5

When developing a payment fee, I want to add a surcharge fee to Pdf. I found the pdf.xml config. However, I don't know how it works. Can anyone help me to explain the config pdf xml.

vendor/magento/module-sales/etc/pdf.xml

<totals>

        <total name="discount">
            <title translate="true">Discount</title>
            <source_field>discount_amount</source_field>
            <title_source_field>discount_description</title_source_field>
            <font_size>7</font_size>
            <display_zero>false</display_zero>
            <sort_order>200</sort_order>
        </total>

UPDATE: Good explain here: Magento 2: How to Read From Configuration Tree

1
  • 1
    The file pdf.xml configuration is used in the Magento\Shipping\Model\Order\Pdf\Packaging Commented May 30, 2016 at 9:19

1 Answer 1

1

If you refer vendor\magento\module-sales\etc\pdf.xml

....
<totals>
    <total name="subtotal">
        <title translate="true">Subtotal</title>
        <source_field>subtotal</source_field>
        <font_size>7</font_size>
        <display_zero>true</display_zero>
        <sort_order>100</sort_order>
    </total>
    <total name="discount">
        <title translate="true">Discount</title>
        <source_field>discount_amount</source_field>
        <title_source_field>discount_description</title_source_field>
        <font_size>7</font_size>
        <display_zero>false</display_zero>
        <sort_order>200</sort_order>
    </total>
    <total name="shipping">
        <title translate="true">Shipping &amp; Handling</title>
        <source_field>shipping_amount</source_field>
        <font_size>7</font_size>
        <display_zero>false</display_zero>
        <sort_order>400</sort_order>
    </total>
    <total name="adjustment_positive">
        <title translate="true">Adjustment Refund</title>
        <source_field>adjustment_positive</source_field>
        <font_size>7</font_size>
        <display_zero>false</display_zero>
        <sort_order>500</sort_order>
    </total>
    <total name="adjustment_negative">
        <title translate="true">Adjustment Fee</title>
        <source_field>adjustment_negative</source_field>
        <font_size>7</font_size>
        <display_zero>false</display_zero>
        <sort_order>600</sort_order>
    </total>
    <total name="grand_total">
        <title translate="true">Grand Total</title>
        <source_field>grand_total</source_field>
        <font_size>8</font_size>
        <display_zero>true</display_zero>
        <sort_order>700</sort_order>
    </total>
</totals>

In this tags, <souce_field>, it gets from the fields of sales_order table in the database.

If you see your database sales_order table, you should find discount_amount field.

Each order has the values of totals' fields including discount_amount because your discount module saved the value into the field discount_amount.

Your Answer

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

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