Cart with quantities in WordPress
The full cart page: keyboard-editable quantities, undoable removal, promo code, free-delivery gauge and totals recalculated then announced.
Here is an excerpt of this component's code in WordPress. The full code is free for members, ready to copy into your project.
This component also comes in
The code in WordPress
<?php
/**
* Plugin Name: Forge, Panier avec quantités
* Description: La page panier complète : quantités modifiables au clavier, retrait annulable, code promo, jauge de livraison offerte et totaux recalculés puis annoncés. Ajoute la composition « Panier avec quantités » à l'éditeur de blocs.
* Version: 1.0.0
* Requires at least: 6.6
* Requires PHP: 8.1
* Author: Forge
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: forge-panier-quantites
*<!-- wp:html -->
<section class="pnq" aria-labelledby="pnq-title" data-pnq data-free-from="4900" data-shipping="590">
<div class="pnq__head">
<h2 class="pnq__title" id="pnq-title">Mon panier</h2>
<p class="pnq__count" data-pnq-count>4 articles</p>
</div>
<p class="pnq__sr" role="status" data-pnq-status></p>
<div class="pnq__wrap">
<div class="pnq__layout">
<div class="pnq__main">
<ul class="pnq__lines" aria-label="Articles du panier">
<li class="pnq__line" data-pnq-line data-name="Café en grains Éthiopie Sidamo" data-price="980" data-qty="2" data-max="10">(() => {
if (!document.querySelector(".pnq")) return;
const PNQ_CODES = {
BIENVENUE10: { label: "10 % de remise sur les articles", rate: 10 },
LIVRAISONOFFERTE: { label: "livraison offerte", freeShipping: true },
};
function pnqMoney(cents) {
return `${(cents / 100).toFixed(2).replace(".", ",")}\u00a0€`;
}
document.querySelectorAll("[data-pnq]").forEach((root) => {:root {
--pnq-text: #2a1a12;
--pnq-muted: #6b4f40;
--pnq-surface: #ffffff;
--pnq-panel: #fbf3ec;
--pnq-line: #e8d6c8;
--pnq-field: #8a6a58;
--pnq-accent: #a8401b;
--pnq-accent-hover: #8f3515;
--pnq-accent-text: #ffffff;
--pnq-strong: #2a1a12;
--pnq-strong-text: #ffffff;Free component: copy it freely, including for commercial projects.
Other e-commerce components in WordPress
E-commerce components in WordPress
A limited-time offer bar: countdown to a fixed date, one-click copyable promo code and a fallback message once the offer is over.
- Tailwind
- React
- CSS
- WordPress

A sales card showing the discount that grows with the cart amount (-10% from €50, -15% from €100…) with a progress bar towards the next tier.
- Tailwind
- React
- CSS
- WordPress

A Christmas gift guide filtered by budget and theme, with the number of ideas announced and an empty state offering to show everything again.
- Tailwind
- React
- CSS
- WordPress

The last order dates for delivery before Christmas, per shipping method, with the days left worked out from the visitor’s date.
- Tailwind
- React
- CSS
- WordPress

A cart that shows live how much is left to add for free shipping, with a progress bar and recalculated totals.
- Tailwind
- React
- CSS
- WordPress

A colour and size picker for a product page: the visual, price and stock follow the choice, and sold-out sizes are disabled.
- Tailwind
- React
- CSS
- WordPress