我想在WooCommerce Admin Dashboard Stats小部件中包含自定义订单状态的详细信息。我在wc-processing
之后设置了2个自定义订单状态。在Admin Dashboard Stats小部件中添加自定义订单状态
订单流程付款成功后:
wc-processing
=>wc-awaiting-shipment
=>wc-dispatched
=>wc-completed
。
由于awaiting shipment
和dispatched
是定制订单状态,WooCommerce统计插件是不是反映了总销售金额的订单。问题是,我有很多订单wc-dispatched
和wc-awaiting-shipment
状态。
这是我已经习惯了这种注册的客户订单状态代码:
/**
* Register new status
* Tutorial: http://www.sellwithwp.com/woocommerce-custom-order-status-2/
* */
function register_awaiting_shipment_order_status() {
register_post_status('wc-awaiting-shipment', array(
'label' => 'Awaiting Shipment',
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop('Awaiting shipment <span class="count">(%s)</span>', 'Awaiting shipment <span class="count">(%s)</span>')
));
}
add_action('init', 'register_awaiting_shipment_order_status');
// Add to list of WC Order statuses
function add_awaiting_shipment_to_order_statuses($order_statuses) {
$new_order_statuses = array();
// add new order status after processing
foreach ($order_statuses as $key => $status) {
$new_order_statuses[$key] = $status;
if ('wc-processing' === $key) {
$new_order_statuses['wc-awaiting-shipment'] = 'Awaiting shipment';
}
}
return $new_order_statuses;
}
add_filter('wc_order_statuses', 'add_awaiting_shipment_to_order_statuses');
/**
* Register new status
* Tutorial: http://www.sellwithwp.com/woocommerce-custom-order-status-2/
* */
function register_dispatched_order_status() {
register_post_status('wc-dispatched', array(
'label' => 'Dispatched',
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop('Dispatched <span class="count">(%s)</span>', 'Dispatched <span class="count">(%s)</span>')
));
}
add_action('init', 'register_dispatched_order_status');
// Add to list of WC Order statuses
function add_dispatched_to_order_status($order_status) {
$new_order_statuses = array();
// add new order status after processing
foreach ($order_status as $key => $status) {
$new_order_statuses[$key] = $status;
if ('wc-awaiting-shipment' === $key) {
$new_order_statuses['wc-dispatched'] = 'Dispatched';
}
}
return $new_order_statuses;
}
add_filter('wc_order_statuses', 'add_dispatched_to_order_status');
我怎样才能做到这一点?
谢谢。
@LoicTheAztec:我现在外出旅游,所以现在还不能对其进行测试,将能够8小时后更新。并抱歉不通知。 –