Zen Cart Logo
Forums / General Questions / Quantity Discount Price rounding

Quantity Discount Price rounding

Views: 1,077

Results 1 to 8 of 8
23 Jun 2011, 7:06 PM
#1
mmwilcox avatar

mmwilcox

New Zenner

Join Date:
Nov 2007
Location:
Huntington, Indiana
Posts:
67
Plugin Contributions:
0

Quantity Discount Price rounding

Is there a way to get the discounted price to use just 2 decimals? Our default currency is set to 2, but the total price of an order indicates that the quantity discount price being used is based on 3+ decimal points.

For instance, an item has a list price of $5.30 with a 16% discount if the customer buys 16. The discount should be $4.45 and the total should be 71.20. Instead, 71.23 is the total that shows as ZenCart is actually using $4.452 as the discount price.

At the price attributes/ quantity discount edit page, it will show the correct discount price and even show $71.20 in the example.

Thanks in advance.

23 Jun 2011, 11:11 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Quantity Discount Price rounding

You could use Actual Price to prevent this from happening ...

24 Jun 2011, 1:21 AM
#3
mmwilcox avatar

mmwilcox

New Zenner

Join Date:
Nov 2007
Location:
Huntington, Indiana
Posts:
67
Plugin Contributions:
0

Re: Quantity Discount Price rounding

Thank you!

By 'actual price', I presume you mean the discount type.

If there is no assistance offered in this thread on where we can add 'round(...' to a discount function somewhere, that may be the best solution. Tough solution to change a couple thousand items, each of which has multiple price breaks.

The Percentage method is more easily maintained as it auto-updates when the list price changes.

24 Jun 2011, 2:36 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Quantity Discount Price rounding

You would have to test what would happen if you alter the functions_prices.php and the function zen_get_products_discount_price_qty in both the Catalog and the Admin and see if that changes the results of what you are experiencing ...

24 Jun 2011, 6:45 PM
#5
mmwilcox avatar

mmwilcox

New Zenner

Join Date:
Nov 2007
Location:
Huntington, Indiana
Posts:
67
Plugin Contributions:
0

Re: Quantity Discount Price rounding

Thanks Linda for the location of the function.

I changed lines 1258, 1262, 1268 and 1270 (catalog side only) by adding the round(...,2) functionality. For instance, line 1262 was changed from:

$discounted_price = $display_price - ($display_price * ($products_discounts_query->fields['discount_price']/100));

to

$discounted_price = $display_price - round($display_price * ($products_discounts_query->fields['discount_price']/100),2);

The variables differ amonst these 4 line numbers, so don't copy the above code to the four lines. Manually add the function to each line.

Working perfectly so far, but still need to thoroughly test. If issues arise, I'll add to this thread.

24 Jun 2011, 6:56 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Quantity Discount Price rounding

Make sure you do both functions_prices.php files for the Catalog and Admin ... and let us know if all is right in the world ... :smile:

24 Jun 2011, 7:19 PM
#7
mmwilcox avatar

mmwilcox

New Zenner

Join Date:
Nov 2007
Location:
Huntington, Indiana
Posts:
67
Plugin Contributions:
0

Re: Quantity Discount Price rounding

Thanks Linda.

Okay, i did the admin side too. Same coding changes. All is well so far.

A real programmer :blush: would have used the currencies/ decimal places field instead of hardcoding a digit '2' as i did. Which of these, if any, would be the proper coding for that?

  1. $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']
  2. $currencies->get_decimal_places($my_currency)
  3. $currencies->currencies[$_SESSION['currency']]['decimal_places']

Thank you.

24 Jun 2011, 9:35 PM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Quantity Discount Price rounding

This would be most accurate:

$currencies->currencies[$_SESSION['currency']]['decimal_places']

But again, always test things completely ...