Magento在发票上添加优惠券代码以打折

时间:2014-04-01 08:52:48

标签: magento magento-1.7

我有一个问题。我想在发票上显示优惠券代码。

折扣(hau723): - 50

现在就是这样。

折扣:-50

我有一个代码

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

它显示正确的代码,但没有折扣。看起来像这样

折扣:-50 价格:0 代码:hau723

我希望有人可以帮助我,我用Google搜索但无法找到答案。

谢谢!

1 个答案:

答案 0 :(得分:1)

你可以通过这种方式实现但是在它工作之后你必须覆盖这个文件

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);
}

如果您有任何疑问,请告诉我

相关问题