From 2392b688398a77f155ba24d6affb0e3c34cbafba Mon Sep 17 00:00:00 2001 From: merdan Date: Mon, 28 Feb 2022 17:32:19 +0500 Subject: [PATCH] cart product adn super attributes --- .../API/Http/Resources/Checkout/CartItemProduct.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/Sarga/API/Http/Resources/Checkout/CartItemProduct.php b/packages/Sarga/API/Http/Resources/Checkout/CartItemProduct.php index fd70b2321..7a15b70f4 100644 --- a/packages/Sarga/API/Http/Resources/Checkout/CartItemProduct.php +++ b/packages/Sarga/API/Http/Resources/Checkout/CartItemProduct.php @@ -15,15 +15,13 @@ class CartItemProduct extends JsonResource */ public function toArray($request) { - /* assign product */ - $product = $this->product ? $this->product : $this; return [ 'id' => $this->id, - 'name' => $product->name, - 'images' => ProductImage::collection($product->images), + 'name' => $this->name, + 'images' => ProductImage::collection($this->images), /* super attributes */ - $this->mergeWhen(!empty($this->product->parent), [ - 'super_attributes' => $this->super_attributes($this->product->parent->super_attributes), + $this->mergeWhen(!empty($this->parent && $this->parent->super_attributes), [ + 'super_attributes' => $this->super_attributes($this->parent->super_attributes), ]), ]; }