Snippets Cart

Bootstrap 5 Shopping Cart with Coupon Code

A shopping cart with product thumbnails, quantity steppers, a promo code field and a live order summary with totals and discount.

Bootstrap 5 No jQuery May 2020 8.1K views

<section class="wdw-stage"><div class="container" style="max-width:1000px">
<div class="mb-4"><span class="wdw-eyebrow">Checkout</span><h1 class="wdw-heading h3 mb-0">Shopping cart <span class="wdw-muted fw-normal fs-6" id="cartCount">(3 items)</span></h1></div>
<div class="row g-4 align-items-stretch">
<div class="col-lg-7"><div class="wdw-card px-4 h-100 d-flex flex-column"><ul class="list-unstyled m-0" id="cartItems">
<li class="item d-flex gap-3 py-4" data-price="10.0">
<img src="https://images.unsplash.com/photo-1521572163474-6864f9cf17ab?w=240&h=240&fit=crop&q=80" alt="Classic round-neck tee" width="88" height="88" class="thumb rounded-4 flex-none object-fit-cover">
<div class="flex-grow-1 min-w-0"><div class="d-flex justify-content-between gap-2 mb-3"><div class="min-w-0"><h3 class="h6 mb-1">Classic round-neck tee</h3><p class="small wdw-muted mb-0">Size L · Maxtra</p></div><strong class="line-total">$10.00</strong></div>
<div class="d-flex align-items-center justify-content-between"><div class="qty d-inline-flex align-items-center rounded-pill bg-body-tertiary p-1" role="group" aria-label="Quantity for Classic round-neck tee"><button class="btn btn-sm rounded-circle border-0 text-body" type="button" data-step="-1" aria-label="Decrease quantity">−</button><output class="px-3 fw-semibold text-center" aria-live="polite">1</output><button class="btn btn-sm rounded-circle border-0 text-body" type="button" data-step="1" aria-label="Increase quantity">+</button></div>
<button type="button" class="btn btn-sm btn-icon-sm rounded-circle border-0 text-body-secondary remove" aria-label="Remove Classic round-neck tee"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 6h18M8 6V4a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v2M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6M10 11v6M14 11v6"/></svg></button></div></div></li>
<li class="item d-flex gap-3 py-4" data-price="15.0">
<img src="https://images.unsplash.com/photo-1576566588028-4147f3842f27?w=240&h=240&fit=crop&q=80" alt="Flower formal tee" width="88" height="88" class="thumb rounded-4 flex-none object-fit-cover">
<div class="flex-grow-1 min-w-0"><div class="d-flex justify-content-between gap-2 mb-3"><div class="min-w-0"><h3 class="h6 mb-1">Flower formal tee</h3><p class="small wdw-muted mb-0">Size L · Adda</p></div><strong class="line-total">$15.00</strong></div>
<div class="d-flex align-items-center justify-content-between"><div class="qty d-inline-flex align-items-center rounded-pill bg-body-tertiary p-1" role="group" aria-label="Quantity for Flower formal tee"><button class="btn btn-sm rounded-circle border-0 text-body" type="button" data-step="-1" aria-label="Decrease quantity">−</button><output class="px-3 fw-semibold text-center" aria-live="polite">1</output><button class="btn btn-sm rounded-circle border-0 text-body" type="button" data-step="1" aria-label="Increase quantity">+</button></div>
<button type="button" class="btn btn-sm btn-icon-sm rounded-circle border-0 text-body-secondary remove" aria-label="Remove Flower formal tee"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 6h18M8 6V4a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v2M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6M10 11v6M14 11v6"/></svg></button></div></div></li>
<li class="item d-flex gap-3 py-4" data-price="9.0">
<img src="https://images.unsplash.com/photo-1583743814966-8936f5b7be1a?w=240&h=240&fit=crop&q=80" alt="Printed white tee" width="88" height="88" class="thumb rounded-4 flex-none object-fit-cover">
<div class="flex-grow-1 min-w-0"><div class="d-flex justify-content-between gap-2 mb-3"><div class="min-w-0"><h3 class="h6 mb-1">Printed white tee</h3><p class="small wdw-muted mb-0">Size M · Cantabil</p></div><strong class="line-total">$9.00</strong></div>
<div class="d-flex align-items-center justify-content-between"><div class="qty d-inline-flex align-items-center rounded-pill bg-body-tertiary p-1" role="group" aria-label="Quantity for Printed white tee"><button class="btn btn-sm rounded-circle border-0 text-body" type="button" data-step="-1" aria-label="Decrease quantity">−</button><output class="px-3 fw-semibold text-center" aria-live="polite">1</output><button class="btn btn-sm rounded-circle border-0 text-body" type="button" data-step="1" aria-label="Increase quantity">+</button></div>
<button type="button" class="btn btn-sm btn-icon-sm rounded-circle border-0 text-body-secondary remove" aria-label="Remove Printed white tee"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 6h18M8 6V4a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v2M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6M10 11v6M14 11v6"/></svg></button></div></div></li>
</ul><p class="text-center wdw-muted py-5 mb-0 d-none" id="cartEmpty">Your cart is empty.</p>
<div class="mt-auto border-top py-3"><div class="d-flex justify-content-between small mb-2"><span id="shipMsg">You are $16.00 away from free shipping</span><span class="wdw-muted">$50</span></div><div class="progress" style="height:6px" role="progressbar" aria-label="Free shipping progress" aria-valuemin="0" aria-valuemax="50" id="shipBar"><div class="progress-bar" id="shipFill"></div></div></div></div></div>
<div class="col-lg-5"><div class="wdw-card p-4 h-100 d-flex flex-column">
<h2 class="wdw-heading h5 mb-3">Order summary</h2>
<form class="mb-1" id="couponForm" novalidate><label for="coupon" class="form-label small wdw-muted">Promo code</label>
<div class="d-flex gap-2"><input id="coupon" class="form-control rounded-pill ps-3" placeholder="Try SAVE20" autocomplete="off"><button class="btn btn-dark rounded-pill px-4" type="submit">Apply</button></div>
<div class="small mt-2" id="couponMsg" role="status"></div></form>
<dl class="mt-3 mb-0 small">
<div class="d-flex justify-content-between py-1"><dt class="fw-normal wdw-muted">Subtotal</dt><dd class="mb-0" id="sSub">$34.00</dd></div>
<div class="d-flex justify-content-between py-1 d-none" id="discRow"><dt class="fw-normal wdw-muted">Discount (20%)</dt><dd class="mb-0 text-success" id="sDisc">-$0.00</dd></div>
<div class="d-flex justify-content-between py-1"><dt class="fw-normal wdw-muted">Shipping</dt><dd class="mb-0" id="sShip">$4.00</dd></div>
<div class="d-flex justify-content-between pt-3 mt-2 border-top fs-5"><dt class="fw-bold">Total</dt><dd class="mb-0 fw-bold" id="sTotal">$38.00</dd></div></dl>
<button type="button" class="btn btn-primary rounded-pill w-100 mt-4">Checkout</button>
<p class="d-flex align-items-center justify-content-center gap-2 small wdw-muted mt-3 mb-0"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="4" y="11" width="16" height="10" rx="2"/><path d="M8 11V7a4 4 0 0 1 8 0v4"/></svg>Secure checkout · Visa, Mastercard, PayPal</p>
<a href="#" class="d-inline-flex align-items-center justify-content-center gap-2 mt-auto pt-3 link-secondary link-underline-opacity-0 small fw-semibold"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m15 18-6-6 6-6"/></svg>Continue shopping</a>
</div></div></div></div></section>

Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.