2
votes

I want to edit the way the invoice looks and followed the advice available here https://magento.stackexchange.com/questions/41650/how-to-change-pdf-invoice-layout and here https://www.hummingbirduk.com/remove-tax-pdf-invoices-magento/.

  • Magento version is 1.9.3.7
  • I am not looking for modules that modify the invoice look.

What I want is to realign the columns and make the TAX column dissapear. I managed to do so for simple products.

The problem is that configurable and bundle products still show the components with tax column included and the others are still displaced.

code/local/mage/sales/model/order/pdf/Invoice.php ( commenting the lines starting at line 77)

$lines[0][] = array(
            'text'  => Mage::helper('sales')->__('Tax'),
            'feed'  => 495,
            'align' => 'right'
        );

will hide the header label which is ok.

code/local/mage/sales/model/order/pdf/Items/Invoice/Default.php (commenting this fragment starting at line 106)

$lines[0][] = array(
            'text'  => $order->formatPriceTxt($item->getTaxAmount()),
            'feed'  => 495,
            'font'  => 'bold',
            'align' => 'right'
        );

will make tax field to be hidden for simple products, yet not for those from the simple products that are components of the bundle/configurable.

The problem is that neither of these files is responsible for the way the configurable and bundle are rendered in the PDF invoice.

enter image description here

What I could identify is that these kind of products are rendered using this function in

code/local/mage/sales/model/order/pdf/Abstract.php (line 760)

protected function _drawItem(Varien_Object $item, Zend_Pdf_Page $page, Mage_Sales_Model_Order $order)
    {
        $orderItem = $item->getOrderItem();
        $type = $orderItem->getProductType();
        $renderer = $this->_getRenderer($type);

        $this->renderItem($item, $page, $order, $renderer);

        $transportObject = new Varien_Object(array('renderer_type_list' => array()));

        Mage::dispatchEvent('pdf_item_draw_after', array(
            'transport_object' => $transportObject,
            'entity_item'      => $item
        ));

        foreach ($transportObject->getRendererTypeList() as $type) {
            $renderer = $this->_getRenderer($type);
            if ($renderer) {
                $this->renderItem($orderItem, $page, $order, $renderer);
            }
        }

        return $renderer->getPage();
    }

Yet I cannot find where the renderers for configurable are defined.

1
why don't you ask on the magento SO, you may have better chance to get an answer in there. (though that community is quite inactive)Edwin
@Edwin - because most are posting and being active here and all Mage related questions get faster results hereMike

1 Answers

0
votes

Copy files to

local/Mage/Bundle/Model/Sales/Order/Pdf/Items

from

core/Mage/Bundle/Model/Sales/Order/Pdf/Items

In Invoice.php comment lines 146&147

$tax = $order->formatPriceTxt($_item->getTaxAmount());
$line[] = array('text'  => $tax,'feed'  => 495,'font'  => 'bold',    'align' => 'right');