How to Change the Sequence of Custom Field Before “subtotal” in Invoice in Magento 2 Backend

An invoice is the legal accounting document that shows the transaction details between a merchant and a customer. Businesses need to craft the invoice design meticulously as it represents the brand and contributes to customers’ trust and shopping experience.

The Magento 2 store admin has to generate invoices for orders placed online. The invoice layout in backend must also be such that helps admin manage the order details easily.

The default Magento 2 offers an invoice template as shown below.

Default Magento output

The admin may want to add custom fields and change the sequence of the existing fields as per the business requirements.

Here, I have taken the example to change the sequence of custom field before “subtotal” in invoice in Magento 2 backend.

In this example, the “qty” custom field is added and the sequence of “subtotal” changes as “qty” is placed in the first position.

Such changes in Magento 2 admin panel for invoice helps admin to get all the required details in invoice totals in the sequence of priority.

Steps to Change the Sequence of Custom Field Before “subtotal” in Invoice in Magento 2 Backend:

  1. Create registration.php file at app\code\Vendor\Module directory
  2. Create module.xml file at app\code\Vendor\Module\etc directory

  3. Create sales_order_invoice_new.xml file at app\code\Vendor\Module\view\adminhtml\layout

  4. Create Qty.php file at app\code\Vendor\Module\Block\Sales\Order

Using the above code, the QTY field is added to the invoice before subtotal as shown in below image.

Custom OP

That’s all!

If you have any doubts regarding this post, do mention them in the Comments section below.

I would be happy to help.

Feel free to share the solution with Magento Community via social media.

Thank You.

Related Posts:

  1. How to Create Barcode and Add it in Magento 2 Invoice PDF
  2. How to Add Order In Invoice PDF in Magento 2
  3. How to Change PDF Invoice Logo in Magento 2
  4. How to Add Header and Footer to Magento 2 Invoice PDF
(based on 15 Reviews)
How to Change the Sequence of Custom Field Before “subtotal” in Invoice in Magento 2 Backend

Kanchi Upadhyay

Kanchi is a Magento Developer at Meetanshi. Apart from that, she is into dancing. In her free time, she likes to make handmade art and craft.

Leave a Reply

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