Skip to content

All-access offer card with places left in WordPress

A single-plan pricing card: struck-through price and discount, a places-left gauge driven by a data attribute, the list of everything included and a booking button that turns into a waiting list once sold out.

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

carte-offre-acces-total-rarete.php
<?php
/**
 * Plugin Name: Forge, Carte offre accès total avec places restantes
 * Description: Une carte de tarification à formule unique : prix barré et remise, jauge des places restantes pilotée par un attribut data-, liste de tout ce qui est inclus et bouton de réservation qui devient liste d'attente quand c'est complet. Ajoute la composition « Carte offre accès total avec places restantes » à 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-carte-offre-acces-total-rarete
 *
pattern.html
<!-- wp:html -->
<article class="coa" aria-labelledby="coa-titre" data-coa data-coa-total="24" data-coa-left="7" data-coa-state="open">
        <p class="coa__eyebrow">Saison 2027, de janvier à décembre</p>
        <h2 class="coa__title" id="coa-titre">Pass accès total à l'atelier</h2>
        <p class="coa__intro">Atelier Terre &amp; Feu, à Nantes. Une seule formule pour toute l'année : les cours, la terre, les cuissons et l'atelier en accès libre.</p>
        <div class="coa__price">
          <p class="coa__now"><span class="coa__amount">1 290 €</span> <span class="coa__period">pour la saison</span></p>
          <p class="coa__was">Au lieu de <s class="coa__strike">1 620 €</s> <span class="coa__badge">−20 %</span></p>
        </div>
        <div class="coa__stock">
          <p class="coa__count" aria-live="polite" data-coa-count><strong class="coa__left" data-coa-left-text>7 places restantes</strong><span data-coa-of> sur 24</span></p>
          <div class="coa__gauge" aria-hidden="true"><span class="coa__fill" style="--coa-fill: 0.7083" data-coa-fill></span></div>
script.js
(() => {
  if (!document.querySelector(".coa")) return;
  (() => {
    const NB = "\u00a0";
    const whole = (value, fallback) => {
      const number = Math.floor(Number(value));
      return value === undefined || value === "" || !Number.isFinite(number) ? fallback : number;
    };

    document.querySelectorAll("[data-coa]").forEach((root) => {
      const leftText = root.querySelector("[data-coa-left-text]");
      const ofText = root.querySelector("[data-coa-of]");
style.css
:root {
  --coa-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --coa-page: #f4f1ea;
  --coa-bg: #ffffff;
  --coa-text: #1f1b16;
  --coa-muted: #575047;
  --coa-edge: #ddd5c7;
  --coa-accent: #9a3412;
  --coa-on-accent: #ffffff;
  --coa-track: #ebe4d8;
  --coa-low: #b4231b;
  --coa-badge: #fde68a;

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

Cards components in WordPress
  • Three treatment cards in accessible neumorphism: gently raised surfaces, buttons that sink in when activated, a light/dark switch for the block itself. 3:1 outlines and AA text kept.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Four fully clickable workshop cards in a neo-brutalist style: thick border, solid offset shadow and a card that sinks onto its shadow on hover or focus. Pastel tones, dark mode, no JavaScript.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Three brutalist service cards: one-pixel border, hard offset shadow that lifts on hover and sinks on click, large type, accent and dark variants. No JavaScript.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A mobile page to link from your social profiles: portrait, name, priority links (booking, WhatsApp, website, reviews, call), opening hours with an open or closed status, social links and a share button, in dependency-free HTML and CSS.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A seasonal promotion card with a struck-through price and discount that announces by itself whether the offer is coming, how many days are left or that it is over.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A 24-door Advent calendar where each surprise only opens from its day in December, with opened doors remembered.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component