Last active
October 9, 2020 13:02
-
-
Save zorem/08ce930dddcff0c7ab0b890bb03310bd to your computer and use it in GitHub Desktop.
The function is going to add this new custom post status into the list of available order statuses within the WooCommerce “Orders” and “Edit Orders” pages so that we can actually use it. We want to pass in the current order statuses so that we can go through them and insert our order status into the list where we’d like it.
This file contains hidden or 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 | |
add_filter('wc_order_statuses', 'add_custom_status_to_order_statuses'); | |
function add_custom_status_to_order_statuses($order_statuses) | |
{ | |
// Replace 'my-custom-status' with your custom order status slug | |
// Replace 'My Custom Status' with your custom order status name | |
$new_order_statuses = array(); | |
foreach ($order_statuses as $key => $status) { | |
$new_order_statuses[$key] = $status; | |
if ('wc-completed' === $key) { | |
$new_order_statuses['wc-my-custom-status'] = __('My Custom Status', 'text-domain'); x | |
} | |
} | |
return $new_order_statuses; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment