SMF Shop
SMFShop => Coding => Topic started by: Raymond on November 29, 2007, 01:00:02 am
-
At the moment my forum says that someone has for example "17.00" credits.
Is there a way to Change the 17.00 cedits to 17 credits?
Thanks for the help.
-
i looked around in the source and i saw the function making the money a 'floating- point' value.
in Shop-Subs.php, at the top, find "// Cast to float", and the line under that, either delete the two lines or put two succeeding slashes at the beginning of the line to make it a comment. (to preserve the code for the future if needed)
i.e. delete this..
// Cast to float
$money = (float) $money;
or.. make it a comment like this
// Cast to float
// $money = (float) $money;
either one works.
-
Alternatively you could change it to
$money = (int) $money;
Which will round off the value if needed.
-
Alternatively you could change it to
$money = (int) $money;
Which will round off the value if needed.
Hello,
thanks for the hack.
Maybe I'm doing something wrong but this hack didn't change anything for me. It's still displaying 123.00 instead of 123
Regards
Vincent Volmer
-
Hi just wondering if it would be Possible to Have the bank show 7.00 and else where 7.
All i can think of is to change the bank sections to not use
function formatMoney($money)
-
Vincent Volmer, are you sure you updated the file correctly?
DarkAxi0m, perhaps make a new function called "formatMoneyBank" in Shop-Subs.php? Edit the normal function as mentioned above, and then add something like:
function formatMoneyBank($money)
{
global $modSettings;
// Cast to float
$money = (float) $money;
// Return amount with prefix and suffix added
return $modSettings['shopCurrencyPrefix'] . $money . $modSettings['shopCurrencySuffix'];
}
(this is the original code, except it's a function called formatMoneyBank instead of formatMoney)
Then, go through the code, and whenever you want something to appear with the decimal places, change formatMoney( to formatMoneyBank( (probably in Shop-Bank.php and Shop.template.php, among others)
Hope this helps you :)
-
Vincent Volmer, are you sure you updated the file correctly?
I see that there are some places: ( index.php?action=shop ) which display the credits correct like 7 credits. On other places like the member list or in the shop ( index.php?action=shop;do=buy ) still are displaying 7.00 credits. I really think I did something wrong or I misunderstood the hack.... but I don't know what or how.
If you don't understand what I mean, please take a look at our website but you need to register first. I can do that for you if you like because the whole website is in Dutch language. If needed I'll send you a PM.
Regards Vincent Volmer