1

我需要限制税额。所以我去了Mage/Tax/Model/Calculation.php 然后找到calcTaxAmount()税收申请功能。 我需要限制所有在结帐时输入税金的税单页税应该为零 ,所以

public function calcTaxAmount($price, $taxRate, $priceIncludeTax = false, $round = true)
    {
        $billing = Mage::getModel('checkout/session')->getQuote()->getCustomerTaxvat();

        if($billing != "" )
        {
            return 0;
        }
        $taxRate = $taxRate / 100;

        if ($priceIncludeTax) {
            $amount = $price * (1 - 1 / (1 + $taxRate));
        } else {
            $amount = $price * $taxRate;
        }

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

        return $amount;
    }

我添加了新条件。它在多家连锁店工作。只有一家商店无法正常工作。它导致用户无法注册,并且 addtocart 不适用于该特定商店。我发现getQuote这个问题。我删除了如下所示的新条件,工作正常。

旧功能:-

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

        if ($priceIncludeTax) {
            $amount = $price * (1 - 1 / (1 + $taxRate));
        } else {
            $amount = $price * $taxRate;
        }

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

        return $amount;
    }
4

2 回答 2

1

试试下面的代码希望这会有所帮助。

public function calcTaxAmount($price, $taxRate, $priceIncludeTax = false, $round = true)
    {
         $currenQuoteId = Mage::getSingleton('checkout/session')->getQuoteId();
  $store = Mage::getSingleton('core/store')->load(Mage::app()->getStore()->getId());
            $quote = Mage::getModel('sales/quote')->setStore($store)->load($currenQuoteId); 
        $billing = $quote->getCustomerTaxvat();

        if($billing != "" )
        {
            return 0;
        }
        $taxRate = $taxRate / 100;

        if ($priceIncludeTax) {
            $amount = $price * (1 - 1 / (1 + $taxRate));
        } else {
            $amount = $price * $taxRate;
        }

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

        return $amount;
    }
于 2017-02-17T05:36:41.280 回答
0

我被固定在以下流程中:-

而不是在 Calculation.php 中使用 GetQuote 使用会话变量

Mage/Checkout/Model/Type/Onepage.php

函数名称:-公共函数 saveBilling($data, $customerAddressId)

        $assign = $this->getQuote()->getCustomerTaxvat();
        if ($assign !="")
        {
            $this->_checkoutSession->setVatSession($assign);
        }
        else
        {
            $this->_checkoutSession->unsVatSession();
        }

在 onepage.php 之前添加上述代码,return array();这意味着函数的最后一个。

现在在下面获取访问会话变量

法师/税收/模型/Calculation.php

public function calcTaxAmount($price, $taxRate, $priceIncludeTax = false, $round = true)
    {
        $sessionaccess = Mage::getModel('checkout/session')->getVatSession();
        if($sessionaccess != "")
        {
            return 0;
        }
        $taxRate = $taxRate / 100;

        if ($priceIncludeTax) {
            $amount = $price * (1 - 1 / (1 + $taxRate));
        } else {
            $amount = $price * $taxRate;
        }

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

        return $amount;
    }
于 2017-02-17T12:41:06.617 回答