Open Jay-Dabo opened 4 years ago
@Jay-Dabo how are you adding the item to the cart? using the users id as in the example:
// add cart items to a specific user $userId = auth()->user()->id; // or any string represents user identifier Cart::session($userId)->add(array( 'id' => 456, // inique row ID 'name' => 'Sample Item', 'price' => 67.99, 'quantity' => 4, 'attributes' => array(), 'associatedModel' => $Product ));
@frezno
public function add(Product $product) {
// Add to Cart
\Cart::session(auth()->id())->add(array(
'id' => $product->id,
'name' => $product->product_name,
'price' => $product->price,
'quantity' => 1,
'attributes' => array(),
'associatedModel' => $product
));
return back();
}
Any help here?
Anytime i add an item to cart and try to update the quantity, the page reloads and returns a quantity of zero to the item i edit.
Here's my CartController.php code:
Here are my cart index.blade.phpcodes:
I did a lot of switch backs between Laravel Collective and not plain HTML
Here's my route web.php code:
Route::get('cart/update/{itemId}', 'CartController@update')->name('cart.update')->middleware('auth');