i have a question. I want to show the coupon code on the invoice like this.

Discount (hau723) : -50

Now it is this.

Discount : -50

I have a code

if($order->getGiftcertCode()!=""){
    $this->y -= 0;
    $page->drawText('Code: '.$order->getGiftcertCode(), 400, $this->y, 'UTF-8');
}

It shows the right code but not with the discount. It looks like this

Discount : -50 Price : 0 Code : hau723

I hope someone can help me, I googled but couldn't find the answer.

Thanks!

有帮助吗?

解决方案

You can achieve this way but after it works you have to override this file

From

app\code\core\Mage\Sales\Model\Order\Pdf\Total\Default.php

in

getTotalsForDisplay() Method


public function getTotalsForDisplay()
{
    $amount = $this->getOrder()->formatPriceTxt($this->getAmount());
    if ($this->getAmountPrefix()) {
        $amount = $this->getAmountPrefix().$amount;
    }      
    if($this->getTitle()=="Discount") // **custom code start**
    {
      $label = Mage::helper('sales')->__($this->getTitle()) . '('.$this->getOrder()->getData('coupon_code').')'.  ':';  
    }
    else
    {
       $label = Mage::helper('sales')->__($this->getTitle()) . ':';  
    }                                        
//       custom code End

$fontSize = $this->getFontSize() ? $this->getFontSize() : 7;
$total = array(
    'amount'    => $amount,
    'label'     => $label,
    'font_size' => $fontSize
);
return array($total);
}

Let me know if you have any query

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top