Skip to content

Order summary in WordPress

The cart summary before checkout: items with thumbnail and quantity, a free-shipping gauge, a promo code and a total recalculated on every change.

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

Open in a new tab

The code in WordPress

pattern.html
<!-- wp:html -->
<section class="recap" aria-labelledby="recap-title" data-recap data-free-from="4000" data-shipping="490">
        <h2 class="recap__title" id="recap-title" tabindex="-1" data-recap-heading>Votre commande</h2>
        <p class="recap__sr" role="status" data-recap-status></p>
        <p class="recap__empty" data-recap-empty hidden>Votre panier est vide. <a class="recap__link" href="#boutique">Retourner à la boutique</a></p>
        <div class="recap__body" data-recap-body>
          <ul class="recap__items">
            <li class="recap__item" data-price="650" data-qty="2">
              <span class="recap__thumb recap__thumb--lavande" aria-hidden="true"><span class="recap__qty">2</span></span>
              <span class="recap__info">
                <strong data-name>Savon surgras lavande</strong>
                <span class="recap__meta">Pain de 100 g · 2 × 6,50 €</span>
recapitulatif-commande.php
<?php
/**
 * Plugin Name: Forge, Récapitulatif de commande
 * Description: Le résumé du panier avant paiement : articles avec vignette et quantité, jauge de livraison offerte, code promo et total recalculé à chaque changement. Ajoute la composition « Récapitulatif de commande » à 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-recapitulatif-commande
 *
script.js
(() => {
  if (!document.querySelector(".recap")) return;
  document.querySelectorAll("[data-recap]").forEach((recap) => {
    const euros = new Intl.NumberFormat("fr-FR", { style: "currency", currency: "EUR" });
    const format = (cents) => euros.format(cents / 100);
    const freeFrom = Number(recap.dataset.freeFrom);
    const shippingCost = Number(recap.dataset.shipping);
    const form = recap.querySelector("[data-promo]");
    const message = recap.querySelector("[data-promo-message]");
    const status = recap.querySelector("[data-recap-status]");
    let rate = 0;
style.css
:root {
  --recap-text: #3a0d24;
  --recap-muted: #7a4560;
  --recap-card: #ffffff;
  --recap-soft: #fdf2f7;
  --recap-line: #f3d5e3;
  --recap-field: #d9a9c0;
  --recap-accent: #be185d;
  --recap-accent-hover: #9d174d;
  --recap-accent-text: #ffffff;
  --recap-ring: #831843;
  --recap-ok: #15803d;

Free component: copy it freely, including for commercial projects.

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
    Component
  • 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
    Component
  • 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
    Component
  • 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
    Component
  • 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
    Component
  • 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
    Component