Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

How to create a custom order status in woocommerce

Writer Sebastian Wright

I've tried the below code to create custom status.

add_action( 'init', function() { $term = get_term_by( 'name', 'shipped', 'shop_order_status' ); if ( ! $term ) { wp_insert_term( 'shipped', 'shop_order_status' ); }
} );

But it is not working. I tried some other methods also. Please can anyone help me on this..

1 Answer

You need to first register your custom status and then add it to the order statuses array.

function register_shipped_order_status() { register_post_status( 'wc-shipped', array( 'label' => 'Shipped', 'public' => true, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop( 'Shipped <span>(%s)</span>', 'Shipped <span>(%s)</span>' ) ) );
}
add_action( 'init', 'register_shipped_order_status' );
add_filter( 'wc_order_statuses', 'custom_order_status');
function custom_order_status( $order_statuses ) { $order_statuses['wc-shipped'] = _x( 'Shipped', 'Order status', 'woocommerce' ); return $order_statuses;
}
0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy