Totally Zenned
- Join Date:
- Oct 2008
- Location:
- Croatia
- Posts:
- 1,819
- Plugin Contributions:
- 24
Post #1 by balihr
I have a problem with rounding and have come up with a solution, but would like to hear thoughts about it, and if it could cause any issues down the road.
Here's the story: we enter product prices in net and prices are displayed with tax (GST = 10%).
I put 3 products to cart:
item 1 (on sale 10%, regular price $107.25) = $96.53 (qty 1) = $96.53
item 2 (on sale 10%, regular price $62.76) = $56.48 (qty 3) = $169.44
item 3 (on sale 10%, regular price $62.76) = $56.48 (qty 1) = $56.48
At checkout, my subtotal shows as $322.47 which is obviously incorrect ($322.45 is expected).
So, includes/classes/order.php at line 537 calculates the totals, but this doesn't match the $_SESSION['cart']->show_total() for some reason. I'm guessing the sale has something to do with it, but I'm not sure.
My question - why is the subtotal re-calculated in the order class, why not use $_SESSION['cart']->show_total() ? What's the difference and what can go wrong if I replace the line from
$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
$this->info['subtotal'] = $currencies->value($_SESSION['cart']->show_total());
My site - Pro ZC Help
My portfolio | My plugins