Get 15% off Mageplaza extensions & subscriptions! Use code HIMAY at checkout.

How to Set Invoice Numbers to Depend on Order Numbers in Magento 2

Vinh Jacker | 07-04-2019

The Most Popular Extension Builder for Magento 2

With a big catalog of 224+ extensions for your online store

Magento 2 Custom Order Number made by Mageplaza is well-known as an indispensable tool that supports store owners to customize the default string of Magento 2 to the sophisticated one to manage and protect business data. The most useful feature of this module is generating the same invoice number based on the purchase number. This function helps shop admins save time to control their work.

Why setting invoice numbers to depend on order numbers is useful?

setting invoice numbers to depend on order numbers

The invoice number for each order is unique in your company’s accounting system, which helps you identify the shipments and customers. This is the reason why creating an associated formula between orders and related billing documents such as invoices, shipment, credit memo is necessary. When a customer places any purchase at your store, the system will make the format of order ID based on your intention thanks Mageplaza Custom Order Number.

An issued invoice will have the string linked with the series’ structure. The format of invoice ID can be generated by replacing the prefix with other letters and keeping the rest of the pattern unchanged. For example, the order number is ORD-01-280519-001, while its invoice is INV-01-280519-001. The structure set by store owners not only helps protect internal data from competitors but also impress visitors with a professional-looking number system from order, invoice, shipment, and credit memo.

How to configure same invoice numbers depending on order numbers?

Before setting up the invoice string matching with its order, let’s take a look at the configuration at the backend. Please go to the Magento Admin, choose Store > Settings > Configuration > Custom Order Number

configure same invoice numbers depending on order numbers

For General Configuration, go to Store > Settings > Configuration > Custom Order Number > General


In the Enable box, you can choose Yes to allow this module.

Firstly, store owners need to adjust the structure of orders before creating the same invoice series based on its format. From the Admin Panel, go to Store > Settings > Configuration > Custom Order Number, choose Order Number section.

Order Number

At Order Number section, choose “Yes” at Enable box to activate this function. Then, you can set up the number order strings as your intention by using syntax. After finishing the base steps to create the formula of the order string, generating the invoice number’s structure will be more simple.

Invoice Number

At Enable box, you choose option “Same as Order Number” to use the configuration the same as the configuration of Order Number At Replace row, you can type the prefix of the order series which would be changed. If leaving this blank, after saving, the Invoice ID will display the same as the configuration of Magento 2.

At To field, you will fill in the replacement value. If leaving this field blank, the value in front of the Replace field will be used. This value is the same as you added in the previous row. For example, the order number, which is ORD-01-280519-001 will be replaced with INV-01-280519-001 for its detailed invoice. The combination of Custom Order Number extension and PDF Invoice allows displaying in the proper format in billing documents which can be sent to customers or print in different sizes of paper.

Final words

To sum up, Custom Order Number is a useful tool for every store using the Magento 2 platform for its e-commerce. For medium and big online shops, it will help store owners to track their orders smartly. With the string of the invoice, they know it applies to which order ID and all information related to the customer. For the newly established stores, it’s not only a way to impress customers due to the professional structure for invoices and orders but also to hide sophisticated information from their rivals.

Custom Oder Number

Custom Order Number for Magento 2

Change order numbers, and increment ID prefixes to protect sensitive business data.

Check it out!


Hello, I'm the Chief Technology Officer of Mageplaza, and I am thrilled to share my story with you. My deep love and passion for technology have fueled my journey as a professional coder and an ultra-marathon runner. Over the past decade, I have accumulated extensive experience and honed my expertise in PHP development.

Related Post

Website Support & Maintenance Services

mageplaza services

Make sure your store is not only in good shape but also thriving with a professional team yet at an affordable price.