1

I am working on Magento 2 pdf invoice and trying to change layout of default invoice.As I have seen in default Magento pdf there are six column for displaying items in pdf

Products
SKU
Price
Qty 
Tax
Subtotal

When I have checked in admin email template it is calling layout for displaying all items

{{layout area="frontend" handle="sales_email_order_invoice_items" invoice=$invoice order=$order}}

and in phtml file

vendor/magento/module-sales/view/frontend/templates/email/invoice/items.phtml

there are only three column

<thead>
        <tr>
            <th class="item-info">
                <?= /* @escapeNotVerified */  __('Items'); ?>
            </th>
            <th class="item-qty">
                <?= /* @escapeNotVerified */  __('Qty'); ?>
            </th>
            <th class="item-subtotal">
                <?= /* @escapeNotVerified */  __('Subtotal'); ?>
            </th>
        </tr>
    </thead>

I am not getting which file is exactly called when

{{layout area="frontend" handle="sales_email_order_invoice_items" invoice=$invoice order=$order}}

layout is loaded.Please help me if anybody know about it.

1
  • Hi, did you get the solution? i need the same to customize the default invoice.. share your solutions bro
    – Ask Xah
    Dec 11, 2018 at 11:07

2 Answers 2

2

Below Model class is responsible for displaying items in invoice pdf.

Magento\Sales\Model\Order\Pdf\Invoice.php

You need to override this model class.

0

I realise this is an old post, but thought it may be of help for anyone visiting in future.

{{layout area="frontend" handle="sales_email_order_invoice_items" invoice=$invoice order=$order}}

This handle is reffering to sales_email_order_invoice_items.xml

From this, we can see that it is likely to be inside the module-sales module. vendor/magento/module-sales/view/frontend/layout/sales_email_order_invoice_items.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Email Invoice Items List" design_abstraction="custom">
    <update handle="sales_email_order_invoice_renderers"/>
    <update handle="sales_email_item_price"/>
    <body>
        <block class="Magento\Sales\Block\Order\Email\Invoice\Items" name="items" template="Magento_Sales::email/invoice/items.phtml">
            <block class="Magento\Framework\View\Element\RendererList" name="sales.email.order.invoice.renderers" as="renderer.list"/>
            <block class="Magento\Sales\Block\Order\Invoice\Totals" name="invoice_totals" template="Magento_Sales::order/totals.phtml" cacheable="false">
                <arguments>
                    <argument name="label_properties" xsi:type="string">colspan="2"</argument>
                </arguments>
                <block class="Magento\Tax\Block\Sales\Order\Tax" name="tax" template="Magento_Tax::order/tax.phtml"/>
            </block>
        </block>
        <block class="Magento\Framework\View\Element\Template" name="additional.product.info" template="Magento_Theme::template.phtml"/>
    </body>
</page>

Inside this file, you can then see the different PHTML files which are being used:

vendor/magento/module-sales/view/frontend/templates/email/invoice/items.phtml
vendor/magento/module-tax/view/frontend/templates/order/tax.phtml
vendor/magento/module-sales/view/frontend/templates/order/totals.phtml

If you need to edit this files; do not edit the core files directly - Place an over-ride into your theme folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.