Hello
In checkout_confirm, i have an order like this :
Name Ref Qty Unit Price Total Price with VAT
Object PM03 1 29.00€ 29.00€
Subtotal without VAT : 24.25€
Tax amount : 4.75€
Subtotal with VAT : 29.00€
Delivery amount with VAT : 9.00€
Delivery tax amount : 1.47€
Total to pay : 38.00€
The problem is that tax amount is calcultated twice. Calculate::getTotals() seems to be called twice whereas the only call point is in ControllerCheckoutConfirm::index() !
Same problem with coupon !
Some idea about this ?
Thanks
No problem with tax in fact.
But the promotion code was calculated twice :
once by my payment system to submit total amount (payment system class)
and
once by CheckoutConfirmClassController class
As object calculate is initialised by reference, i added as static variable in CalculateCoupon::calculate()
function calculate() {
static $i = 1; // ADD
$total_data = array();
if (($this->config->get('coupon_status')) && ($this->coupon->getId())) {
if ($this->coupon->getDiscount($this->cart->getTotal()) > 0) {
$total_data[] = array(
'title' => $this->language->get('text_coupon_title', $this->coupon->getName()),
'text' => '-' . $this->currency->format($this->coupon->getDiscount($this->cart->getTotal())),
'value' => $this->coupon->getDiscount($this->cart->getTotal())
);
if($i == 1) { // ADD
$this->cart->decreaseTotal($this->coupon->getDiscount($this->cart->getTotal()));
}
}
if (($this->coupon->getShipping()) && ($this->cart->hasShipping())) {
$total_data[] = array(
'title' => $this->language->get('text_coupon_shipping'),
'text' => '-' . $this->currency->format($this->tax->calculate($this->shipping->getCost($this->session->get('shipping_method')), $this->shipping->getTaxClassId($this->session->get('shipping_method')))),
'value' => $this->tax->calculate($this->shipping->getCost($this->session->get('shipping_method')), $this->shipping->getTaxClassId($this->session->get('shipping_method')))
);
if($i == 1) { // ADD
$this->cart->decreaseTotal($this->tax->calculate($this->shipping->getCost($this->session->get('shipping_method')), $this->shipping->getTaxClassId($this->session->get('shipping_method'))));
}
}
}
$i++; // ADD
return $total_data;
}
But the promotion code was calculated twice :
once by my payment system to submit total amount (payment system class)
and
once by CheckoutConfirmClassController class
As object calculate is initialised by reference, i added as static variable in CalculateCoupon::calculate()
function calculate() {
static $i = 1; // ADD
$total_data = array();
if (($this->config->get('coupon_status')) && ($this->coupon->getId())) {
if ($this->coupon->getDiscount($this->cart->getTotal()) > 0) {
$total_data[] = array(
'title' => $this->language->get('text_coupon_title', $this->coupon->getName()),
'text' => '-' . $this->currency->format($this->coupon->getDiscount($this->cart->getTotal())),
'value' => $this->coupon->getDiscount($this->cart->getTotal())
);
if($i == 1) { // ADD
$this->cart->decreaseTotal($this->coupon->getDiscount($this->cart->getTotal()));
}
}
if (($this->coupon->getShipping()) && ($this->cart->hasShipping())) {
$total_data[] = array(
'title' => $this->language->get('text_coupon_shipping'),
'text' => '-' . $this->currency->format($this->tax->calculate($this->shipping->getCost($this->session->get('shipping_method')), $this->shipping->getTaxClassId($this->session->get('shipping_method')))),
'value' => $this->tax->calculate($this->shipping->getCost($this->session->get('shipping_method')), $this->shipping->getTaxClassId($this->session->get('shipping_method')))
);
if($i == 1) { // ADD
$this->cart->decreaseTotal($this->tax->calculate($this->shipping->getCost($this->session->get('shipping_method')), $this->shipping->getTaxClassId($this->session->get('shipping_method'))));
}
}
}
$i++; // ADD
return $total_data;
}
Who is online
Users browsing this forum: No registered users and 2 guests