SMF Shop

SMFShop => Coding => Topic started by: Raymond on November 29, 2007, 01:00:02 am

Title: Change "7.00 cedits" to "7 credits"
Post 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.
Title: Re: Change "7.00 cedits" to "7 credits"
Post by: Dark_Zero on November 29, 2007, 04:46:27 am
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.
Title: Re: Change "7.00 cedits" to "7 credits"
Post by: Daniel15 on December 03, 2007, 12:44:45 pm
Alternatively you could change it to
Code: [Select]
$money = (int) $money;
Which will round off the value if needed.
Title: Re: Change "7.00 cedits" to "7 credits"
Post by: Vincent Volmer on January 06, 2008, 11:59:16 pm
Alternatively you could change it to
Code: [Select]
$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
Title: Re: Change "7.00 cedits" to "7 credits"
Post by: DarkAxi0m on January 08, 2008, 10:40:45 am
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)
Title: Re: Change "7.00 cedits" to "7 credits"
Post by: Daniel15 on January 11, 2008, 03:09:01 pm
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:
Code: [Select]
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 :)
Title: Re: Change "7.00 cedits" to "7 credits"
Post by: Vincent Volmer on January 12, 2008, 02:17:55 am
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