Read More
Read More
Menu Close

    How to change Magento 2 Order’s Increment Id PAD-LENGTH ?

    Some merchants want to customize order’s Increment id PAD-LENGTH numbers to be different than what Magento 2 produces by default.
    PAD-LENGTH is the number of zeros in increment id of an order

    Increment id is the ID through which a store owner communicate with the customer.

    An order increment id is consist of following parts:

    1. Prefix
    2. Suffix
    3. Start-value
    4. Pad-length

    The Prefix, Suffix, Start-value, and Step are stored in the database, while the Pad-length is set in the code.

    Here we only talk about PAD-LENGTH. The PAD-LENGTH of the increment-ID is determined in the code base, and it’s not affected by any database properties.
    In \Magento\SalesSequence\Mdel\Secequence, the getCurrentValue() method used for to set the pattern of the increment id number:

    Searching for an experienced
    Magento 2 Company ?
    Read More

    the “$this->pattern” got value from the constant DEFAULT_PATTERN
    which is initially %s%’.09d%s.

     

    %’.09d. The ‘.0 sets “0” as the padding character and sets the number of digits to display as the value that follows, which in this case is 9. The d presents the number as a [signed] decimal. This means that by default, the increment-ID number will be a signed decimal with 9 digits, padded with 0s.

    How to change PAD-LENGTH

    We can change this in a custom module by creating etc/di.xml

    Here I have set the padding 6 from default padding  9 zero.

    . . .
    Discuss on Helpdesk

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top