Skip to content

Cart promo code

A promo code field that checks the code, explains a refusal (unknown, minimum spend) and recalculates discount, shipping and total.

  • Tailwind
  • React
  • CSS
  • WordPress
Open in a new tab

Description

In the order summary, the customer types their code; three kinds are handled: percentage off items, fixed amount with minimum spend, free shipping. Input is forgiving (lower case, spaces) and each refusal is explained precisely: unknown or expired code, or the amount missing to reach the minimum (“€16.00 to go”), with aria-invalid, focus back on the field and a message read through aria-live. An accepted code becomes a tag with a “Remove” button; the Discount line appears, shipping turns “Free” where relevant and the total is recalculated, in French format. Focus follows the action: on “Remove” after applying, on the field after removal. Codes are described in JSON in an attribute: in a real shop the final check happens server-side and this component is the interface. 44 px buttons, AA contrast in light and dark mode, no overflow at 360 px.

Code

Loading the code…

The code of this component in

Archive contents

code-promo-panier-html-tailwind.zip3 files · 5 Ko

  • index.html7 Ko
  • README.md4 Ko
  • LICENSE.md1 Ko

Tags

Updated on December 2, 2026.

Reviews

No reviews yet.

In the same spirit

  • 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