Loading...

Fix lỗi Laravel tích hợp Shopping Cart nhưng không save được


Anh em nào cái đặt source laravel mới  mà tích hợp https://github.com/darryldecode/laravelshoppingcart thường sẽ bị lỗi không save được data.

Ví dụ 

// now the product to be added on cart
$product = array(
'id' => 456,
'name' => 'Sample Item 1',
'price' => 100,
'quantity' => 1,
'attributes' => array(),
'conditions' => array()
);
// finally add the product on the cart
\Cart::add($product);



Nhưng khi get ra lại thì không có dữ liệu

$items = \Cart::getContent();

 

Cách khắc phục thêm vào file app/Http/Kernel.php

\Illuminate\Session\Middleware\StartSession::class,

 

Fix lỗi Laravel tích hợp Shopping Cart nhưng không save được

Chúc anh em thành công.

# Bài viết cùng chuyên mục