Magento – Totals for emails and pdf invoices

invoicetotals

Where are the PDF invoices totals pulled from? I see that it is an array in abstract.php, but where does the original files come from?

Best Answer

It helps to take a look at how Magento implements it - most totals are added in the sales module in /app/code/core/Mage/Sales/etc/config.xml

For example the subtotal is defined here

<config>
    <global>
        <!-- SNIP -->
        <sales>
            <!-- SNIP -->
            <quote>
                <totals>
                    <subtotal>
                        <class>sales/quote_address_total_subtotal</class>
                        <after>nominal</after>
                        <before>grand_total</before>
                    </subtotal>
                </totals>
            </quote>
        </sales>
    </global>
</config>

and for the pdf here

<config>
    <global>
        <!-- SNIP -->
        <pdf>
            <!-- SNIP -->
            <totals>
                <subtotal translate="title">
                    <title>Subtotal</title>
                    <source_field>subtotal</source_field>
                    <font_size>7</font_size>
                    <display_zero>1</display_zero>
                    <sort_order>100</sort_order>
                </subtotal>
            </totals>
        </pdf>
    </global>
</config>

Use the above configuration in your own module's config.xml file as a start, Adjust subtotal = your total code. Further places to look into
/app/code/core/Mage/Sales/Model/Quote/Address
/app/code/core/Mage/Sales/Model/Order/Pdf

Related Topic