From 30eea44d48f76fd6da476e9d94933b23dc3c2852 Mon Sep 17 00:00:00 2001 From: merdan Date: Thu, 17 Nov 2022 16:08:28 +0500 Subject: [PATCH] discount cart rules --- .../API/Http/Resources/Checkout/CartRuleResource.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/Sarga/API/Http/Resources/Checkout/CartRuleResource.php b/packages/Sarga/API/Http/Resources/Checkout/CartRuleResource.php index b7626d858..1942faaa8 100644 --- a/packages/Sarga/API/Http/Resources/Checkout/CartRuleResource.php +++ b/packages/Sarga/API/Http/Resources/Checkout/CartRuleResource.php @@ -13,14 +13,16 @@ class CartRuleResource extends JsonResource public function toArray($request): array { + $is_fixed = str_contains($this->action_type,'fixed'); return [ 'id' => $this->id, 'name' => $this->name, 'description' => $this->description, - 'action_type' => $this->action_type, - 'amount' => str_contains($this->action_type,'fixed')? - core()->formatPrice($this->discount_amount, $this->currency): - $this->discount_amount.'%' + 'is_fixed' => $is_fixed, + 'is_discount' => $this->discount_amoun >0, + 'amount' => (double) ($is_fixed ? + core()->convertPrice($this->discount_amount, $this->currency): + $this->discount_amount) ]; }