我想在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小時後更新。並抱歉不通知。 –