From a8cdf29fc7aed023d982b802e09845ba39d66857 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Mon, 1 Feb 2021 15:35:04 +0530 Subject: [PATCH] Issue #3572, fixes percentage for 2 decimal values --- packages/Webkul/Product/src/Type/AbstractType.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/Webkul/Product/src/Type/AbstractType.php b/packages/Webkul/Product/src/Type/AbstractType.php index 083c38c57..eb286c93f 100644 --- a/packages/Webkul/Product/src/Type/AbstractType.php +++ b/packages/Webkul/Product/src/Type/AbstractType.php @@ -959,7 +959,7 @@ abstract class AbstractType if ($haveOffers) { foreach ($customerGroupPrices as $key => $customerGroupPrice) { - if ($key > 0) { + if ($customerGroupPrice && $customerGroupPrice->qty > 1) { array_push($offerLines, $this->getOfferLines($customerGroupPrice)); } } @@ -985,7 +985,7 @@ abstract class AbstractType public function getOfferLines($customerGroupPrice) { $price = $this->getCustomerGroupPrice($this->product, $customerGroupPrice->qty); - $discount = (($this->product->price - $price) * 100) / ($this->product->price); + $discount = number_format((($this->product->price - $price) * 100) / ($this->product->price), 2); $offerLines = trans('shop::app.products.offers', ['qty' => $customerGroupPrice->qty, 'price' => core()->currency($price), 'discount' => $discount]);