Bootstrap 5 Shopping Cart Checkout with Payment Options
A shopping bag with quantity steppers and a live order summary, a selectable payment method and a card details form.
<section class="wdw-stage">
<div class="container" style="max-width:1040px">
<div class="mb-4"><span class="wdw-eyebrow">Checkout</span><h1 class="wdw-heading h3 mt-1 mb-0">Shopping bag</h1></div>
<div class="row g-4 checkout">
<div class="col-lg-7">
<div class="wdw-card p-3 p-sm-4">
<ul class="list-unstyled mb-0 cart-items">
<li class="cart-item d-flex align-items-center gap-3 py-3" data-price="9.99">
<img src="https://images.unsplash.com/photo-1544947950-fa07a98d237f?w=200&q=70" alt="Book cover" class="cart-img" width="64" height="88">
<div class="flex-grow-1">
<h2 class="h6 fw-bold mb-0">Thinking, Fast and Slow</h2>
<p class="small wdw-muted mb-0">Daniel Kahneman · <span class="badge bg-body-secondary text-body-secondary">Digital</span></p>
</div>
<div class="d-flex flex-column align-items-end gap-2">
<strong class="item-total">$9.99</strong>
<div class="qty btn-group" role="group" aria-label="Quantity">
<button type="button" class="btn btn-outline-secondary qty-minus" aria-label="Decrease quantity">−</button>
<output class="qty-val" aria-live="polite">1</output>
<button type="button" class="btn btn-outline-secondary qty-plus" aria-label="Increase quantity">+</button>
</div>
</div>
</li>
<li class="cart-item d-flex align-items-center gap-3 py-3 border-top" data-price="13.50">
<img src="https://images.unsplash.com/photo-1512820790803-83ca734da794?w=200&q=70" alt="Book cover" class="cart-img" width="64" height="88">
<div class="flex-grow-1">
<h2 class="h6 fw-bold mb-0">Homo Deus</h2>
<p class="small wdw-muted mb-0">Yuval Noah Harari · <span class="badge bg-body-secondary text-body-secondary">Paperback</span></p>
</div>
<div class="d-flex flex-column align-items-end gap-2">
<strong class="item-total">$13.50</strong>
<div class="qty btn-group" role="group" aria-label="Quantity">
<button type="button" class="btn btn-outline-secondary qty-minus" aria-label="Decrease quantity">−</button>
<output class="qty-val" aria-live="polite">1</output>
<button type="button" class="btn btn-outline-secondary qty-plus" aria-label="Increase quantity">+</button>
</div>
</div>
</li>
</ul>
<hr class="my-2">
<h2 class="h6 fw-bold mt-3 mb-3">Payment method</h2>
<div class="row g-2 pay-options" role="radiogroup" aria-label="Payment method">
<div class="col-4"><input type="radio" class="btn-check" name="pay" id="pay-credit" checked><label class="pay-opt" for="pay-credit"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2" y="5" width="20" height="14" rx="2.5"/><path d="M2 10h20"/></svg>Credit card</label></div>
<div class="col-4"><input type="radio" class="btn-check" name="pay" id="pay-debit"><label class="pay-opt" for="pay-debit"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2" y="5" width="20" height="14" rx="2.5"/><path d="M6 15h4"/></svg>Debit card</label></div>
<div class="col-4"><input type="radio" class="btn-check" name="pay" id="pay-paypal"><label class="pay-opt" for="pay-paypal"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 7a2 2 0 0 1 2-2h13v4"/><path d="M3 7v11a2 2 0 0 0 2 2h14a1 1 0 0 0 1-1v-9a1 1 0 0 0-1-1H5a2 2 0 0 1-2-2z"/><circle cx="16" cy="14.5" r="1"/></svg>Wallet</label></div>
</div>
<form class="row g-3 mt-1" id="card-form" onsubmit="return false">
<div class="col-sm-6"><label for="cname" class="form-label small fw-semibold">Name on card</label><input type="text" id="cname" class="form-control" placeholder="Jane Doe" autocomplete="cc-name"></div>
<div class="col-sm-6"><label for="cnum" class="form-label small fw-semibold">Card number</label><input type="text" id="cnum" class="form-control" placeholder="1111 2222 3333 4444" inputmode="numeric" autocomplete="cc-number"></div>
<div class="col-6"><label for="exp" class="form-label small fw-semibold">Expiry</label><input type="text" id="exp" class="form-control" placeholder="MM/YY" autocomplete="cc-exp"></div>
<div class="col-6"><label for="cvv" class="form-label small fw-semibold">CVV</label><input type="text" id="cvv" class="form-control" placeholder="123" inputmode="numeric" autocomplete="cc-csc"></div>
</form>
</div>
</div>
<div class="col-lg-5">
<aside class="wdw-card summary p-4 p-sm-4 d-flex flex-column">
<h2 class="h6 fw-bold mb-3">Order summary</h2>
<dl class="d-flex flex-column gap-2 mb-3">
<div class="d-flex justify-content-between"><dt class="fw-normal wdw-muted">Subtotal</dt><dd class="mb-0 fw-semibold" id="sum-sub">$23.49</dd></div>
<div class="d-flex justify-content-between"><dt class="fw-normal wdw-muted">Shipping</dt><dd class="mb-0 fw-semibold" id="sum-ship">$2.99</dd></div>
<div class="d-flex justify-content-between"><dt class="fw-normal wdw-muted">Tax</dt><dd class="mb-0 fw-semibold" id="sum-tax">$0.00</dd></div>
</dl>
<div class="d-flex justify-content-between align-items-center border-top pt-3 mb-4"><span class="fw-bold">Total</span><span class="h4 fw-bold mb-0" id="sum-total">$26.48</span></div>
<button type="button" class="btn btn-primary rounded-pill btn-lg mt-2">Pay <span id="pay-amt">$26.48</span></button>
<p class="small wdw-muted text-center mt-3 mb-0">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 */
.checkout .cart-img{flex:none;width:64px;height:88px;object-fit:cover;border-radius:.5rem;box-shadow:var(--wdw-shadow-sm)}
.checkout .qty{--bs-btn-padding-x:.5rem;border-radius:999px}
.checkout .qty .btn{min-height:32px;width:32px;padding:0;border-color:var(--bs-border-color);border-radius:999px!important;margin:0!important}
.checkout .qty-val{min-width:2rem;text-align:center;font-weight:600;line-height:32px}
.checkout .pay-opt{display:flex;flex-direction:column;align-items:center;gap:.4rem;padding:.9rem .5rem;border:1.5px solid var(--bs-border-color);border-radius:.9rem;font-size:.8125rem;font-weight:600;color:var(--bs-secondary-color);cursor:pointer;text-align:center;transition:.15s;height:100%}
.checkout .pay-opt:hover{border-color:var(--bs-primary-border-subtle);color:var(--bs-body-color)}
.checkout .btn-check:checked+.pay-opt{border-color:var(--bs-primary);background:var(--bs-primary-bg-subtle);color:var(--bs-primary-text-emphasis)}
.checkout .btn-check:focus-visible+.pay-opt{outline:3px solid var(--bs-focus-ring-color);outline-offset:2px}
.checkout .summary dt,.checkout .summary dd{margin:0}
(function initCheckout() {
var root = document.querySelector('.checkout');
if (!root) return;
var money = function (n) { return '$' + n.toFixed(2); };
var SHIP = 2.99, TAX = 0;
function update() {
var sub = 0;
root.querySelectorAll('.cart-item').forEach(function (it) {
var q = parseInt(it.querySelector('.qty-val').textContent, 10);
var t = q * parseFloat(it.dataset.price);
it.querySelector('.item-total').textContent = money(t);
sub += t;
});
var ship = sub ? SHIP : 0, total = sub + ship + TAX;
root.querySelector('#sum-sub').textContent = money(sub);
root.querySelector('#sum-ship').textContent = money(ship);
root.querySelector('#sum-tax').textContent = money(TAX);
root.querySelector('#sum-total').textContent = money(total);
root.querySelector('#pay-amt').textContent = money(total);
}
root.addEventListener('click', function (e) {
var btn = e.target.closest('.qty-plus, .qty-minus');
if (!btn) return;
var out = btn.closest('.qty').querySelector('.qty-val');
var n = parseInt(out.textContent, 10) + (btn.classList.contains('qty-plus') ? 1 : -1);
out.textContent = Math.min(Math.max(n, 1), 99);
update();
});
var card = root.querySelector('#card-form');
root.querySelectorAll('input[name="pay"]').forEach(function (r) {
r.addEventListener('change', function () { card.classList.toggle('d-none', r.id === 'pay-paypal'); });
});
update();
})();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.