protected static $_specifications = null;
protected static $_productTypes = null;
protected static $_specificationFields = null;
- protected static $_cart_data;
+ protected static $_cart_data = null;
/**
* @var array
if (!self::$_cart_data) {
$cart_items = session('cart_items', []);
-
self::$_cart_data = [];
- $products = self::with('media')->whereIn('id', array_keys($cart_items))->get();
-
- foreach ($products as $product) {
- self::$_cart_data[] = [
- 'id' => $product->id,
- 'name' => $product->name,
- 'reference' => $product->reference,
- 'category' => $product->type->name,
- 'quantity' => $cart_items[$product->id],
- 'image' => $product->image,
- 'URL' => $product->url,
- ];
+
+ if (count($cart_items) > 0) {
+
+ $products = self::with('media')->whereIn('id', array_keys($cart_items))->get();
+
+ foreach ($products as $product) {
+ self::$_cart_data[] = [
+ 'id' => $product->id,
+ 'name' => $product->name,
+ 'reference' => $product->reference,
+ 'category' => $product->type->name,
+ 'quantity' => $cart_items[$product->id],
+ 'image' => $product->image,
+ 'URL' => $product->url,
+ ];
+ }
}
}