Author Topic: Space in thousands separator for prices??  (Read 11915 times)

LAMF

  • Beginner
  • *
  • Posts: 33
Space in thousands separator for prices??
« 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.
BR
LAMF - R.I.P. Johnny Thunders

John2400

  • Virtuemart - the Future is ever Changing
  • Global Moderator
  • Full Member
  • *
  • Posts: 1568
  • VirtueMart Version: Use VM3.6+
Re: Space in thousands separator for prices??
« Reply #1 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.

LAMF

  • Beginner
  • *
  • Posts: 33
Re: Space in thousands separator for prices??
« Reply #2 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?
BR
LAMF - R.I.P. Johnny Thunders

John2400

  • Virtuemart - the Future is ever Changing
  • Global Moderator
  • Full Member
  • *
  • Posts: 1568
  • VirtueMart Version: Use VM3.6+
Re: Space in thousands separator for prices??
« Reply #3 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]

LAMF

  • Beginner
  • *
  • Posts: 33
Re: Space in thousands separator for prices??
« Reply #4 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...
BR
LAMF - R.I.P. Johnny Thunders

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 28314
  • Always on vacation
    • Jenkin Hill Internet
Re: Space in thousands separator for prices??
« Reply #5 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.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

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

Currently using VirtueMart  4.0.2 10661 on Joomla 3.10.9 PHP 7.4.29

LAMF

  • Beginner
  • *
  • Posts: 33
Re: Space in thousands separator for prices??
« Reply #6 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?
BR
LAMF - R.I.P. Johnny Thunders

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10432
  • VirtueMart Version: 3+
Re: Space in thousands separator for prices??
« Reply #7 on: July 11, 2012, 23:30:21 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

  • Beginner
  • *
  • Posts: 33
Re: Space in thousands separator for prices??
« Reply #8 on: July 12, 2012, 14:10:58 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

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10432
  • VirtueMart Version: 3+
Re: Space in thousands separator for prices??
« Reply #9 on: July 12, 2012, 15:20:47 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

  • Beginner
  • *
  • Posts: 4
Re: Space in thousands separator for prices??
« Reply #10 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:

Code: [Select]
$this->_thousands = str_replace('&', ' ', $this->_thousands);


Final work look this:

Code: [Select]
$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

  • Beginner
  • *
  • Posts: 33
Re: Space in thousands separator for prices??
« Reply #11 on: August 17, 2012, 12:05:20 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

  • Beginner
  • *
  • Posts: 3
Re: Space in thousands separator for prices??
« Reply #12 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

LAMF

  • Beginner
  • *
  • Posts: 33
Re: Space in thousands separator for prices??
« Reply #13 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!
BR
LAMF - R.I.P. Johnny Thunders

kok

  • Beginner
  • *
  • Posts: 35
  • VirtueMart Version: 2.6.10
Re: Space in thousands separator for prices?? [no hacks]
« Reply #14 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.
Joomla! 2.5.27
VirtueMart 2.6.10