fdesanto VIP
Total posts: 34
05 Nov 2015 09:57

Hi, I have this scenario:

User buy Basic Plan, after 3 hours he say "Fantastic Product, I move to Pro". But when try to upgrade to Pro he not have any discount.

in /helpers/emerald.php at line 815 I have this code:

$used_days  = floor(($now - $start) / 86400);
$steps_used = ceil($used_days / $ug_plan->params->get('crossplans.ud_price_step'));
if(!$steps_used)
{
    continue;
}

but if an user used plan for less of 1 day then $steps_used var is "0" and he not have discount. Now i have changed line 815 with:

$used_days  = ceil(($now - $start) / 86400);

and now this it's fixed.

Last Modified: 11 Nov 2015


Sergey
Total posts: 13,748
07 Nov 2015 14:26

YOu are right, ceil is better. It will count as one day even not finished day which is fair.

But also I had to delete if(!$steps_used){ continue; }. Because even if user had not used it yet, then full amount of the plan have to become a discount.

Thank you, for report.


fdesanto VIP
Total posts: 34
09 Nov 2015 15:26

Hi, Great, thanks


fdesanto VIP
Total posts: 34
09 Nov 2015 15:48

Ops, I found another small issue. With upgrade very often the amount has many decimals, many payment gateway does not accept values with too many decimal (eg. paypal), so you have to add a round function.

at line 828 of emerald.php I have added round function and now works

$ug_discount        = round($unused_amount,2);

Sergey
Total posts: 13,748
11 Nov 2015 12:07

Perfect! Thank you!

Powered by Cobalt