How to keep sequential order numbers after deactivate plugin or disabling the sequential order option

By adding this code you can retain the order numbers that were added by the option to use sequential numbers that were activated.

Our plugin has an option to use sequential order numbers for all orders. But if you deactivate that option or uninstall the plugin the order numbers will change to the default WooCommerce order numbers.

Note that we recommend the plugin mentioned when adding custom code, but you might as well add that code to functions.php in your themes/child themes.

The solution works both for ordinary WordPress sites and WordPress multisite.

Install and network activate

Add the custom code into the plugin:

function get_sequential_order_number( $order_number ) {
   $_order_number = get_post_meta( $order_number, '_order_number', true );

   if ( $_order_number > 0 ) {
      return $_order_number;

   return $order_number;

add_filter( 'woocommerce_order_number', 'get_sequential_order_number', 10, 1 );