Skip to content

Black Friday bar with promo code 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.

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

bandeau-black-friday-compte-a-rebours.php
<?php
/**
 * Plugin Name: Forge, Bandeau Black Friday avec code promo
 * Description: Un bandeau d’offre à durée limitée : compte à rebours jusqu’à une date fixe, code promo copiable en un clic et message de repli une fois l’offre terminée. Ajoute la composition « Bandeau Black Friday avec code promo » à 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-bandeau-black-friday-compte-a-rebours
 *
pattern.html
<!-- wp:html -->
<div class="bfcr" role="region" aria-label="Offre Black Friday" lang="fr" data-bfcr data-bfcr-end="2026-11-30T23:59:59+01:00">
        <div class="bfcr__inner">
          <div class="bfcr__live" data-bfcr-live>
            <p class="bfcr__offer"><svg class="bfcr__icon" viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3.5 12.6V4.5a1 1 0 0 1 1-1h8.1l7.9 7.9a1.4 1.4 0 0 1 0 2l-6.1 6.1a1.4 1.4 0 0 1-2 0Z"/><circle cx="8.2" cy="8.2" r="1.4"/></svg><span><span class="bfcr__badge">Black Friday</span> <strong>−30 % sur tout le site</strong> jusqu’au <time datetime="2026-11-30T23:59:59+01:00">lundi 30 novembre à 23 h 59</time>. <a class="bfcr__link" href="#conditions-offre">Voir les conditions</a></span></p>
            <div class="bfcr__timer" role="timer" data-bfcr-timer hidden>
              <span class="bfcr__tlab" aria-hidden="true">Fin dans</span>
              <span class="bfcr__units" aria-hidden="true">
                <span class="bfcr__unit"><span class="bfcr__num" data-bfcr-d>0</span><span class="bfcr__ulab">j</span></span>
                <span class="bfcr__unit"><span class="bfcr__num" data-bfcr-h>00</span><span class="bfcr__ulab">h</span></span>
                <span class="bfcr__unit"><span class="bfcr__num" data-bfcr-m>00</span><span class="bfcr__ulab">min</span></span>
                <span class="bfcr__unit bfcr__unit--s"><span class="bfcr__num" data-bfcr-s>00</span><span class="bfcr__ulab">s</span></span>
script.js
(() => {
  if (!document.querySelector(".bfcr")) return;
  document.querySelectorAll("[data-bfcr]").forEach((root) => {
    const end = new Date(root.dataset.bfcrEnd).getTime();
    const live = root.querySelector("[data-bfcr-live]");
    const over = root.querySelector("[data-bfcr-expired]");
    const timer = root.querySelector("[data-bfcr-timer]");
    const sr = root.querySelector("[data-bfcr-sr]");
    const copy = root.querySelector("[data-bfcr-copy]");
    const label = root.querySelector("[data-bfcr-copy-label]");
    const code = root.querySelector("[data-bfcr-code]");
    const status = root.querySelector("[data-bfcr-status]");
style.css
:root {
  --bfcr-bg: #111111;
  --bfcr-text: #ffffff;
  --bfcr-muted: #d6d3d1;
  --bfcr-line: #111111;
  --bfcr-accent: #ffcf4a;
  --bfcr-accent-hover: #ffe08a;
  --bfcr-on-accent: #111111;
  --bfcr-cell: rgb(255 255 255 / 0.12);
  --bfcr-page-muted: #57534e;
  --demo-bandeau-black-friday-compte-a-rebours-bg: #faf7f2;
  --demo-bandeau-black-friday-compte-a-rebours-text: #1c1917;

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

E-commerce components in 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
    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
  • A wishlist for an online shop: add from product cards, a summary with total and removal, remembered in the browser.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component