Site icon Qaisar Satti's Blogs

How to Create Custom or Sequential Order Numbers Programmatically

Today we are going to discuss how we can create custom or sequential order numbers programmatically in WooCommerce. Understand one thing before starting, that order number and order ID are not the same terms in WooCommerce.

 

Use  woocommerce_order_number filter hook to change order numbers. You can also add date format {number}-{Year}. (code below)

 

Sequential Order Numbers

So the whole idea of sequential order numbers comes into two parts. In the first part, we need to create a custom field when an order is created.

In the second part, we are using a custom field value as an order number.

add_filter( 'woocommerce_order_number', 'qaisar_custom_order_prefix' );

function qaisar_custom_order_prefix( $orderId ) {

return 'test-'.$orderId;

}
Exit mobile version