1

How can i change the sort order in invoice PDF?

Now i have:

enter image description here

But i want the following:

  • Subtotal
  • Shipping
  • Total

  • TAX 6%

  • TAX 21%
  • Total TAX

Thanks!

2 Answers 2

2

You can customise the sort order of totals for PDFs in XML. You will need to setup a basic module (and ensure it has dependencies of Mage_Sales and Mage_Tax), then add the following code the config.xml of your module:

Note: I have left the default ordering as is below, you can customise to your needs.

<global>
    <pdf>
        <subtotal>
            <sort_order>100</sort_order>
        </subtotal>
        <discount>
            <sort_order>200</sort_order>
        </discount>
        <tax>
            <sort_order>300</sort_order>
        </tax>
        <shipping>
            <sort_order>400</sort_order>
        </shipping>
        <adjustment_positive>
            <sort_order>500</sort_order>
        </adjustment_positive>
        <adjustment_negative>
            <sort_order>600</sort_order>
        </adjustment_negative>
        <grand_total>
            <sort_order>700</sort_order>
        </grand_total>
    </pdf>
</global>
0

Looking at the code found in Mage\Sales\Model\Order\Pdf\Abstract.php around line 547 (Magento 1.8.1) you should see:

$totals = Mage::getConfig()->getNode('global/pdf/totals')->asArray();

That means a element should exist after . The config file should be:

<global>
    <pdf>
        <totals>
            <subtotal>
                <sort_order>100</sort_order>
            </subtotal>
            <discount>
                <sort_order>200</sort_order>
            </discount>
            <tax>
                <sort_order>300</sort_order>
            </tax>
            <shipping>
                <sort_order>400</sort_order>
            </shipping>
            <adjustment_positive>
                <sort_order>500</sort_order>
            </adjustment_positive>
            <adjustment_negative>
                <sort_order>600</sort_order>
            </adjustment_negative>
            <grand_total>
                <sort_order>700</sort_order>
            </grand_total>
        </totals>
    </pdf>
</global>

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.