Bootstrap 5 Checkout Form with Order Summary
A two-column checkout with shipping and card fields beside a live order summary that updates quantities, totals and gift codes.
<section class="wdw-stage">
<div class="container" style="max-width:1040px">
<nav aria-label="Checkout progress" class="mb-4">
<ol class="breadcrumb justify-content-center small fw-semibold text-uppercase mb-0">
<li class="breadcrumb-item"><a href="#" class="text-decoration-none wdw-muted">Shop</a></li>
<li class="breadcrumb-item"><a href="#" class="text-decoration-none wdw-muted">Shopping bag</a></li>
<li class="breadcrumb-item active text-primary" aria-current="page">Checkout</li>
</ol>
</nav>
<div class="row g-4">
<div class="col-lg-7">
<form class="wdw-card p-4 p-md-5" id="checkoutForm" novalidate>
<h1 class="wdw-heading h3 mb-4">Checkout</h1>
<h2 class="wdw-eyebrow mb-3">Shipping details</h2>
<div class="row g-3 mb-4">
<div class="col-12"><div class="form-floating"><input class="form-control" id="coName" placeholder="Full name" value="Alex Morgan" autocomplete="name" required><label for="coName">Full name</label><div class="invalid-feedback">Please enter your name.</div></div></div>
<div class="col-12"><div class="form-floating"><input class="form-control" id="coAddr" placeholder="Address" value="12 Garden Row, Stockholm" autocomplete="street-address" required><label for="coAddr">Address</label><div class="invalid-feedback">Please enter your address.</div></div></div>
</div>
<h2 class="wdw-eyebrow mb-3">Payment details</h2>
<div class="row g-3">
<div class="col-12"><div class="form-floating"><input class="form-control" id="coCardName" placeholder="Name on card" autocomplete="cc-name" required><label for="coCardName">Name on card</label><div class="invalid-feedback">Enter the name on the card.</div></div></div>
<div class="col-12"><div class="form-floating"><input class="form-control" id="coCard" placeholder="Card number" inputmode="numeric" autocomplete="cc-number" maxlength="19" minlength="19" required><label for="coCard">Card number</label><div class="invalid-feedback">Enter a 16-digit card number.</div></div></div>
<div class="col-6"><div class="form-floating"><input class="form-control" id="coExp" placeholder="MM/YY" autocomplete="cc-exp" maxlength="5" minlength="5" pattern="(0[1-9]|1[0-2])/\d\d" required><label for="coExp">Valid through</label><div class="invalid-feedback">Use the format MM/YY.</div></div></div>
<div class="col-6"><div class="form-floating"><input class="form-control" id="coCvc" placeholder="CVC" inputmode="numeric" autocomplete="cc-csc" maxlength="4" minlength="3" required><label for="coCvc">CVC</label><div class="invalid-feedback">Enter the 3 or 4 digit code.</div></div></div>
</div>
<button type="submit" class="btn btn-primary btn-lg rounded-pill w-100 mt-4" data-pay>Pay</button>
<div class="small mt-3 text-center" id="payMsg" role="status"></div>
<p class="small wdw-muted text-center mt-3 mb-0">Payments are encrypted. You can cancel your subscription any time.</p>
</form>
</div>
<div class="col-lg-5">
<aside class="wdw-card p-4 align-self-start sticky-lg-top" style="top:1.5rem" aria-label="Order summary">
<div class="d-flex justify-content-between align-items-center">
<h2 class="wdw-eyebrow mb-0">Your order</h2>
<a href="#" class="small fw-semibold">Edit bag</a>
</div>
<ul class="list-unstyled mb-0 mt-2 border-bottom">
<li class="co-item py-3" data-item data-price="179">
<img class="co-thumb rounded-3" src="https://images.unsplash.com/photo-1553062407-98eeb64c6a62?w=160&h=160&fit=crop&q=70" width="64" height="64" alt="Navy canvas backpack" loading="lazy">
<div class="co-info"><div class="fw-semibold text-body-emphasis">Standard Bag</div><div class="small wdw-muted">1 week subscription</div></div>
<div class="co-price fw-bold text-end" data-line></div>
<div class="co-qty d-flex align-items-center gap-1" role="group" aria-label="Quantity for Standard Bag, 1 week subscription">
<button type="button" class="qty-btn" data-qty="-1" aria-label="Decrease quantity">−</button>
<output class="qty-val fw-semibold" data-q aria-live="polite">2</output>
<button type="button" class="qty-btn" data-qty="1" aria-label="Increase quantity">+</button>
</div>
</li>
<li class="co-item py-3" data-item data-price="179">
<img class="co-thumb rounded-3" src="https://images.unsplash.com/photo-1548036328-c9fa89d128fa?w=160&h=160&fit=crop&q=70" width="64" height="64" alt="Tan leather tote bag" loading="lazy">
<div class="co-info"><div class="fw-semibold text-body-emphasis">Standard Bag</div><div class="small wdw-muted">2 week subscription</div></div>
<div class="co-price fw-bold text-end" data-line></div>
<div class="co-qty d-flex align-items-center gap-1" role="group" aria-label="Quantity for Standard Bag, 2 week subscription">
<button type="button" class="qty-btn" data-qty="-1" aria-label="Decrease quantity">−</button>
<output class="qty-val fw-semibold" data-q aria-live="polite">1</output>
<button type="button" class="qty-btn" data-qty="1" aria-label="Increase quantity">+</button>
</div>
</li>
<li class="co-item py-3" data-item data-price="249">
<img class="co-thumb rounded-3" src="https://images.unsplash.com/photo-1584917865442-de89df76afd3?w=160&h=160&fit=crop&q=70" width="64" height="64" alt="Black structured handbag" loading="lazy">
<div class="co-info"><div class="fw-semibold text-body-emphasis">Premium Bag</div><div class="small wdw-muted">1 month subscription</div></div>
<div class="co-price fw-bold text-end" data-line></div>
<div class="co-qty d-flex align-items-center gap-1" role="group" aria-label="Quantity for Premium Bag, 1 month subscription">
<button type="button" class="qty-btn" data-qty="-1" aria-label="Decrease quantity">−</button>
<output class="qty-val fw-semibold" data-q aria-live="polite">1</output>
<button type="button" class="qty-btn" data-qty="1" aria-label="Increase quantity">+</button>
</div>
</li>
</ul>
<dl class="row gy-2 my-3 small">
<dt class="col-6 fw-normal wdw-muted">Subtotal</dt><dd class="col-6 text-end mb-0" data-sub></dd>
<dt class="col-6 fw-normal wdw-muted">Shipping</dt><dd class="col-6 text-end mb-0">Free</dd>
<dt class="col-6 fw-normal wdw-muted d-none" data-disc-row>Gift code</dt><dd class="col-6 text-end mb-0 text-success d-none" data-disc-row data-disc></dd>
<dt class="col-6 fs-5 text-body-emphasis">Total</dt><dd class="col-6 text-end mb-0 fs-5 fw-bold text-body-emphasis" data-total></dd>
</dl>
<form class="d-flex gap-2" id="giftForm">
<label class="visually-hidden" for="giftCode">Gift code</label>
<input class="form-control rounded-pill px-3" id="giftCode" placeholder="Gift code (try SAVE10)" autocomplete="off">
<button class="btn btn-primary rounded-pill px-4" type="submit">Apply</button>
</form>
<div class="small mt-2" id="giftMsg" role="status"></div>
<p class="small wdw-muted d-flex align-items-center gap-2 mt-4 mb-0 pt-3 border-top"><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" class="text-primary flex-shrink-0"><rect x="4" y="11" width="16" height="10" rx="3"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/></svg>Secure checkout. Free returns within 30 days.</p>
</aside>
</div>
</div>
</div>
</section>
/* Web Designer Wall library style — shared base for every Bootstrap 5 snippet.
Indigo accent, Plus Jakarta Sans, soft cards, pill buttons. Works in light and dark. */
@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap");
:root,
[data-bs-theme="light"] {
--wdw-font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
--bs-body-font-family: var(--wdw-font);
--bs-primary: #4f46e5;
--bs-primary-rgb: 79, 70, 229;
--bs-primary-text-emphasis: #3730a3;
--bs-primary-bg-subtle: #eef2ff;
--bs-primary-border-subtle: #c7d2fe;
--bs-link-color: #4f46e5;
--bs-link-color-rgb: 79, 70, 229;
--bs-link-hover-color: #4338ca;
--bs-link-hover-color-rgb: 67, 56, 202;
--bs-focus-ring-color: rgba(79, 70, 229, 0.25);
--bs-border-radius: 0.75rem;
--bs-border-radius-lg: 1rem;
--bs-border-radius-xl: 1.25rem;
--wdw-radius-card: 1.25rem;
--wdw-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 16px 40px -16px rgba(16, 24, 40, 0.22);
--wdw-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 12px -4px rgba(16, 24, 40, 0.12);
--wdw-stage: #f5f6fb;
}
[data-bs-theme="dark"] {
--bs-primary: #818cf8;
--bs-primary-rgb: 129, 140, 248;
--bs-primary-text-emphasis: #c7d2fe;
--bs-primary-bg-subtle: rgba(129, 140, 248, 0.14);
--bs-primary-border-subtle: rgba(129, 140, 248, 0.35);
--bs-link-color: #a5b4fc;
--bs-link-color-rgb: 165, 180, 252;
--bs-link-hover-color: #c7d2fe;
--bs-link-hover-color-rgb: 199, 210, 254;
--bs-focus-ring-color: rgba(129, 140, 248, 0.35);
--wdw-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -16px rgba(0, 0, 0, 0.7);
--wdw-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px -4px rgba(0, 0, 0, 0.5);
--wdw-stage: #0f1117;
}
body { font-family: var(--wdw-font); -webkit-font-smoothing: antialiased; }
/* Bootstrap compiles its blue into these components; point them at the accent. */
.btn-primary {
--bs-btn-bg: var(--bs-primary); --bs-btn-border-color: var(--bs-primary);
--bs-btn-hover-bg: #4338ca; --bs-btn-hover-border-color: #4338ca;
--bs-btn-active-bg: #3730a3; --bs-btn-active-border-color: #3730a3;
--bs-btn-disabled-bg: var(--bs-primary); --bs-btn-disabled-border-color: var(--bs-primary);
--bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #0f1117; --bs-btn-hover-bg: #a5b4fc; --bs-btn-hover-border-color: #a5b4fc; --bs-btn-hover-color: #0f1117; --bs-btn-active-color: #0f1117; }
.btn-outline-primary {
--bs-btn-color: var(--bs-primary); --bs-btn-border-color: var(--bs-primary);
--bs-btn-hover-bg: var(--bs-primary); --bs-btn-hover-border-color: var(--bs-primary);
--bs-btn-active-bg: var(--bs-primary); --bs-btn-active-border-color: var(--bs-primary);
--bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}
.btn { --bs-btn-font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; }
.btn-sm { min-height: 36px; }
.form-control, .form-select { min-height: 44px; border-radius: .75rem; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: rgba(var(--bs-primary-rgb), .6); box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.form-check-input:checked { background-color: var(--bs-primary); border-color: var(--bs-primary); }
.nav-pills { --bs-nav-pills-link-active-bg: var(--bs-primary); }
.nav { --bs-nav-link-color: var(--bs-secondary-color); --bs-nav-link-hover-color: var(--bs-emphasis-color); }
.pagination { --bs-pagination-active-bg: var(--bs-primary); --bs-pagination-active-border-color: var(--bs-primary); --bs-pagination-color: var(--bs-body-color); --bs-pagination-focus-box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.progress, .progress-stacked { --bs-progress-bar-bg: var(--bs-primary); }
.list-group { --bs-list-group-active-bg: var(--bs-primary); --bs-list-group-active-border-color: var(--bs-primary); }
.dropdown-menu { --bs-dropdown-link-active-bg: var(--bs-primary); border-radius: .875rem; box-shadow: var(--wdw-shadow-sm); }
.accordion { --bs-accordion-active-bg: var(--bs-primary-bg-subtle); --bs-accordion-active-color: var(--bs-primary-text-emphasis); --bs-accordion-btn-focus-box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.badge { font-weight: 600; }
/* Library building blocks — use these instead of re-inventing them per snippet. */
.wdw-stage { min-height: 100vh; display: flex; align-items: center; background: var(--wdw-stage); padding-block: 3rem; }
.wdw-card { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color-translucent); border-radius: var(--wdw-radius-card); box-shadow: var(--wdw-shadow); }
.wdw-card-sm { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color-translucent); border-radius: 1rem; box-shadow: var(--wdw-shadow-sm); }
.wdw-aurora { position: relative; color: #fff; background: radial-gradient(60% 55% at 100% 0, #818cf8 0, transparent 70%), radial-gradient(65% 60% at 0 100%, #ec4899 0, transparent 65%), #1e1b4b; }
.wdw-eyebrow { display: inline-block; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--bs-primary); }
.wdw-heading { font-weight: 800; letter-spacing: -.02em; color: var(--bs-emphasis-color); }
.wdw-muted { color: var(--bs-secondary-color); }
.wdw-icon { width: 2.75rem; height: 2.75rem; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: .875rem; background: var(--bs-primary-bg-subtle); color: var(--bs-primary); }
/* Component */
.breadcrumb { --bs-breadcrumb-divider: "›"; letter-spacing: .06em; }
#checkoutForm .form-control { min-height: 58px; }
.co-item { display: grid; grid-template-columns: 4rem 1fr auto; column-gap: 1rem; row-gap: .5rem; align-items: center; }
.co-item + .co-item { border-top: 1px solid var(--bs-border-color-translucent); }
.co-thumb { grid-row: 1 / span 2; width: 4rem; height: 4rem; object-fit: cover; align-self: start; }
.co-info { grid-column: 2; }
.co-price { grid-column: 3; grid-row: 1; min-width: 4.5rem; align-self: start; }
.co-qty { grid-column: 2 / span 2; grid-row: 2; justify-self: start; }
.qty-btn { width: 2.75rem; height: 2.75rem; padding: 0; border: 1px solid var(--bs-border-color); border-radius: 50%; background: var(--bs-body-bg); color: var(--bs-body-color); font-weight: 600; font-size: 1.1rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center; transition: background .15s, border-color .15s; }
.qty-btn:hover { background: var(--bs-tertiary-bg); color: var(--bs-emphasis-color); }
.qty-btn:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 2px; }
.qty-val { width: 2.25rem; text-align: center; font-variant-numeric: tabular-nums; }
function initCheckout() {
var items = document.querySelectorAll('[data-item]');
if (!items.length) return;
var discount = 0;
var fmt = function (n) { return n.toFixed(0) + ' SEK'; };
function render() {
var sub = 0;
items.forEach(function (li) {
var q = +li.querySelector('[data-q]').textContent, line = q * +li.dataset.price;
li.querySelector('[data-line]').textContent = fmt(line);
sub += line;
});
var off = Math.round(sub * discount), total = sub - off;
document.querySelector('[data-sub]').textContent = fmt(sub);
document.querySelector('[data-disc]').textContent = '−' + fmt(off);
document.querySelectorAll('[data-disc-row]').forEach(function (el) { el.classList.toggle('d-none', !discount); });
document.querySelector('[data-total]').textContent = fmt(total);
document.querySelector('[data-pay]').textContent = 'Pay ' + fmt(total);
}
document.querySelectorAll('[data-qty]').forEach(function (btn) {
btn.addEventListener('click', function () {
var el = btn.closest('[data-item]').querySelector('[data-q]');
el.value = el.textContent = Math.max(1, Math.min(9, +el.textContent + +btn.dataset.qty));
render();
});
});
var gift = document.getElementById('giftForm');
gift.addEventListener('submit', function (e) {
e.preventDefault();
var ok = document.getElementById('giftCode').value.trim().toUpperCase() === 'SAVE10', msg = document.getElementById('giftMsg');
discount = ok ? 0.1 : 0;
msg.textContent = ok ? '10% discount applied.' : 'That code is not valid.';
msg.className = 'small mt-2 ' + (ok ? 'text-success' : 'text-danger');
render();
});
var card = document.getElementById('coCard'), exp = document.getElementById('coExp');
card.addEventListener('input', function () { card.value = card.value.replace(/\D/g, '').slice(0, 16).replace(/(.{4})/g, '$1 ').trim(); });
exp.addEventListener('input', function () { var v = exp.value.replace(/\D/g, '').slice(0, 4); exp.value = v.length > 2 ? v.slice(0, 2) + '/' + v.slice(2) : v; });
var form = document.getElementById('checkoutForm'), payMsg = document.getElementById('payMsg');
form.addEventListener('submit', function (e) {
e.preventDefault();
form.classList.add('was-validated');
var ok = form.checkValidity();
payMsg.textContent = ok ? 'Thanks! This is a demo, so no payment was taken.' : 'Please fix the highlighted fields.';
payMsg.className = 'small mt-3 text-center ' + (ok ? 'text-success' : 'text-danger');
if (!ok) form.querySelector(':invalid').focus();
});
render();
}
initCheckout();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.