I am trying to create a japanese version of the quick.cart. While doing this, I found that the amounts in japan should not have a .00 at the end. Does anybody know how to display amounts without .00. Example: Y10000 instead of Y10000.00.
Thanks, Fonk
roland
2006-01-09 11:28
I have written a small and not so beauty, but working script for a problem something like that. You need to modify it, and will work. This script is something like number_format() in PHP.
<script language="JavaScript">
function reverse_string(string_in) { var reversed = ''; for (var x = string_in.length; x >= 0; x--) reversed += string_in.charAt(x); return reversed; }
function insert_separator(string_in, separator) { var tmp = ''; for (var x = 0; x <= string_in.length; x++) if ((x % 3 == 0) && (x != 0) && (x != string_in.length)) tmp += string_in.charAt(x-1) + separator; else tmp += string_in.charAt(x-1);
return tmp; }
function number_format(number, thousand_sep, decimal_sep) { var tmp = number; var tmp2 = '', tmp3 = ''; var int_part = '', dec_part = '';
I forget: You may need to include this script into the js/standard.js file. I hope it helps.
Roland
Fonk
2006-01-10 00:28
Hi Roland,
Thanks for the quick response. I am trying to get it to work. Unfortunately I don't know much about PHP yet. What I did sofar is to put the code in a standard.js file, I included the standard.js in head.tpl and tried to call number_format from products_list.tpl. Something like <script>number_format('1000',' ',',')</script>
The script doesn't return anything. Probably something stupid I am doing.
Tomorrow another day :) Fonk
Roland
2006-01-10 08:37
The standard.js file isn't automatically included in page.tpl? Anyway.
This script doesn't return anything, but writes it to the page. I have modified the code for your needs.
<script language="JavaScript">
function reverse_string(string_in) { var reversed = ''; for (var x = string_in.length; x >= 0; x--) reversed += string_in.charAt(x); return reversed; }
function insert_separator(string_in, separator) { var tmp = ''; for (var x = 0; x <= string_in.length; x++) if ((x % 3 == 0) && (x != 0) && (x != string_in.length)) tmp += string_in.charAt(x-1) + separator; else tmp += string_in.charAt(x-1);
return tmp; }
function number_format(number, thousand_sep) { var int_part = number.toString();
The last line is just an example, don't copy into the standard.js or it will do an extra and useless output to the screen:-). (Now, if you copy the whole code into an .htm or .html file and run it by a web browser, you will see the result, what is 10 001, without any decimals or so.)
Now, as the standard.js contains the functions needed, you have to modify the temlates everywhere you need, like this:
It may be "number_format($aList[fSummary], ' ')", because the script converts the number into string automatically. You will have to modify the .tpl files everywhere you need to format the numbers.
Roland
Roland
2006-01-10 08:40
Change the "<"-s to the "less than" character. It's a bug in the forum engine, it automatically replaces it.
Roland
Roland
2006-01-10 08:48
And take care. In the orders_delivery.tpl let the last 2 numbers unchanged, or it will display the "total cost" 0 when you choose a courier. It is because it uses a JavaScript code to do the calculation, and it will se a string (formatted number with spaces or commas) where he needs a pure number with or without a decimal point, so it will return 0.0. That's the limitation of this solution. With further JS and PHP coding (inside the Quick.Cart) it can be fixed, but I don't want to do that.
Roland
neofrix
2006-01-13 21:45
Roland,
I am green to java and php, still tried your script:
- script copied in standard.js - line changed in products_list.tpl