DEV Community

loading...

Shopping Cart Laravel 8: part 03

remonhasan profile image Remon Hasan ・1 min read

Alt Text

Source Code

Github

Add to cart

Now we have to pick the add to cart of product by using wire bind as like:

wire:click.prevent="store({{$product->id}},'{{$product->name}}',{{$product->regular_price}})"

Additionally, we can use the method of count() for checking there is any product or not! For that we can use the loop like:

@if(Cart::count()>0)
// go for product
else
No Products
@endif

Fetch product image from database

src="{{asset('assets/images/products')}}/{{$item->model->image}}"

Route action

href="{{route('product.details',['slug'=>$item->model->slug])}}"

Rest of the functions of building cart package

  1. Subtotall
  2. Total
  3. Tax

Alt Text

Discussion (0)

Forem Open with the Forem app