VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: D_L_I on August 31, 2014, 10:56:48 AM

Title: price number format
Post by: D_L_I on August 31, 2014, 10:56:48 AM
Hey guys,
looking for a way to get the prices to be rounded to 1 digit after decimal point, but display 2.
meaning the price 10.72 should be displayed as 10.70.
If I am sending rounding digits to 1 it displays only 10.7, and I need the last 0 to be displayed as well.

Thanks!!
Title: Re: price number format
Post by: jjk on August 31, 2014, 16:38:12 PM
I didn't test this myself, but basically two options to play with come into my mind:
1. Different combinations of 'Currencies' >your currency > Decimals / Configuration > Pricing tab> Rounding Digits.
2. Enable "Use for swizz CHF the Rappenrundung" in Configuration > Pricing tab and create a template override file of ...\administrator\components\com_virtuemart\helpers\currencydisplay.php, in which you change the 'numeric_code' to the one of your currency and the 0.5 in the next line to 1.0.
if($this->_numeric_code===756 and VmConfig::get('rappenrundung',FALSE)=="1"){
$price = round((float)$price * 2,1) * 0.5;
Title: Re: price number format
Post by: Milbo on August 31, 2014, 19:30:01 PM
or you format your currency,. use rounding 1 and just add a 0
Title: Re: price number format
Post by: D_L_I on September 01, 2014, 07:36:13 AM
thanks Milbo and jjk...
did not know about formatting the currency  :)
Title: Re: price number format
Post by: loppan on January 19, 2016, 17:54:49 PM
Quote from: Milbo on August 31, 2014, 19:30:01 PM
or you format your currency,. use rounding 1 and just add a 0
Thanks Milbo, that's a great tip, but I'm having one issue, and I'm wondering if I'm doing something wrong.

My base currency is SEK but I want EUR to show for example 18.10 € instead of 18.13 €.

In Configuration / Pricing I use rounding 1 on all displayed prices. This makes all prices show 18.1 € instead of 18.13 €.

I then add a "0" in Configuration / Currencies : Positive format : {number}0 {symbol}. Now the product price show as 18.10 €. Great!

But my cart module still shows the price with the default rounding, an on top of this it adds the 0, please see the attached screenshot :

How can I make the cart display also show 18.10 instead of 18.130?

Checkout looks fine, it's just the cart module that's giving me problems. Is this a bug?

Best

Peter