将优惠券代码的价值计入“税”中magento 中的calculation.php

发布于 2024-10-11 18:17:49 字数 799 浏览 2 评论 0原文

我试图将当前应用于购物车的折扣代码的名称拉入calculation.php 文件中。折扣代码的名称是可选的税,但我无法传递它或直接检索它。它似乎在 mage/sales/model/quote.php 中被引用为 $quote->getCouponCode() ,我想在 mage/tax/model/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;
        }
    }

克里斯使用模型(我认为这是正确的)

Im trying to pull in the name of the discount code currently applied to the cart into the calculation.php file. The name of the discount code is optionalTax but Im having trouble passing it through or retrieving it directly. Its appears to be referenced as $quote->getCouponCode() in mage/sales/model/quote.php and I want to use it in
mage/tax/model/calculation.php

Anyone have any idea on how to call it in as I've tried using the model as per (which I think is correct)

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

Chris

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2024-10-18 18:17:49

我猜你需要从正确的模型中获取报价:

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

you need to get the quote from right model i guess:

Mage::getSingleton('checkout/session')->getQuote();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文