'Woocommerce apply custom order status
Woocommerce custom order status is getting set to pending payment instead of the custom order specified. So, here is what I'm trying to do. I have created a custom order status called Archive Order, here is my code:
// Register New Order Statuses
function wpex_wc_register_post_statuses() {
register_post_status( 'wc-archive-order', array(
'label' => _x( 'Archive Order', 'WooCommerce Order status', 'woocommerce' ),
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Archive (%s)', 'Archive (%s)', 'woocommerce' )
) );
}
add_filter( 'init', 'wpex_wc_register_post_statuses' );
// Add New Order Statuses to WooCommerce
function wpex_wc_add_order_statuses( $order_statuses ) {
$order_statuses['wc-archive-order'] = _x( 'Archive Order', 'WooCommerce Order status', 'woocommerce' );
return $order_statuses;
}
add_filter( 'wc_order_statuses', 'wpex_wc_add_order_statuses' );
Elsewhere on the site I make an ajax (php no js) call to update the order status like so:
$order = wc_get_order($order_id);
$order->update_status( 'archive-order', '', true) ;
However I get pending payment instead of archive order status. I have tried many different things nothings seams to get the custom order status working. Also, I don't see it in the drop down either, where I can update order statuses.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
