A
Anonymous

Shopping Cart Component - Copy this Html, Bootstrap Component to your project

@extends('layouts.app') @section('content') <h1>Giỏ hàng của bạn</h1> @if(session('success')) <div class="alert alert success"> {{ session('success') }} </div> @endif @if(count($cart) > 0) <table class="table"> <thead> <tr> <th>Tên sản phẩm</th> <th>Số lượng</th> <th>Giá</th> <th>Thành tiền</th> <th>Hãng sản xuất</th> <th>Hành động</th> </tr> </thead> <tbody> @php $total = 0; @endphp @foreach ($cart as $id => $details) @php $total += $details['price'] * $details['quantity']; @endphp <tr> <td>{{ $details['name'] }}</td> <td> <form action="{{ route('cart.update', $id) }}" method="POST" style="display: inline;"> @csrf @method('PATCH') <input type="number" name="quantity" value="{{ $details['quantity'] }}" min="1" class="form control" style="width: 60px; display: inline;"> <button type="submit" class="btn btn sm btn secondary">Cập nhật</button> </form> </td> <td>{{ number_format($details['price'], 2) }}</td> <td>{{ number_format($details['price'] * $details['quantity'], 2) }}</td> <td>{{ $details['category'] }}</td> <td> <form action="{{ route('cart.remove', $id) }}" method="POST"> @csrf @method('DELETE') <button type="submit" class="btn btn danger">Xoá</button> </form> </td> </tr> @endforeach </tbody> </table> <div class="text right"> <h3>Tổng tiền: {{ number_format($total, 2) }} VND</h3> <! Thêm nút thanh toán > <a href="{{ route('orders.create') }}" class="btn btn success">Thanh toán</a> </div> @else <p>Giỏ hàng của bạn trống.</p> @endif <a href="{{ route('products.index') }}" class="btn btn primary">Tiếp tục mua sắm</a> @endsection

Prompt
Component Preview

About

Shopping Cart Component - Manage your products with quantity updates, price calculations, and easy removal options, built with HTML an. Get code instantly!

Share

Last updated 1 month ago