Jump to content

3 Decimal Places For Prices


Guest K.D.S

Recommended Posts

Hi, am very new to cubecart and seem to have a problem setting the number of decimal places for prices. The products i am going to sell have a very low value but cant seem to set the prices to accept 3 decimal places.

I have set the currency (GB Pounds) to 3 decimal places but the prices stick to two places, rounding up. e.g. if i set the price to 0.025 when i look at the product it has changed to 0.03.

Thanks for any help.

Kev.

Link to comment
Share on other sites

I haven't looked in the CC code, but the MySQL database has the product's price set at a certain format.

Use what ever means you have to access your store's MySQL database and look at the design of the table 'CubeCart_inventory'. The [price] column is formatted to hold Decimal(30,2). Change that to (30,3) and the default value to '0.000'.

Do the same to tables 'CubeCart_order_inv[price]' and 'CubeCart_order_sum[subtotal] and [prod_total]' if desired.

There *may* still be CC code that rounds to two decimal places, specifically during tax computations. But the bottom line computation, rounding to two decimal places may be what you actually want to end up with.

In /includes/functions.inc.php, there is a function, priceFormat(), that uses data from the CubeCart_currencies table, [decimalPlaces] field. You might want to add another record here (maybe it's in the admin panel where you can add a currency) for "microdollars", being a copy of US Dollars (or whatever), but with '3' as the value for decimalPlaces.

Link to comment
Share on other sites

  • 1 month later...
Guest megaline

Hi,

I have done for version 4 and it works. The only problem is that We should have the TOTAL just in 2 decimal as in reality the 0.001€ does not exist so we could not ask customers to pay that and the total should be rounded to only 2 decimals. Anyone has done that?

thank you

Ali

Link to comment
Share on other sites

Try searching through all your CC files looking for the string:

"VAL_GRAND_TOTAL",priceFormat($order[0]['prod_total'])

One place you can find it in CC3.0.15 is in:

/includes/content/viewOrder.inc.php around line 126.

Change (at least) this to:

"VAL_GRAND_TOTAL",round(priceFormat($order[0]['prod_total']),2)

This is, of course, until you add a "bottomLineDecimalPlaces" column to the currencies table and mod all the code to use it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...