Adding a thousand separator

Automatic multi currency display on entire catalog.

Run your catalog in a main currency (or a main and alternate) with the customer having the option to turn on an additional currency throughout the Catalog, Cart and Checkout.
Post Reply
wjcampbe
Posts: 7
Joined: Wed Apr 05, 2006 3:11 pm

Adding a thousand separator

Post by wjcampbe »

Norman,

How easy would it be to amend NorPrice to format the output with a thousands separator on currencies such as Japanese Yen?

Finance Director does not like the current display.

thanks,
Bill
norman
Site Admin
Posts: 1248
Joined: Sat Feb 07, 2004 9:55 pm

Post by norman »

NorPrice displays the alternate currency in 2 ways. If the exchange rate is below a certain value (CUSTOMVAR:HIDEFRACTIONRATE) it uses nnnn.nn If the exchange rate is above it just displays the integer value.

Neither of these routines do any comma type formatting. It wouldn't be hard to add, however. All you'd need to do is alter 2 files

Cart and Checkout the Perl routine ActinicOrder.pm, lines the format strings within

$sFormattedPrice .= sprintf(" (%d $iso)", $nNorprice);

and

$sFormattedPrice .= sprintf(" (%1.2f $iso)", $nNorprice);

for the integer and decimal version.

For the Product page, norpricesupport.js JavaScript and the lines are

return prefix + ' (' + optplus + Math.round(altprice) + ' ' + isoname + ')' + suffix;

and

return prefix + ' (' + optplus + topounds(altprice) + ' ' + isoname + ')' + suffix;

where the Math.round(altprice) and topounds(altprice) would need some code added to fit in the commas.

This http://www.web-source.net/web_developme ... atting.htm page contains some routines for both Perl and JavaScript.
Norman
wjcampbe
Posts: 7
Joined: Wed Apr 05, 2006 3:11 pm

Post by wjcampbe »

Excellent Norman,

Will let you know how I get on.

Bill
wjcampbe
Posts: 7
Joined: Wed Apr 05, 2006 3:11 pm

Post by wjcampbe »

I'm almost there.

I have working javascript when there is a fraction in the result, but not when the result is a whole number.

I have consistently working perl.

Want a copy back when I'm finished? :D

Bill
norman
Site Admin
Posts: 1248
Joined: Sat Feb 07, 2004 9:55 pm

Post by norman »

Yes please.

I was going to look at adding this myself when I had some free time but anything that speeds that up will be useful.
Norman
wjcampbe
Posts: 7
Joined: Wed Apr 05, 2006 3:11 pm

Post by wjcampbe »

Have sent an email - perfect perl and partial javascript. Still working on it.

Bill
norman
Site Admin
Posts: 1248
Joined: Sat Feb 07, 2004 9:55 pm

Post by norman »

Just emailed you what's hopefully a solution.
Norman
wjcampbe
Posts: 7
Joined: Wed Apr 05, 2006 3:11 pm

Post by wjcampbe »

I just came on to say my solution is now working 100% in everything except Opera 9.

OK in IE6, IE7, Firefox and Opera 8.5.

Will look at your solution, and see if it's the same change I made, then come back at you.
wjcampbe
Posts: 7
Joined: Wed Apr 05, 2006 3:11 pm

Post by wjcampbe »

Nope - the javascript would not work. I will send you the one I have working.

Bill
wjcampbe
Posts: 7
Joined: Wed Apr 05, 2006 3:11 pm

Post by wjcampbe »

Just got your patched javascript - it works - so much neater and more compact than what I had :oops: - guess I won't send you anything new after all.


Thanks loads, Norman.
norman
Site Admin
Posts: 1248
Joined: Sat Feb 07, 2004 9:55 pm

Post by norman »

I can't take too much credit. I got most of it from the O'Reilly Perl Cookbook.
Norman
Post Reply