【问题标题】:Magento 1.9 remove tax on checkout when user enter VATMagento 1.9 在用户输入增值税时取消结帐税
【发布时间】:2017-01-14 03:08:57
【问题描述】:

当用户在结帐时输入增值税号时,我正在尝试进行 magento 修改,从订单中删除税款。

我在 stackoverflow 上找到了一个代码,它支持 magento 旧版本,但它不适用于新版本 1.9

我对工作条件做了一些修改并返回 0,即使它返回 0 结帐仍然显示税款。

这是我存档的代码

/app/code/core/Mage/Tax/Model/Calculation.php line number 268



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


           //my code
            $ctax= Mage::getSingleton('checkout/session')->getQuote()->getCustomerTaxvat();


            if ($this->getCustomer() && $ctax !='') {
                //echo 'test';
                return 0;          
            }
        //end my code   


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

当用户在结帐时输入增值税号时,任何人都可以帮助我将税款设为 0,非常感谢

【问题讨论】:

    标签: php magento magento-1.9


    【解决方案1】:

    我已经通过关注这个帖子解决了我的问题:Modify tax rate on cart quote items and recalculate

    我已将观察者添加到事件sales_quote_collect_totals_before

    这是我观察者的内容,很简单:

        public function removetax($observer)
        {
            $customer_id = Mage::getSingleton('customer/session')->getId();
            $customer = Mage::getModel("customer/customer")->load($customer_id);
    
            if($customer->getIsTaxExempt() == 1)
            {
                $items = $observer->getEvent()->getQuote()->getAllVisibleItems();
                foreach($items as $item)
                    $item->getProduct()->setTaxClassId(0);
            }
        }
    

    如果客户是免税的,我会获取当前购物车的内容,并且对于每件商品,我将产品税级设置为 0。不保存产品或商品是强制性的。此处的目的是为以下计算设置一个值,而不是将其保存在数据库中。税类需要保持在数据库中的初始值。

    【讨论】:

    • 它需要节省magento mate,无论如何我们购买了一个解决问题的扩展程序,谢谢您的回答
    【解决方案2】:

    您可以使用sales_quote_collect_totals_before 事件。

    那么您必须在结帐页面上定义删除tax 的逻辑。

    这个link你可以参考。

    【讨论】:

    • 这似乎不起作用,我只需要通过编辑 /app/code/core/Mage/Tax/Model/Calculation.php 文件代码来获得干净的解决方案
    【解决方案3】:

    转到 Calculation.php 并找到 calcTaxAmount() 并添加计费条件

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

    【讨论】:

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