将优惠券代码的值带入magento的“tax”calculation.php

时间:2011-01-12 11:06:00

标签: magento

我试图将当前应用于购物车的折扣代码的名称输入到calculation.php文件中。折扣代码的名称是optionalTax但我无法直接传递或直接检索它。它似乎在mage / sales / model / quote.php中引用为$quote->getCouponCode(),我想在其中使用它 法师/税/模型/ calculation.php

任何人都知道如何调用它,因为我已尝试按照模型使用模型(我认为这是正确的)

public function calcTaxAmount($price, $taxRate, $priceIncludeTax=false, $round=true)
    {
        $taxRate = $taxRate/100;

        if ($priceIncludeTax) {
            $amount = $price*(1-1/(1+$taxRate));
        } else {
   $cModel = Mage::getModel('catalog/sales');
   $thisDiscountCode = $cModel->$quote->getCouponCode();
   die($thisDiscountCode);
   $amount = $price*$taxRate; 
        }

        if ($round) {
            return $this->round($amount);
        } else {
            return $amount;
        }
    }

克里斯

1 个答案:

答案 0 :(得分:1)

你需要从正确的模型中得到报价:

Mage::getSingleton('checkout/session')->getQuote();