Skip to content
Advertisement

How to add woocommerce custom order status?

I have added new custom order status to woocommerce by using following function.

JavaScript

whenever I go to edit order and changed the order status to newly added custom order status and click on Save Order button. After loading the order status automatically changes to Pending Order not stands in newly added custom order…

enter image description here

enter image description here

How to overcome this problem…?

Advertisement

Answer

The order status that you’re registering wc-custom-order-status is too long – 22 characters. This results in saving only the first 20 characters of the post status, which makes it invalid and causes your issue.

The order statuses are registered as post statuses, and post statuses have a limitation of 20 characters.

I suggest that you update your wc-custom-order-status status name to wc-shipping-progress, which is exactly 20 characters in length.

I’m also posting the updated version of your code, just for reference (I’ve only changed the status name):

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement