【问题标题】:Magento disable tax when customer enter vat number on checkout当客户在结帐时输入增值税号时,Magento 禁用税收
【发布时间】:2013-09-16 09:19:40
【问题描述】:

我有 magento 1.7 网站,如果客户在结帐页面上输入税号,我很乐意从客户那里取消该税。

我有两个国家荷兰和比利时的税收规则都有 10% 的税。默认国家是比利时

当比利时客户在结帐页面输入增值税号时,我需要取消加税。

我厌倦了使用税收规则,但没有运气。

任何人都知道如何使用 magento 后端或使用代码级别来做到这一点。我赞赏任何答案。 谢谢

【问题讨论】:

    标签: php magento magento-1.7


    【解决方案1】:

    Override Magento 的 Tax Model 的 getRate() 函数是我们做类似事情的方式。

    class My_Module_Model_Tax_Calculation extends Mage_Tax_Model_Calculation
    {
    
        public function getRate($request)
        {
            if (!$request->getCountryId() || !$request->getCustomerClassId() || !$request->getProductClassId()) {
                return 0;
            }
    
            $country_id = $request->getCountryId();
    
            if ($country_id == 'BE' && $this->getCustomer() && $this->getCustomer()->getTaxvat()) {
                return 0;          
            }
    
            $cacheKey = $this->_getRequestCacheKey($request);
            if (!isset($this->_rateCache[$cacheKey])) {
                $this->unsRateValue();
                $this->unsCalculationProcess();
                $this->unsEventModuleId();
                Mage::dispatchEvent('tax_rate_data_fetch', array('request'=>$request));
                if (!$this->hasRateValue()) {
                    $rateInfo = $this->_getResource()->getRateInfo($request);
                    $this->setCalculationProcess($rateInfo['process']);
                    $this->setRateValue($rateInfo['value']);
                } else {
                    $this->setCalculationProcess($this->_formCalculationProcess());
                }
                $this->_rateCache[$cacheKey] = $this->getRateValue();
                $this->_rateCalculationProcess[$cacheKey] = $this->getCalculationProcess();
            }
            return $this->_rateCache[$cacheKey];
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-04
      • 1970-01-01
      • 1970-01-01
      • 2017-12-04
      • 1970-01-01
      • 2021-01-01
      • 1970-01-01
      相关资源
      最近更新 更多