function initSubscriptionPaymentParams(&$subscription, $rows2) { $app =& JFactory::getApplication(); $coupon_code = $app->getUserStateFromRequest('com_joomla_lms_dis_coupon_code', 'dis_coupon_code', ''); $p_coupon_disc = 0; $p_disc = 0; $p_disc = JLMS_DISCOUNTS::getPercentDiscounts($subscription->id); $p_coupon_disc = JLMS_DISCOUNTS::getPercentCouponDiscount($coupon_code, $subscription->id); if ($subscription->account_type == '6') { $sub_total = JLMS_RECURRENT_PAY::getFirstDayPrice($subscription); } else { $sub_total = round($subscription->price, 2); } if ($sub_total < 0) { $sub_total = 0; } $tax = 0; $tax_type = 0; $tax_amount = 0; $disc = 0; if ($subscription->account_type == '5') { $disc = $sub_total * ($subscription->discount / 100); } if ($p_coupon_disc > 0) { $disc += $sub_total * $p_coupon_disc / 100; } if ($p_disc > 0) { $disc += $sub_total * $p_disc / 100; } if (count($rows2) > 0) { $price = $sub_total - $disc; if ($rows2[0]->tax > 0) { if ($rows2[0]->tax_type == 1) { $tax_amount = round($price / 100 * $rows2[0]->tax, 2); } } $tax = $rows2[0]->tax; $tax_type = $rows2[0]->tax_type; } $subscription->disc = $disc; $subscription->tax = $tax; $subscription->tax_type = $tax_type; $subscription->tax_amount = $tax_amount; $subscription->sub_total = $sub_total; $subscription->total = $sub_total - $disc; if ($subscription->total < 0) { $subscription->total = $tax_amount; } else { $subscription->total += $tax_amount; } $subscription->p_coupon_disc = $p_coupon_disc; $subscription->p_disc = $p_disc; }