News:

Looking for documentation? Take a look on our wiki

Main Menu

rounding prices in virtumeart

Started by kiasati, August 25, 2018, 10:08:13 AM

Previous topic - Next topic

kiasati

Hi.

my shop currency is RIAL.
prices don't have decimals and are like this:
19231
215543
1002544

I want to round 2 last digits and have them like this:
19231 --> 19200
215543 --> 215600
1002544 --> 1002600

how can I do this?


Jörgen

#1
Are there any calculations done on the orices VAT, tax etc ?

If not then just simply write in the rounded prices in the product data.

If that does not I guess You can do someting like this in subayout prices.php:

$product->prices['basePriceWithTax'] = round($product->prices['basePriceWithTax'] / 100) *100;


This rounds off the two last digits for the basePriceWithTax.

Continue with all the other prices, there may be a better way, but this can be done in the template.

Jörgen @ Kreativ Fotografi

Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Studio 42

Have you try to change the decimal separator in RIAL currency ?
YOu can try using a space for eg.

kiasati

Quote from: Jörgen on August 25, 2018, 11:03:14 AM
Are there any calculations done on the orices VAT, tax etc ?

If not then just simply write in the rounded prices in the product data.
the base price that I input is rounded.
Then a rule with -5% off generates the final price. I want this final price to be rounded too.

kiasati

Quote from: Studio 42 on August 25, 2018, 18:17:20 PM
Have you try to change the decimal separator in RIAL currency ?
You can try using a space for eg.

in RIAL currency there are no decimals.
for example, there is no price like "1525.45" it's like "1525"
so I turned off decimals.

I want this 1525 to be rounded and be like 1500.

what is the best way to do so?
Is it doable in VM backend?

Studio 42

If you need to round, then you can use decimals and fake the display, it's why i said you to remove the separator and round to 2 decimals.
Or another solution is to round to 0 decimal and add 00 to the currency ?
You should play with your currency in the back-end to find the best for you

Milbo

Indeed an interesting question. The need operation is, divide by 1000, round and multiply by 1000 (or 100 respectivly)
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/