【问题标题】:Magento add coupon code to discount on invoiceMagento 将优惠券代码添加到发票折扣中
【发布时间】:2014-04-01 08:52:47
【问题描述】:

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

折扣(hau723):-50

现在是这个。

折扣:-50

我有密码

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

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

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

希望有人能帮助我,我用谷歌搜索但找不到答案。

谢谢!

【问题讨论】:

    标签: magento magento-1.7


    【解决方案1】:

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

    来自

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

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

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

    【讨论】:

    • 它有效,谢谢!但是“但是在它工作之后你必须覆盖这个文件”是什么意思?
    • 很高兴为您提供帮助....实际上这是核心文件,因此如果新的 magento 升级它将被替换,因此将此文件放在本地目录中或首先在 google 中搜索如何覆盖 magento 中的模型.
    • 谢谢!不知道。
    • 只要在 google 中搜索如何在 magento 中覆盖模型,就会有很多关于它的文章
    • 我认为这对你有帮助 inchoo.net/ecommerce/magento/…
    猜你喜欢
    • 2012-12-27
    • 1970-01-01
    • 2014-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-09
    相关资源
    最近更新 更多