News:

Looking for documentation? Take a look on our wiki

Main Menu

Space in thousands separator for prices??

Started by LAMF, July 10, 2012, 22:55:11 PM

Previous topic - Next topic

LAMF

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.
BR
LAMF - R.I.P. Johnny Thunders

John2400

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.

LAMF

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?
BR
LAMF - R.I.P. Johnny Thunders

John2400

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]

LAMF

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...
BR
LAMF - R.I.P. Johnny Thunders

jenkinhill

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.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

LAMF

kenkinhill:
Sorry I don't quite understand what you mean... Can you explain more in detail how I should set this up?
BR
LAMF - R.I.P. Johnny Thunders

PRO

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

LAMF

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?
BR
LAMF - R.I.P. Johnny Thunders

PRO

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


Vratislav Dlabaja

#10
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.

LAMF

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!
BR
LAMF - R.I.P. Johnny Thunders

BELGOR

#12
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

LAMF

Belgor: This was indeed a better solution!

Thanks a lot fo an easy fix to the problem!
BR
LAMF - R.I.P. Johnny Thunders

kok

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.
Joomla! 2.5.27
VirtueMart 2.6.10