Originally Posted by
mc12345678
I do believe (right or wrong) that part of the intention (though I was not involved in any original development) was to provide two "independent" means to arrive at a final display so that there could always be a sort of check or balance about the data.
I thought the same, but there's absolutely no check anywhere. IMHO, this would make sense if there was something like
Code:
$subtotal += $shown_price;
if($subtotal == $currencies->value($_SESSION['cart']->show_total())) {
$this->info['subtotal'] = $subtotal;
} else {
}
and then have something in the else{}part to re-calculate and see what went wrong...
Thing is - at the moment I'm even getting different values on the shopping cart page. With the specific case as described above, item prices are calculated differently on cart page and at checkout.
Item 2 is $56.48 on cart page, but comes up as $56.49 on checkout. Times 3, makes is $169.47. And Item 3 also comes up as $56.49, but subtotal comes up as $322.47...
So, cart page:
item 1: $96.53
item 2: $169.44
item 3: $56.48
-----------
subtotal: $322.45
I go to checkout and the numbers change to:
item 1: $96.53
item 2: $169.47
item 3: $56.49
-----------
subtotal: $322.47
And the new subtotal is incorrect, just do the math - 2 cents are lost. So, not only it calculates wrong, but it also changes values between pages... Total nightmare...
I have changed the order.php class again to get the totals on checkout corrected, and it works on my specific case, although I'm not sure if it's a universal solution. I went from:
Code:
$shown_price = (zen_add_tax($this->products[$index]['final_price'] * $this->products[$index]['qty'], $this->products[$index]['tax']))
+ zen_add_tax($this->products[$index]['onetime_charges'], $this->products[$index]['tax']);
$this->info['subtotal'] += $shown_price;
to:
Code:
$shown_price = (zen_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']))
+ zen_add_tax($this->products[$index]['onetime_charges'], $this->products[$index]['tax']);
$this->info['subtotal'] += $currencies->value($shown_price)* $this->products[$index]['qty'];
Basically, I don't multiply qty and net price, then add tax, but instead I add tax to each item first, then do the rounding and then multiply with qty. This way I actually DO get the correct subtotal ($322.49) and this works, but I'm still trying to see how to change the shopping_cart.php class to work the same way because we're still getting $322.45 on cart page (and it's not really friendly to add 4 cents out of the blue...).
Bookmarks