How To Change Order Increment ID Length In Magento 2

In this post, I will guide you on How To Change Order Increment ID Length In Magento 2. Customize order ID length as desired with just one piece of code added to the custom module.

By default, the order increment ID length is 9. However, it can be changed and these changes will apply to shipments, invoices, and credit memos.

Steps To Change Order Increment ID Length In Magento 2

1. Create di.xml file in the following path:

app\code\{your-Vendor}\{your-Extension}\etc\di.xml

2. If your module already has a di.xml file, open it and add the following code:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Framework\DB\Sequence\SequenceInterface">
        <arguments>
            <argument name="pattern" xsi:type="string">%s%'.08d%s</argument>
        </arguments>
    </type>
</config>

In the above code we have set the order id length to 8. You can completely change them to the number you want for the order id length. From there, the length of the increment id in the shipment, invoice, and credit memo will also be changed.

3. Then, run clear cache, flush cache command and see the result:

php bin/magento cache:clean
php bin/magento cache:flush

Following the above steps will help you to change the order increment id length as desired easily.

Follow us for the more helpful posts!

We hope this is a useful post for you.

You can read more useful posts likeĀ How To Add Custom Meta Tag In Product View Page In Magento 2.

Thank you for reading!

4.8 4 votes
Article Rating

Aaron LX

Aaron is a passionate writer, crazy about shopping, eCommerce and trends. Besides his outstanding research skills and a positive mind, Aaron eagerly shares his experience with the readers.

Leave a Reply or put your Question here

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x