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 » Wed Apr 05, 2006 3:15 pm

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: 1238
Joined: Sat Feb 07, 2004 9:55 pm

Post by norman » Wed Apr 05, 2006 4:14 pm

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 » Wed Apr 05, 2006 4:59 pm

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 » Thu Apr 06, 2006 2:00 am

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: 1238
Joined: Sat Feb 07, 2004 9:55 pm

Post by norman » Thu Apr 06, 2006 2:15 am

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 » Thu Apr 06, 2006 9:43 am

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

Bill

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

Post by norman » Thu Apr 06, 2006 2:12 pm

Just emailed you what's hopefully a solution.
Norman

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

Post by wjcampbe » Thu Apr 06, 2006 2:16 pm

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 » Thu Apr 06, 2006 3:26 pm

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 » Thu Apr 06, 2006 3:40 pm

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: 1238
Joined: Sat Feb 07, 2004 9:55 pm

Post by norman » Sun Apr 09, 2006 12:21 am

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

Post Reply