Magento – Change Order Number and Invoice Number

invoicemagento-2.1.7orderssales-order

I am using Magento-2.1.7 and I want to change order, invoice and shipment number from 10000001 to 20000000.

How can I do this?

Best Answer

Please perform following.

  1. Open your PHP Admin database
  2. Find & click on the table called: sequence_order_1 (it is located in database itself not in the information_schema )
  3. Click on "Operations" tab & under "AUTO_INCREMENT" edit to desired order number.

You can do same for shipment and invoice tables sequence_invoice_1 and sequence_shipment_1

EDIT To change digits length.

Change The Sequence To change the order number padding edit Sequence.php (I believe there is a better way via a di.xml)

vendor/magento/module-sales-sequence/Model/Sequence.php

Edit this line

const DEFAULT_PATTERN  = "%s%'.09d%s";

Change the "9" to the desired padding

Example

const DEFAULT_PATTERN  = "%s%'.08d%s";
Related Topic