Skip to content

Seasonal offer card in WordPress

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.

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-promotion-saisonniere.php
<?php
/**
 * Plugin Name: Forge, Carte d’offre saisonnière
 * Description: Une carte de promotion saisonnière avec prix barré et remise, qui annonce d’elle-même si l’offre est à venir, combien de jours il reste ou qu’elle est terminée. Ajoute la composition « Carte d’offre saisonnière » à 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-promotion-saisonniere
 *
pattern.html
<!-- wp:html -->
<article class="cop" data-cop data-cop-start="2026-11-23" data-cop-end="2026-12-31" aria-labelledby="cop-titre">
        <div class="cop-visual" aria-hidden="true"><span class="cop-percent">−20 %</span></div>
        <div class="cop-body">
          <p class="cop-badge" data-cop-badge>Du 23 novembre au 31 décembre</p>
          <h2 class="cop-title" id="cop-titre">Coffret « Thés de l’Avent »</h2>
          <p class="cop-text">24 sachets de thés et infusions bio à découvrir chaque matin de décembre : chaï aux épices, rooibos vanille, thé vert au yuzu…</p>
          <p class="cop-prices">
            <span class="cop-now" data-cop-now><span class="cop-sr">Prix de l’offre : </span>39 €</span>
            <del class="cop-was" data-cop-was><span class="cop-sr">Prix habituel : </span>49 €</del>
            <span class="cop-now" data-cop-regular hidden>49 €</span>
          </p>
script.js
(() => {
  if (!document.querySelector(".cop")) return;
  document.querySelectorAll("[data-cop]").forEach((root) => {
    const on = (el, type, fn) => el.addEventListener(type, fn);
    const now = new Date();
    const parse = (iso) => {
      const [y, m, d] = iso.split("-").map(Number);
      return new Date(y, m - 1, d);
    };
    const start = parse(root.dataset.copStart);
    const end = parse(root.dataset.copEnd);
    const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
style.css
:root {
  --cop-card: #ffffff;
  --cop-text: #22191f;
  --cop-muted: #5a4d55;
  --cop-accent: #9d174d;
  --cop-accent-text: #ffffff;
  --cop-soft: #fdf2f6;
  --cop-visual: linear-gradient(135deg, #831843, #be185d 55%, #f59e0b);
  --demo-carte-offre-promotion-saisonniere-bg: #f4ecf0;
  --demo-carte-offre-promotion-saisonniere-text: #22191f;
}

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

Cards components 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.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • 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 24-door Advent calendar where each surprise only opens from its day in December, with opened doors remembered.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component