For big businesses dealing with lots of orders, deleting old invoice numbers is really helpful. It fixes mistakes, makes the system faster, and saves time when searching for invoices. The WebToffee’s WooCommerce PDF Invoices, Packing Slips, Delivery Notes, and Shipping Labels plugin allows store owners to delete existing invoice numbers. Store owners can do this in two ways:
- Using a custom tool. Steps to follow while using a custom tool for deletion are as follows:
- Navigate to the Invoice settings page.
- Clear all the order statuses selected under Automate invoice creation.
- Navigate to WooCommerce > Status > Tools.
- Perform the deletion using the Delete all generated invoice numbers tool.
- Using a custom code snippet. Steps to follow while using a custom code snippet for deletion are as follows:
- Add the custom code snippet to the WordPress site in use.
- Refresh the WooCommerce Orders listing page.
- Once done with the deletion, remove the custom code snippet from the WordPress site.
Deleting invoice numbers using a custom tool
To delete all the existing invoice numbers:
- Navigate to Invoice/Packing > Invoice > General.
- Under the General section, head to Automate invoice creation.
- Clear all the order statuses selected under the Automate invoice creation option.
- Click on Update Settings.
- Now, head to WooCommerce > Status > Tools
- Under the Tools tab, navigate to the Delete all generated invoice numbers tool.
- Click on the Delete button present against the tool. On clicking the Delete button a confirmation window will pop up.
- Click on the OK button and run the tool.
Deleting invoice numbers using a custom code snippet
To delete all the existing invoice numbers using a custom code snippet, follow these steps:
- Add the custom code snippet below to the WordPress site which is currently in use. Add it to the active child theme’s functions.php file or use a third-party plugin for the addition. To know more about how to add a custom code snippet using a third-party plugin, refer to this article.
delete_post_meta_by_key( 'wf_invoice_number' );
- On adding the code, refresh the WooCommerce Orders listing page and make sure that the existing invoice numbers are deleted.
- On deletion of the invoice numbers, remove the custom code snippet from the WordPress site.
Alternative Method
The plugin stores the invoice numbers under the meta key wf_invoice_number and contains them in the tables wp_postmeta and wp_wc_orders_meta. If you have access to the SQL DB of your website you can delete it with an SQL query.
Upon deletion of the existing invoice numbers, the WooCommerce Orders listing page will look like this:
- To know more about how to create invoice numbers for upcoming orders, refer to this article.