Shopping Cart Page
URL: /cart/list
Template: Cart module view
The shopping cart displays all items the user has added. It includes item quantities, prices, subtotals, tax, and shipping estimates.
Cart Data via getCart()
On the cart page, use getCart() (with no argument) to fetch the full cart object:
Cart Object Structure
| Key | Type | Description |
|---|---|---|
items |
array |
Array of cart item objects |
subTotal |
float |
Sum of all items before tax/shipping |
taxAmount |
float |
Total tax applied |
shippingAmount |
float |
Estimated shipping cost |
grandTotal |
float |
Final total (subtotal + tax + shipping) |
couponCode |
string |
Applied coupon code, or empty |
couponDiscount |
float |
Discount amount from coupon |
customerCredit |
float |
Customer credit applied |
Cart Item Structure
Each $cart['items'] element:
| Key | Type | Description |
|---|---|---|
productId |
int | Product ID |
name |
string | Product name |
itemNo |
string | SKU |
quantity |
int | Quantity in cart |
price |
float | Unit price |
totalPrice |
float | price * quantity |
image |
string | Product image URL |
permalink |
string | Product URL slug |
detailUrl |
string | Link to product detail page |
updateUrl |
string | URL to update this item's quantity |
removeUrl |
string | URL to remove this item from the cart |
shippingMode |
string | Shipping mode code |
Quick Cart Count (Header)
For the header cart badge, use the filtered version:
<a href="{{ customUrl('cart_list') }}" class="btn btn-warning">
Cart
<span class="badge bg-danger">{{ getCart('cartProductQuantity') }}</span>
</a>
Template Skeleton
@extends('layout.layout')
@section('headtitle')
<title>Shopping Cart | {{ $page->settings->siteTitle }}</title>
@endsection
@section('content')
@php $cart = getCart(); @endphp
<div class="container mt-4">
<h1>Your Shopping Cart</h1>
@if(empty($cart['items']))
<div class="alert alert-info">Your cart is empty. <a href="{{ customUrl('home') }}">Continue Shopping</a></div>
@else
<table class="table">
<thead>
<tr>
<th>Product</th>
<th>Price</th>
<th>Quantity</th>
<th>Total</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach($cart['items'] as $item)
<tr>
<td>
<img src="{{ $item['image'] ?? noproductimage() }}" width="60" alt="{{ $item['name'] }}">
<a href="{{ $item['detailUrl'] ?? '#' }}">{{ $item['name'] }}</a>
<small class="text-muted d-block">{{ $item['itemNo'] }}</small>
</td>
<td>${{ tagPrice($item['price'] ?? 0) }}</td>
<td>{{ $item['quantity'] ?? 1 }}</td>
<td>${{ tagPrice($item['totalPrice'] ?? 0) }}</td>
<td>
<a href="{{ $item['removeUrl'] ?? '#' }}" class="btn btn-sm btn-outline-danger">Remove</a>
</td>
</tr>
@endforeach
</tbody>
</table>
<div class="d-flex justify-content-end">
<table class="table" style="width: 300px;">
<tr>
<td>Subtotal:</td>
<td>${{ tagPrice($cart['subTotal'] ?? 0) }}</td>
</tr>
@if(($cart['couponDiscount'] ?? 0) > 0)
<tr>
<td>Coupon ({{ $cart['couponCode'] }}):</td>
<td>-${{ tagPrice($cart['couponDiscount']) }}</td>
</tr>
@endif
<tr>
<td>Tax:</td>
<td>${{ tagPrice($cart['taxAmount'] ?? 0) }}</td>
</tr>
@if(!bulkBuyer())
<tr>
<td>Shipping:</td>
<td>${{ tagPrice($cart['shippingAmount'] ?? 0) }}</td>
</tr>
@else
<tr>
<td>Shipping:</td>
<td><strong class="text-success">FREE (Bulk Buyer)</strong></td>
</tr>
@endif
<tr class="fw-bold">
<td>Total:</td>
<td>${{ tagPrice($cart['grandTotal'] ?? 0) }}</td>
</tr>
</table>
</div>
<div class="d-flex justify-content-end gap-2">
<a href="{{ customUrl('home') }}" class="btn btn-outline-secondary">Continue Shopping</a>
<a href="{{ customUrl('checkout_address') }}" class="btn btn-primary">Proceed to Checkout</a>
</div>
@endif
</div>
@endsection