Php getQuote在某些商店不起作用

Php getQuote在某些商店不起作用,php,magento-1.9,checkout,tax,Php,Magento 1.9,Checkout,Tax,我需要限制税额。所以我去了Mage/Tax/Model/Calculation.php 然后查找calcTaxAmount()税务申请函数我需要限制所有在结帐时输入税务vatid的税务人员,一页税务应为零 所以 我增加了新的条件。它在一些多层商店里工作。只有一家商店不能正常工作。这会导致用户无法注册,并且addtocart无法为该特定存储工作。我发现了这个问题。我移除了如下的新条件,工作正常 旧功能:- public function calcTaxAmount($price, $taxRate

我需要限制税额。所以我去了
Mage/Tax/Model/Calculation.php
然后查找
calcTaxAmount()
税务申请函数我需要限制所有在结帐时输入税务vatid的税务人员,一页税务应为零 所以

我增加了新的条件。它在一些多层商店里工作。只有一家商店不能正常工作。这会导致用户无法注册,并且addtocart无法为该特定存储工作。我发现了这个问题。我移除了如下的新条件,工作正常

旧功能:-

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

尝试下面的代码,希望这有帮助

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

我被固定在下面:-

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

Mage/Checkout/Model/Type/Onepage.php

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

在返回数组()之前的onepage.php中添加上述代码表示函数的最后一个

现在在下面访问会话变量

Mage/Tax/Model/Calculation.php


谢谢@user247217。我被修好了。我把答案加上。
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;
    }
        $assign = $this->getQuote()->getCustomerTaxvat();
        if ($assign !="")
        {
            $this->_checkoutSession->setVatSession($assign);
        }
        else
        {
            $this->_checkoutSession->unsVatSession();
        }
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;
    }