Match Invoice Numbers to WooCommerce Order Numbers
In this article
If you run a WooCommerce store, you've probably noticed that your invoices and your order numbers don't line up. This can make bookkeeping confusing and frustrate customers who call about "order #1042" while you're looking at "invoice #1005." This guide shows you how to make your invoice numbers match your WooCommerce order numbers, so every document is easy to cross-reference. You'll need admin access to your WordPress dashboard and a few minutes to set it up. The exact steps depend on which invoice plugin you use, but the most popular ones are covered here.
What You'll Need
- Administrator access to your WordPress site
- An active invoice plugin (such as WooCommerce PDF Invoices & Packing Slips, PDF Invoices for WooCommerce, or similar)
- Access to your WordPress admin area (wp-admin)
- Optional: a staging site to test changes before going live
Step-by-Step
Method 1: Using WooCommerce PDF Invoices & Packing Slips (the free plugin)
- Log in to your WordPress admin dashboard.
- Go to WooCommerce → PDF Invoices → Documents (or Invoice if you're on an older version).
- Click on the Invoice document type to open its settings.
- Look for a section called Numbering or Invoice Number.
- Find the option Order number as invoice number and enable it (check the box or switch the toggle).
- If you see an option like Reset invoice number yearly, leave it off unless you specifically want the invoice number to restart each year (which would break the match with order numbers).
- Click Save at the bottom of the page.
- Now generate a test invoice for a recent order to confirm the invoice number matches the order number.
Method 2: Using PDF Invoices for WooCommerce (by WPBean)
- Go to WooCommerce → PDF Invoice in your WordPress admin.
- Click on the General tab.
- Scroll down to the Invoice Number section.
- Look for a setting called Invoice Number Format or Invoice Number.
- Select the option that says Order Number (sometimes labeled as "Use Order Number as Invoice Number").
- If there's a prefix/suffix field, leave it empty to keep the invoice number identical to the order number.
- Save your changes.
- Test by creating a new order and downloading its PDF invoice.
Method 3: Using a Custom Code Snippet (for any plugin)
If your plugin doesn't have a built-in option, you can use a small code snippet in your theme's functions.php file or a code snippet plugin.
- Install a code snippet plugin like Code Snippets (or use a child theme's functions.php).
- Add the following filter (adjust the hook name to match your plugin; this example works for the free plugin):
add_filter( 'wpo_wcpdf_invoice_number', 'set_invoice_number_to_order_number', 10, 4 ); function set_invoice_number_to_order_number( $invoice_number, $document, $order, $context ) { if ( $document->get_type() === 'invoice' ) { return $order->get_order_number(); } return $invoice_number; }- Save the snippet and activate it.
- Test with a new order to verify the invoice number equals the order number.
Important: If you've already generated invoices with your current numbering system, changing the setting will only affect new invoices. Existing invoices keep their old numbers.
Common Mistakes
- Enabling yearly reset: Some plugins have a "reset invoice number every year" option. If you enable this, your invoice numbers will restart at 1 each January, breaking the match with order numbers.
- Using a prefix or suffix: Adding a prefix like "INV-" or a suffix like "-2024" makes the invoice number different from the order number. If you want them to match exactly, leave these fields empty.
- Not clearing cache: After changing settings, your site may serve cached PDFs. Clear any caching plugins and your browser cache before testing.
- Testing on an old order: If you test on an order that already has an invoice generated, the plugin may not re-generate it. Always test on a new order.
- Editing functions.php incorrectly: A small syntax error can break your site. Always use a code snippet plugin or a child theme to avoid losing changes.
Tips
- Before making changes, note your current invoice numbering. If you need to revert, you'll know what to set it back to.
- If you use sequential order numbers (a plugin like WooCommerce Sequential Order Numbers), the invoice number will match the sequential number, not the default order ID. That's fine—it's still a match.
- Test on a staging site first if possible, especially if you're using custom code.
- Keep your invoice plugin updated to ensure the settings remain available.
- If you have many existing orders with mismatched numbers, consider whether you want to renumber them. Most plugins don't allow retroactive changes easily, so weigh the effort.
Troubleshooting
Invoice number still doesn't match after enabling the setting.
First, check if you have any caching plugin that might be serving old PDFs. Clear all caches (site, browser, CDN) and try again. Also, make sure you're generating a new invoice for a new order—not re-downloading an old one.
The option "Order number as invoice number" is not visible.
Some plugins only show this option if you have the premium version. Check your plugin's documentation. If it's not available, use the custom code snippet method above.
My invoice numbers are still sequential but not matching order numbers.
This can happen if you have a separate invoice numbering sequence that starts at 1 and increments independently. Look for a setting called "Invoice number start" or "Number of digits"—set it to match your order numbers, or use the custom code method to force the order number.
After adding the code snippet, my site shows a white screen.
This usually means there's a syntax error in your code. Immediately deactivate the snippet or remove the code from functions.php (via FTP if needed). Then re-add the code carefully, checking for missing semicolons or parentheses.
Existing invoices have old numbers, and I want them to match too.
This is more complex. You'll need to manually edit the invoice numbers in your database or use a plugin that supports renumbering. This is risky and may break references. Consider whether it's necessary—many stores simply accept that old invoices keep their numbers.
Frequently Asked Questions
Will this change affect my accounting software?
Yes, it will make your invoices match your order numbers, which is generally a good thing for accounting. However, if you've already synced old invoices to your accounting software, those won't change. New invoices will match.
Can I use this with a sequential order number plugin?
Yes, as long as you set your invoice number to use the order number (which will be the sequential number), it will match perfectly.
What if I already sent an invoice to a customer with a different number?
That invoice will keep its original number. Only new invoices will match. You can send a note to the customer if needed, but most won't notice.
Does this work with all invoice plugins?
Most popular plugins have a built-in option or allow a filter. If yours doesn't, the custom code method should work as long as the plugin provides a filter hook. Check your plugin's documentation.
Will my invoice numbers start from 1 again?
No, if you set the invoice number to match the order number, it will use the existing order number. So if your next order is #1050, the invoice will be #1050.
Can I revert to my old numbering system later?
Yes, simply disable the setting or remove the code snippet. Your invoices will go back to the previous numbering for new orders. Old invoices remain unchanged.