VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: LAMF on July 10, 2012, 22:55:11 PM

Title: Space in thousands separator for prices??
Post by: LAMF on July 10, 2012, 22:55:11 PM
Hi all!
I need help to set up the thousands separator for currencies (my currency is SEK).
I need a simple space as the separator to show the prices, like this:
10 000 SEK (10000 SEK).
How do I set up this in Virtue Mart?
I use the latest VM 2.0.8c.
I have tried to use the   but this gives a UTF-8 error so it display a incompatibility symbol intead of the space between the numbers.
Title: Re: Space in thousands separator for prices??
Post by: John2400 on July 11, 2012, 00:25:08 AM
LAMF,

Hi the currency setup is in the configuration>>currencies>>your country setup

but if you add the space then your calculations may end up wrong.  Here we once wrote 1,000,000 as standard   now it is 1000000 calculation issues.
Title: Re: Space in thousands separator for prices??
Post by: LAMF on July 11, 2012, 08:45:17 AM
John:
Ok I see so it wasn't that simple, I have asked the owner of the shop that I am setting up if a . (dot) would be ok as a separator but he claims that the Swedish standard is a space and he is right.... well well guess there's currently nothing to do about it then?
Title: Re: Space in thousands separator for prices??
Post by: John2400 on July 11, 2012, 09:25:44 AM
Hi I presumed that you have gone in and played with the currency settings -

and tried to put in the space - I'm sure others will have an answer for you .  also If you do pay by credit card or by paypal or others - they will have a setting too.

And If it is standard then they will send it in the invoice correctly?

[attachment cleanup by admin]
Title: Re: Space in thousands separator for prices??
Post by: LAMF on July 11, 2012, 10:25:07 AM
So far noone has been able to support this "easy-solved" problem...
Isn't the space a thing that should only be output visible not in the rendering/calcualtion of price process?
Could it be set up just to force the output view of the thousands as wished?
To me it feels simple but then I'm no developer so I couldn't tell...
Title: Re: Space in thousands separator for prices??
Post by: jenkinhill on July 11, 2012, 13:15:33 PM
A space will be stripped out/ignored, so a workaround would be to set, for example, a carat (^) as the thousands delimiter and use substr_replace() in the display templates to replace the carat with a space. I have not tested this as I always use the comma.

That would avoid having to hack the core code to enable a space.
Title: Re: Space in thousands separator for prices??
Post by: LAMF on July 11, 2012, 23:20:34 PM
kenkinhill:
Sorry I don't quite understand what you mean... Can you explain more in detail how I should set this up?
Title: Re: Space in thousands separator for prices??
Post by: PRO on July 11, 2012, 23:30:21 PM
Quote from: LAMF on July 11, 2012, 23:20:34 PM
kenkinhill:
Sorry I don't quite understand what you mean... Can you explain more in detail how I should set this up?

" str_replace"
http://www.w3schools.com/php/func_string_str_replace.asp


Category page
<?php $product->prices = str_replace( 'change-this', 'to-this',$product->prices ); ?>

for product page
$product->prices    is this
$this->product->prices
Title: Re: Space in thousands separator for prices??
Post by: LAMF on July 12, 2012, 14:10:58 PM
Quote from: BanquetTables.pro on July 11, 2012, 23:30:21 PM

" str_replace"
http://www.w3schools.com/php/func_string_str_replace.asp


Category page
<?php $product->prices = str_replace( 'change-this', 'to-this',$product->prices ); ?>

for product page
$product->prices    is this
$this->product->prices

So I should make a template override in the: com_virtuemart/views/category/tmpl/default.php
and add this line:
<?php $product->prices = str_replace( '', '^',$product->prices ); ?>

and then the: com_virtuemart/views/productdetails/tmpl/default.php
and add this
$product->prices    is this
$this->product->prices

Am I totally out of track or did I at least get something right?
Title: Re: Space in thousands separator for prices??
Post by: PRO on July 12, 2012, 15:20:47 PM
Quote from: LAMF on July 12, 2012, 14:10:58 PM
Quote from: BanquetTables.pro on July 11, 2012, 23:30:21 PM

" str_replace"
http://www.w3schools.com/php/func_string_str_replace.asp


Category page
<?php $product->prices = str_replace( 'change-this', 'to-this',$product->prices ); ?>

for product page
$product->prices    is this
$this->product->prices

So I should make a template override in the: com_virtuemart/views/category/tmpl/default.php
and add this line:
<?php $product->prices = str_replace( '', '^',$product->prices ); ?>

and then the: com_virtuemart/views/productdetails/tmpl/default.php
and add this
$product->prices    is this
$this->product->prices

Am I totally out of track or did I at least get something right?


I have tried and tried, and cannot get this code to work, I do now know how to fix this, sorry

Title: Re: Space in thousands separator for prices??
Post by: Vratislav Dlabaja on July 17, 2012, 22:22:07 PM
I have a solved it...

You must go to:
administrator\components\com_virtuemart\helpers\currencydisplay.php
line 341
There is this text:
$res = number_format

above this text you must insert this code:

$this->_thousands = str_replace('&', ' ', $this->_thousands);



Final work look this:

$this->_thousands = str_replace('&', ' ', $this->_thousands);
$res = number_format((float)$nb,(int)$nbDecimal,$this->_decimal,$this->_thousands);



After that you must go to administrator:
Virtuemart -> Configuration -> Currencies -> "Select Currency" -> Thousands Separator = &

After that, will be Thousands Separator   "space".
If you do not understand write me.
Title: Re: Space in thousands separator for prices??
Post by: LAMF on August 17, 2012, 12:05:20 PM
Quote from: Vratislav Dlabaja on July 17, 2012, 22:22:07 PM
After that, will be Thousands Separator   "space".
If you do not understand write me.

Super thanks!
You're the hero!
This was the solution!
Title: Re: Space in thousands separator for prices??
Post by: BELGOR on August 27, 2012, 12:57:01 PM
Better solution:

Edit structure of database table #__virtuemart_currencies
Set type of colum "currency_thousands" from char(4) to varchar(4)

Now is able to save simple text space to thousand separator in currencies settings
Title: Re: Space in thousands separator for prices??
Post by: LAMF on September 14, 2012, 09:42:17 AM
Belgor: This was indeed a better solution!

Thanks a lot fo an easy fix to the problem!
Title: Re: Space in thousands separator for prices?? [no hacks]
Post by: kok on October 22, 2013, 08:27:05 AM
VM2 - Configuration - Currencies - select yours - Currency [ Edit ] - Thousands Separator - enter (Alt+0160)

ps: Just be careful, as this approach may be a problem with the rounding of the numbers.