0

How to check what is the $source (Invoice or Credit memo) in function insertTotals on pdf Invoices/Creditmemo/Shipment.

protected function insertTotals($page, $source){

    $order = $source->getOrder();
    $totals = $this->_getTotalsList($source);
    $lineBlock = array(
        'lines'  => array(),
        'height' => 15
    );
    foreach ($totals as $total) {
        $total->setOrder($order)
            ->setSource($source);

        if ($total->canDisplay()) {
            $total->setFontSize(10);
            foreach ($total->getTotalsForDisplay() as $totalData) {

                $lineBlock['lines'][] = array(
                    array(
                        'text'      => $totalData['label'],
                        'feed'      => 475,
                        'align'     => 'right',
                        'font_size' => $totalData['font_size'],
                        'font'      => 'bold'
                    ),
                    array(
                        'text'      => $totalData['amount'],
                        'feed'      => 565,
                        'align'     => 'right',
                        'font_size' => $totalData['font_size'],
                        'font'      => 'bold'
                    ),
                );


            }

        }


    }

    $this->y -= 10;
    $page = $this->drawLineBlocks($page, array($lineBlock));
    return $page;



}

This is how it's called function in Creditmemo.php:

$this->insertTotals($page, $creditmemo);

And from Invoice.php:

$this->insertTotals($page, $invoice);
1
    if ($source instanceof Mage_Sales_Model_Order_Creditmemo) {
        //Creditmemo stuff here
    }
  • works like a charm.. :) Thank you very much! – srdan Jul 1 '13 at 7:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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