1

我希望能够检查我在用户会话中设置的变量,并在此基础上使用户购物车免税。我怎样才能做到这一点?

我认为搞乱客户类型太复杂了。是否有另一种方法来改变适用的税收?或离开以即时更改客户群。

4

1 回答 1

3

我做了一些与此非常相似的事情,我将 app/code/core/Mage/Tax/Model/Calculation.php 覆盖为 app/code/local/Mage/Tax/Model/Calculation.php 并添加了显示的语句在评论下方,根据会话值将税率设置为 0。这是在结帐时即时计算的。

public function getRate($request)
{
    if (!$request->getCountryId() || !$request->getCustomerClassId() || !$request->getProductClassId()) {
        return 0;
    }

    $cacheKey = "{$request->getProductClassId()}|{$request->getCustomerClassId()}|{$request->getCountryId()}|{$request->getRegionId()}|{$request->getPostcode()}";
    if (!isset($this->_rateCache[$cacheKey])) {
        $this->unsRateValue();
        $this->unsCalculationProcess();
        $this->unsEventModuleId();
        Mage::dispatchEvent('tax_rate_data_fetch', array('request'=>$this));
        if (!$this->hasRateValue()) {
            $this->setCalculationProcess($this->_getResource()->getCalculationProcess($request));
            $this->setRateValue($this->_getResource()->getRate($request));
        } else {
            $this->setCalculationProcess($this->_formCalculationProcess());
        }
        $this->_rateCache[$cacheKey] = $this->getRateValue();
        $this->_rateCalculationProcess[$cacheKey] = $this->getCalculationProcess();
    }
//this is the bit you're looking for down here
    if (Mage::getStoreConfig('tax/calculation/calc_rate_zero')) {
        $_taxvat = Mage::getSingleton('checkout/session')->getQuote()->getCustomerTaxvat();
        if ( $_taxvat != null && $_taxvat != ' ') {
            $this->setRateValue( 0 );
            $this->_rateCache[$cacheKey] = $this->getrateValue();
            $this->_rateCalculationProcess[$cacheKey]= $this->getCalculationProcess();
        }
    }

    return $this->_rateCache[$cacheKey];
}
于 2012-07-12T18:36:31.153 回答