Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
Last active August 26, 2025 07:05
Show Gist options
  • Select an option

  • Save webtoffee-git/857e1d9ca6b5acde173c09094d9c4fa6 to your computer and use it in GitHub Desktop.

Select an option

Save webtoffee-git/857e1d9ca6b5acde173c09094d9c4fa6 to your computer and use it in GitHub Desktop.
Code to retain Sequential number for old orders even after deactivating the plugin - By WebToffee
<?php //Do not copy this line of code
add_filter('woocommerce_order_number', 'wt_show_old_order_number', PHP_INT_MAX, 2);
function wt_show_old_order_number($order_number, $order)
{
if ($order instanceof WC_Order) {
$meta_value = $order->get_meta('_order_number');
if ($meta_value) {
$order_number = $meta_value;
}
}
return $order_number;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment