LaravelDaily / Laravel-Livewire-ShoppingCart-Demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

remove item from cart

mohamad19941994 opened this issue · comments

Hello Povilas,
I try to create function to remove item from cart can you help me
public function removeFromCart($product_id) { $rowId = Cart::get($product_id); Cart::remove($rowId); $this->emit('cart_updated'); }
this function give error "The cart does not contain rowId 1."
and in blade section this my code:
<p class="btn-holder"> @if($cart->where('id', $shrq->id)->count()) <button wire:click="removeFromCart({{ $shrq->id }})" class="btn btn-danger btn-block text-center" role="button">remove</button> @else <button wire:click="addToCart({{ $shrq->id }})" class="btn btn-warning btn-block text-center" role="button">add</button> @endif </p>
Thanks

@mohamad19941994 sorry I don't provide such personal support for such free repositories. I can answer a quick question but your situation needs debugging to be able to answer, unfortunately I don't have free time for that.