Magento 1.8 – How to Remove Shipping Costs from PDF Invoice (Symmetrics InvoicePdf)

invoicemagento-1.8pdfshipping

I've made a custom shipping calculation, but now I need to remove the Shipping Amount on the pdf invoice.
I'm using the Symmetrics Invoice Pdf, and I've tried to copy

app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php
to
app/code/local/Mage/Sales/Model/Order/Pdf/Abstract.php

and changed

 $totalShippingChargesText = "(" . Mage::helper('sales')->__('Total Shipping Charges') . " "
            . $order->formatPriceTxt($order->getShippingAmount()) . ")";

to

 $totalShippingChargesText = " ";

but it still shows the shipping costs on the invoice pdf.
I don't have a getShippingAmount in my invoice.php (app/code/local/Symmetrics/Invoicepdf/Model/Pdf/Invoice.php).

The module can be find here: https://github.com/symmetrics/mrg_invoicepdf

So where do I have to look?

Best Answer

You could rewrite Symmetrics_InvoicePdf_Model_Pdf_Items_Totals and overwrite the function _getTotalsList() as follows:

protected function _getTotalsList()
{
    $totals = Mage::getConfig()->getNode('global/invoicepdf/totals')->asArray();
    usort($totals, array($this, '_sortTotalsList'));
    $totalModels = array();
    foreach ($totals as $totalInfo) {
        // ignore the shipping amount
        if (!empty($totalInfo['model']) && $totalInfo['source_field'] != 'shipping_amount') {
            $totalModel = Mage::getModel($totalInfo['model']);
            if ($totalModel instanceof Mage_Sales_Model_Order_Pdf_Total_Default) {
                $totalInfo['model'] = $totalModel;
            } else {
                Mage::throwException(
                    Mage::helper('sales')->__(
                        'Pdf total model should extend Mage_Sales_Model_Order_Pdf_Total_Default'
                    )
                );
            }
        } else {
            $totalModel = Mage::getModel($this->_defaultTotalModel);
        }
        $totalModel->setData($totalInfo);
        $totalModels[] = $totalModel;
    }

    return $totalModels;
}

Another option: It should even be enough to build an extension which depends on Symmetrics_InvoicePdf with the following config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <global>
        <invoicepdf>
            <totals>
                <shipping>
                    <model/>
                </shipping>
            </totals>
        </invoicepdf>
    </global>
</config>

By the way you could also have a look at the more flexible, more customisable and better supported extension Firegento_Pdf.