laravelEcomm/resources/views/cart.blade.php
2024-07-07 13:06:31 +05:45

184 lines
7.9 KiB
PHP

<x-header />
<!-- Breadcrumb Section Begin -->
<section class="breadcrumb-option">
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="breadcrumb__text">
<h4>Shopping Cart</h4>
<div class="breadcrumb__links">
<a href="{{ url::to('/') }}">Home</a>
<a href="{{ url::to('shop') }}">Shop</a>
<span>Shopping Cart</span>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Breadcrumb Section End -->
<!-- Shopping Cart Section Begin -->
<section class="shopping-cart spad">
<div class="container">
<div class="row">
<div class="col-lg-8">
<div class="shopping__cart__table">
@if (session()->has('success'))
<div id="success-message" class="alert alert-success">
{{ session()->get('success') }}
</div>
@endif
@if (session()->has('error'))
<div id="error-message" class="alert alert-danger">
{{ session()->get('error') }}
</div>
@endif
<table>
<thead>
<tr>
<th>Product</th>
<th>Quantity</th>
<th>Total</th>
<th></th>
</tr>
</thead>
{{-- <tbody>
@foreach ($cartItems as $item)
<tr>
<td class="product__cart__item">
<div class="product__cart__item__pic">
<img src="{{ asset('uploads/products/' . $item->picture) }}" alt="">
</div>
</td>
<td class="quantity__item">
<div class="product__cart__item__text">
<h6>{{ $item->name }} (<b>Nrs {{ $item->price }}</b>)</h6>
<h5></h5>
</div>
<div class="quantity">
<input type="number" class="form-control" name="quantity" min="1"
max="{{ $item->pQuantity }}" value="{{ $item->quantity }}">
</div>
</td>
<td class="cart__price"><br> Nrs. {{ $item->price * $item->quantity }}</td>
<td class="cart__close"> <a href="{{ url::to('deleteCartItem/' . $item->id) }}">
<i class="fa fa-trash"></i></a>
</td>
</tr>
@endforeach
</tbody> --}}
<tbody>
@php
$total = 0;
@endphp
@foreach ($cartItems as $item)
<tr>
<td class="product__cart__item">
<div class="product__cart__item__pic">
<img src="{{ asset('uploads/products/' . $item->picture) }}" alt="">
</div>
</td>
<td class="quantity__item">
<div class="product__cart__item__text">
<h6>{{ $item->name }}</h6>
<h5><b>Nrs {{ $item->price }}</b></h5>
</div>
<div class="quantity">
<form action="{{ route('cart.update', $item->id) }}" method="post">
@csrf
<input type="number" class="form-control" name="quantity"
min="1" max="{{ $item->pQuantity }}"
value="{{ $item->quantity }}">
<button type="submit"
class="btn btn-primary mt-2 btn-block">Update</button>
</form>
</div>
</td>
<td class="cart__price"><br> Nrs. {{ $item->price * $item->quantity }}</td>
<td class="cart__close"> <a href="{{ url::to('deleteCartItem/' . $item->id) }}">
<i class="fa fa-trash"></i></a>
</td>
</tr>
@php
$total += $item->price * $item->quantity;
@endphp
@endforeach
</tbody>
</table>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="continue__btn">
<a href="#">Continue Shopping</a>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="continue__btn update__btn">
<a href="#"><i class="fa fa-spinner"></i> Update cart</a>
</div>
</div>
</div>
</div>
<div class="col-lg-4">
<div class="cart__discount">
<h6>Discount codes</h6>
<form action="#">
<input type="text" placeholder="Coupon code">
<button type="submit">Apply</button>
</form>
</div>
<div class="cart__total">
<h6>Cart total</h6>
<ul>
<li>Subtotal <span>Nrs {{ $total }} </span></li>
<li>Total <span>Nrs {{ $total }}</span></li>
</ul>
<form action=" {{ url::to('checkout') }} ">
<input type="text" name="name" class="form-control mt-2" placeholder="Enter Name"
id="" required>
<input type="text" name="phone" class="form-control mt-2"
placeholder
="Enter Phone" id="" required>
<input type="text" name="address" class="form-control mt-2"
placeholder
="Enter Address" id="" required>
<input type="hidden" name="bill" class="form-control mt-2" value="{{ $total }}"
id="" required>
<input type="submit" name="checkout" class="primary-btn mt-2 btn-block"
value="Proceed to Checkout" id="" required>
</form>
</div>
</div>
</div>
</div>
</section>
<!-- Shopping Cart Section End -->
<!-- Footer Section Begin -->
<x-footer />
<!-- Footer Section End -->