getQuote 不适用于某些商店

问题描述 投票:0回答:2

我需要限制税额。所以我去了

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;
    }
php magento-1.9 checkout
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;
    }

0
投票

我被固定在以下流程:-

使用会话变量代替在 Calculation.php 中使用 GetQuote

法师/结账/模型/类型/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;
    }
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.