Magento 2 generates the order number or order ID automatically. If you wish to change it, the process is not so straightforward. The reason is that altering the order number can impact other store functionality as they are interrelated. Most users who change the ID complain about problems with order tracking, reporting, and other inconsistencies.
If you still wish to know how to change the order ID, we recommend proceeding with caution. However, with our step by step guide, the risk of something going wrong is minimal. Before we list the ways through which you can change the order number, let’s briefly touch upon why you may need to do so.
As stated above, changing the default order number in Magento 2 is not a common or recommended practice. Nevertheless, there could be some scenarios or reasons why a Magento admin might want to consider changing the default order number. Let’s go through these reasons.
One of the reasons that Magento owners may need to change the default order number is because of compliance purposes. For example, a government agency or even your auditor may require a specific numbering format for order number for auditing purposes. Failure to change the numbers can lead to regulatory action and other problems.
The second most common reason for changing the order number is consistency. You may be migrating from Magento 1 to Magento 2 and wish for the same order numbers to be carried forward. Secondly, you may be selling on multiple platforms and want that all platforms have the same order ID mechanism.
Another possible reason for changing the default Magento 2 order number is the specific reporting or analytical requirements where specific order numbering formats make it easier to filter and analyse data.
Lastly, you may consider changing the order numbering solely because you find it convenient. It may make order tracking easier for you or aligns with your personal preferences.
Here are some steps you can follow if you absolutely need to change order numbers in Magento 2:
Important Note: Before making any changes to your order numbers, it's important to back up your Magento database and test this procedure in a development or staging environment. Modifying order numbers in a live store can have unintended consequences. Check out our earlier article on ‘Magento 2 Modes: Set Developer, Production & Default Mode’ to change to development mode.
sequence_order_1
.Auto_Increment
column to your desired order number. For example, if you change the order number to 300007954, the next order numbers will be 300007955, 300007956, and so on.sales_order
and sales_order_grid
tables. If you change order numbers, you may need to update references in these tables as well. This can be complex and may require custom SQL queries.You can also do this by running the following SQL command.
ALTER TABLE sequence_order_1 AUTO_INCREMENT=300007954
If you wish to change the order number by adding a prefix or modifying an existing prefix, here’s what you need to do:
UPDATE ‘sales_sequence_profile’ SET ‘prefix’ = ‘X’ WHERE ‘meta_id’ = 5;
That's all for changing the default order numbers in Magento 2. It's important that you follow best practices, test the changes in a development environment, and maintain proper documentation to make sure that your store's functionality is not compromised if you decide to proceed with changing order numbers. After making the changes, you need to clear the cache and reindex. If you run into an issue or have further queries, contact our team.
This blog was created with FME's SEO-friendly blog