WHMCS: Round up product prices for secondary currencies
Today, I actually assisted my hosting provider in setting up secondary currencies in WHMCS, the billing and support system for/from cpanel!
They only wanted full numbers for the monthly breakdowns, so when they click "Update Prices" in the Currency Settings and a product would cost 1233.37 the price gets automatically rounded up to 1234.00.
Unfortunately, WHMCS doesn't offer this feature, so I suggested to setup a script on a secure location that they can trigger after they update the currency conversion rates and product prices. Below is the sql query that goes through all secondary currencies (1 = default currency) and rounds up the values, so that the setup fee and all monthly prices are full numbers.
The script itself would run a simple MySQL query:
msetupfee = ceil(msetupfee),
qsetupfee = ceil(qsetupfee),
ssetupfee = ceil(ssetupfee),
asetupfee = ceil(asetupfee),
bsetupfee = ceil(bsetupfee),
tsetupfee = ceil(tsetupfee),
monthly = ceil(monthly),
quarterly = ceil(quarterly/3)*3,
semiannually = ceil(semiannually/6)*6,
annually = ceil(annually/12)*12,
biennially = ceil(biennially/24)*24,
triennially = ceil(triennially/36)*36
WHERE
currency != 1 AND
id = id
you could replace
with
or
etc
Enjoy
2296
I might want to round the costs also.
Particularly on the grounds that for instance in swiss francs, the littlest coin is 5 penny. So costs with something else than 0 or 5 toward the end look moronic and will really make perplexity among customers.
For my situation I would want to round the costs down/up to xx.x0 for areas, and xx.00 for facilitating items. I figure I will simply impair the WHMCS include and compose my own cron script that redesigns costs accordignly…
Hi,
To round up/down use this:
If you need to have 2 decimal points, you can use number_format(VALUE, 2), for example:
To always round up, use this php function:
source: http://stackoverflow.com/questions/8239600/rounding-up-to-the-second-decimal-place