From 3537135c36ec15c991bca7a20c2fa894566d2c83 Mon Sep 17 00:00:00 2001 From: merdan Date: Thu, 21 Apr 2022 17:30:05 +0500 Subject: [PATCH] discounted configurables --- packages/Sarga/API/Http/Resources/Catalog/Product.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/Sarga/API/Http/Resources/Catalog/Product.php b/packages/Sarga/API/Http/Resources/Catalog/Product.php index cffcfc38c..6c56f4e15 100644 --- a/packages/Sarga/API/Http/Resources/Catalog/Product.php +++ b/packages/Sarga/API/Http/Resources/Catalog/Product.php @@ -215,8 +215,9 @@ class Product extends JsonResource 'color_count' => $this->variants->groupBy('color')->count(), ]; -// Log::info($this->variants); - if( $special_variant = $this->variants()->where('min_price','<','max_price')->orderBy('min_price')->first()){ + $special_variant = $this->variants->sortBy('min_price')->first(); + + if($special_variant && $special_variant->min_price < $special_variant->max_price){ $data = array_merge($data, [ 'special_price' => core()->convertPrice($special_variant->min_price), 'formatted_special_price' => core()->currency($special_variant->min_price),