public function roundFixedAmountCoupon(&$total)
{
$app = Factory::getApplication();
$paramsC = PhocacartUtils::getComponentParameters();
$rounding_calculation_fac = $paramsC->get('rounding_calculation_fixed_amount_coupon', -1);
if ($rounding_calculation_fac < 0) {
return;
}
$discount = 0;
if (!empty($total['couponcartfixedamount'])) {
foreach ($total['couponcartfixedamount'] as $k => $v) {
if (isset($v['discount'])) {
if (isset($v['netto']) && $v['netto'] < $v['discount']) {
$discount = $v['netto'];
// more pieces of product - so the cart discount is divided to more pieces of products, but max to cart discount fixed amount
} else {
$discount = $v['discount'];
// one product - whole cart discount goes to one product
}
}
}
}
if (isset($total['dnetto']) && $total['dnetto'] > 0 && $discount > 0) {
$dif = $discount - $total['dnetto'];
if ($dif > 0) {
$total['rounding'] += $dif;
$total['dnetto'] = $discount;
} else {
if ($dif < 0) {
$total['rounding'] -= $dif;
$total['dnetto'] = $discount;
}
}
}
return;
}