VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: kiasati on August 25, 2018, 10:08:13 AM

Title: rounding prices in virtumeart
Post by: kiasati on August 25, 2018, 10:08:13 AM
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?

Title: Re: rounding prices in virtumeart
Post by: 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.

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

Title: Re: rounding prices in virtumeart
Post by: 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.
Title: Re: rounding prices in virtumeart
Post by: kiasati on August 26, 2018, 07:00:58 AM
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.
Title: Re: rounding prices in virtumeart
Post by: kiasati on August 26, 2018, 07:05:30 AM
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?
Title: Re: rounding prices in virtumeart
Post by: Studio 42 on August 26, 2018, 13:04:57 PM
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
Title: Re: rounding prices in virtumeart
Post by: Milbo on August 26, 2018, 16:32:05 PM
Indeed an interesting question. The need operation is, divide by 1000, round and multiply by 1000 (or 100 respectivly)