有什么方法可以为部分退款的订单设置自定义订单状态? [英] Is there any way to set a custom Order status for partial refunded order?

查看:237
本文介绍了有什么方法可以为部分退款的订单设置自定义订单状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当订单部分退款时,我想自动将WooCommerce订单状态更新为wc-partialRefunded。

I would like to automatically update my WooCommerce order status to wc-partialRefunded when the order refunded partially.

我已经成功创建了自定义订单状态,但不确定如何计算订单数量并得到结果。

I have successfully created the custom order status and not sure how to count the order quantity and get the result.

有什么方法可以做到这一点?

Is there any way to do this?

我有尝试使用以下代码创建自定义订单状态:-

I have tried below code to create the custom order status:-

add_filter( 'woocommerce_register_shop_order_post_statuses', 'register_custom_order_status' );

function register_custom_order_status( $order_statuses ){

   // Status must start with "wc-"
   $order_statuses['wc-partialRefunded'] = array(                                 
   'label'                     => _x( 'Partial Refunded', 'Order status', 'woocommerce' ),
   'public'                    => false,                                 
   'exclude_from_search'       => false,                                 
   'show_in_admin_all_list'    => true,                                 
   'show_in_admin_status_list' => true,                                 
   'label_count'               => _n_noop( 'Partial Refunded <span class="count">(%s)</span>', 'Partial Refunded <span class="count">(%s)</span>', 'woocommerce' ),                              
   );      
   return $order_statuses;
}




  1. 在以下位置显示订单状态下拉@单个订单和批量操作 @订单



add_filter( 'wc_order_statuses', 'custom_order_status' );


function custom_order_status( $order_statuses ) {      
   $order_statuses['wc-partialRefunded'] = _x( 'Partial Refunded', 'Order status', 'woocommerce' );       
   return $order_statuses;
}

非常感谢,
Sajidul

Many Thanks, Sajidul

推荐答案

这就是我用来创建称为已开票的自定义订单状态的内容。将其添加到主题的功能中。php

This is what I have used to create a custom order status called "Invoiced". Add this to your theme's functions.php

// woo 2.2之后的新订单状态

// New order status AFTER woo 2.2

add_action( 'init', 'register_my_new_order_statuses' );

function register_my_new_order_statuses() {
    register_post_status( 'wc-invoiced', array(
        'label'                     => _x( 'Invoiced', 'Order status', 'woocommerce' ),
        'public'                    => true,
        'exclude_from_search'       => false,
        'show_in_admin_all_list'    => true,
        'show_in_admin_status_list' => true,
        'label_count'               => _n_noop( 'Invoiced <span class="count">(%s)</span>', 'Invoiced<span class="count">(%s)</span>', 'woocommerce' )
    ) );
}

add_filter( 'wc_order_statuses', 'my_new_wc_order_statuses' );

// Register in wc_order_statuses.
function my_new_wc_order_statuses( $order_statuses ) {
    $order_statuses['wc-invoiced'] = _x( 'Invoiced', 'Order status', 'woocommerce' );

    return $order_statuses;
}

来源: https://wordpress.stackexchange.com/a/199295

这篇关于有什么方法可以为部分退款的订单设置自定义订单状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆