Created
October 25, 2019 06:03
-
-
Save zorem/acc273dccad16095836b8aab058dbe93 to your computer and use it in GitHub Desktop.
From this code snippet you can create custom order status partial shipped
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 this code to your theme functions.php file or a custom plugin | |
add_action('init', 'register_partial_shipped_order_status'); | |
//add status after completed | |
add_filter('wc_order_statuses', 'add_partial_shipped_to_order_statuses'); | |
//Custom Statuses in admin reports | |
add_filter('woocommerce_reports_order_statuses', 'include_partial_shipped_order_status_to_reports', 20, 1); | |
// for automate woo to check order is paid | |
add_filter('woocommerce_order_is_paid_statuses', 'partial_shipped_woocommerce_order_is_paid_statuses'); | |
/*** Register new status : Delivered | |
* https://www.zorem.com/how-to-create-custom-order-status-in-woocommerce/ | |
**/ | |
function register_partial_shipped_order_status() | |
{ | |
register_post_status('wc-partial-shipped', array( | |
'label' => __('Partial Shipped', 'text-domain'), | |
'public' => true, | |
'show_in_admin_status_list' => true, | |
'show_in_admin_all_list' => true, | |
'exclude_from_search' => false, | |
'label_count' => _n_noop('Partial Shipped <span class="count">(%s)</span>', 'Partial Shipped <span class="count">(%s)</span>', 'text-domain') | |
)); | |
} | |
/* | |
* add status after completed | |
*/ | |
function add_partial_shipped_to_order_statuses($order_statuses) | |
{ | |
$new_order_statuses = array(); | |
foreach ($order_statuses as $key => $status) { | |
$new_order_statuses[$key] = $status; | |
if ('wc-completed' === $key) { | |
$new_order_statuses['wc-partial-shipped'] = __('Partial Shipped', 'text-domain'); | |
} | |
} | |
return $new_order_statuses; | |
} | |
/* | |
* Adding the custom order status to the default woocommerce order statuses | |
*/ | |
function include_partial_shipped_order_status_to_reports($statuses) | |
{ | |
if ($statuses) | |
$statuses[] = 'partial-shipped'; | |
return $statuses; | |
} | |
/* | |
* mark status as a paid. | |
*/ | |
function partial_shipped_woocommerce_order_is_paid_statuses($statuses) | |
{ | |
$statuses[] = 'partial-shipped'; | |
return $statuses; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment