Domanda

Nel mio negozio, CE 1.9.2.2, vorrei arrotondare i prezzi dopo l'applicazione fiscale. Esempio: Ho un prodotto con un prezzo 160.50 senza tasse applicate.Per alcuni clienti il negozio applica una regola fiscale che aumenta il prezzo del suo 22%.Quindi, dopo il calcolo delle tasse, il prezzo per quel particolare prodotto diventa 195.81.Per quei clienti vorrei avere il prodotto con il prezzo 196.00 mentre lasciamo 160.50 per i clienti che non hanno il calcolo delle imposte applicato.

È possibile ottenere questo in qualche modo in Magento?

È stato utile?

Soluzione

Sono riuscito a farlo.Questo è il modo in cui l'ho raggiunto.

Ho dovuto estendere la classe Mage_Tax_Model_Calculation e riscrivere la logica nel metodo calcTaxAmount.

public function calcTaxAmount($price, $taxRate, $priceIncludeTax = false, $round = true)
{
    $taxRate = $taxRate / 100;

    if ($priceIncludeTax) {
        $amount = $price * (1 - 1 / (1 + $taxRate));
    } else {
        $amount = $price * $taxRate;
    }

    $taxedPrice = $price + $amount;
    $amount += round($taxedPrice) - $taxedPrice;

    if ($round) {
        return $this->round($amount);
    }

    return $amount;
}
.

Ho appena aggiunto le due linee:

$taxedPrice = $price + $amount;
$amount += round($taxedPrice) - $taxedPrice;
.

Per sommare l'importo fiscale la differenza tra il prezzo tassato e il prezzo tassato arrotondato.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top