Last active
October 31, 2020 02:19
-
-
Save cmbibby/f45a6ac6873017b82441d574bd6c91af to your computer and use it in GitHub Desktop.
Add custom WooCommerce order Status
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* Register the status | |
* | |
* Note the status must start with wc- | |
* | |
*/ | |
function my_custom_order_status($order_statuses){ | |
$order_statuses['wc-my-status'] = array( | |
'label' => _x( 'My Status', '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( 'My Status<span class="count">(%s)</span>', 'My Status<span class="count">(%s)</span>', 'woocommerce' ), | |
); | |
return $order_statuses; | |
} | |
add_filter('woocommerce_register_shop_order_post_statuses', 'my_custom_order_status',10,1); | |
/** | |
* | |
* Add it to the other order statuses | |
* | |
*/ | |
function show_custom_order_status( $order_statuses ) { | |
$order_statuses['wc-my-status'] = _x( 'My Status', 'Order status', 'woocommerce' ); | |
return $order_statuses; | |
} | |
add_filter( 'wc_order_statuses', 'show_custom_order_status',10,1); | |
/** | |
* | |
* Make it so we can bulk edit | |
* "mark_" must be used instead of "wc" | |
*/ | |
function get_custom_order_status_bulk( $bulk_actions ) { | |
$bulk_actions['mark_my-status'] = 'Change status to My Status'; | |
return $bulk_actions; | |
} | |
add_filter( 'bulk_actions-edit-shop_order', 'get_custom_order_status_bulk',10,1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment