Remove Leading Zeros in Order Number – Magento 2 Guide

magento2orders

I am trying to remove the leading zeros from the order numbers. I have figured out how to set the sequence just fine. We want to set the orders to start in the 275000 range.

Right now its in the database, visually, etc at 0000275000.

I'd like it to show just 275000.

Any guidance is appreciated. I thought this could be solved via database, but I am not seeing it.

Best Answer

This article helped me with this issue: https://www.classyllama.com/blog/m2-incrementid

What I did on my site is create a module (or you can piggy-back on an existing module) and this is my etc/di.xml

<?xml version="1.0"?>
<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%'.06d%s</argument>
        </arguments>
    </type>
</config>
Related Topic