Discount percentage rounded

This commit is contained in:
2025-11-13 10:29:50 +01:00
parent fcaf67e8be
commit 35e6b82422

View File

@@ -461,9 +461,15 @@ class ProductLazyArray extends AbstractLazyArray
if ($show_price && $this->product['reduction']) { if ($show_price && $this->product['reduction']) {
if ($this->product['discount_type'] === 'percentage') { if ($this->product['discount_type'] === 'percentage') {
$discountLabel = $this->product['discount_percentage'];
$num = floatval(str_replace(',', '.', preg_replace('/[^0-9,.-]/', '', $discountLabel)));
$rounded = round($num);
$discountLabel = sprintf('-%d%%', abs($rounded));
$flags['discount'] = [ $flags['discount'] = [
'type' => 'discount', 'type' => 'discount',
'label' => $this->product['discount_percentage'], // 'label' => $this->product['discount_percentage'],
'label' => $discountLabel,
]; ];
} elseif ($this->product['discount_type'] === 'amount') { } elseif ($this->product['discount_type'] === 'amount') {
$flags['discount'] = [ $flags['discount'] = [