BlogTutorials

Create WooCommerce Custom Order Statuses For WordPress

woocommerce custom order

WooCommerce is an superior WordPress plugin to advertise merchandise on-line. And proper this second I’d like to point you recommendations on how one can create plugin to allow you to Create WooCommerce Custom-made Order Statuses For WordPress  .

By default WooCommerce offers these order statuses:

  • cancelled
  • completed
  • failed
  • on-hold
  • pending
  • processing
  • refunded

Nonetheless what when you want to add new statuses, or maybe modify present ones? Beneath is an occasion exhibiting you the way in which simple it is in order so as to add a model new order standing to your WooCommerce orders.

Visually proper right here is the last word final result:

woocommerce-custom-order-status

Register New WooCommerce Order Standing

Beforehand WooCommerce used a “shop_order_status” taxonomy so together with new order statuses was a bit robust, nonetheless, now it’s less complicated then ever! Have a look on the code beneath for an occasion.

// Register New Order Statuses
function wpex_wc_register_post_statuses() {
	register_post_status( 'wc-custom-order-status', array(
		'label'						=> _x( 'Custom-made Order Standing Title', 'WooCommerce Order standing', 'text_domain' ),
		'public'					=> true,
		'exclude_from_search'		=> false,
		'show_in_admin_all_list'	=> true,
		'show_in_admin_status_list'	=> true,
		'label_count'				=> _n_noop( 'Accepted (%s)', 'Accepted (%s)', 'text_domain' )
	) );
}
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-custom-order-status'] = _x( 'Custom-made Order Standing Title', 'WooCommerce Order standing', 'text_domain' );
	return $order_statuses;
}
add_filter( 'wc_order_statuses', 'wpex_wc_add_order_statuses' );

In case you want to add various new WooCommerce Custom-made Order Statuses For WordPress, merely duplicate the register_post_status function contained within the wpex_wc_register_post_statuses function as many events as you want making certain to alter the ID and the labels accordingly. Then add the model new order standing to the $order_statuses array inside the wpex_wc_add_order_statuses function.

Download The WPSaviour App Now

Pay in your preferred currency
Indian rupee
Euro