getQuote не работает в некоторых магазинах

Мне нужно ограничить сумму налога. поэтому я пошел 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;
}

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

Другие решения

Я был исправлен ниже потока: —

Вместо использования GetQuote в Calculation.php с помощью переменной сеанса

Mage / Checkout / Модель / тип / Onepage.php

Название функции: — публичная функция saveBilling ($ data, $ customerAddressId)

        $assign = $this->getQuote()->getCustomerTaxvat();
if ($assign !="")
{
$this->_checkoutSession->setVatSession($assign);
}
else
{
$this->_checkoutSession->unsVatSession();
}

Добавить код выше в onepage.php перед return array(); что означает последний из функции.

Теперь ниже получить доступ к переменной сеанса

Mage / Налоги / модель / 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;
}
0

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector