Skip to content

Price table with options in WordPress

A price table by service: one package to pick, options to tick, and the total with the estimated time recalculated on every click.

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 -->
<form class="ttp" data-ttp aria-labelledby="ttp-titre">
        <p class="ttp-eyebrow">Éclat Auto · Angers</p>
        <h2 class="ttp-title" id="ttp-titre">Composez votre lavage</h2>
        <p class="ttp-lead">Choisissez une formule, ajoutez les options utiles : le prix et la durée se calculent aussitôt.</p>
        <fieldset class="ttp-set">
          <legend class="ttp-legend">1. La formule</legend>
          <table class="ttp-table">
            <caption class="ttp-caption">Formules de lavage, une seule au choix</caption>
            <thead>
              <tr>
                <th class="ttp-head" scope="col">Prestation</th>
script.js
(() => {
  if (!document.querySelector(".ttp")) return;
  document.querySelectorAll("[data-ttp]").forEach((root) => {
    const on = (el, type, fn) => el.addEventListener(type, fn);
    const form = root;
    const total = root.querySelector("[data-ttp-total]");
    const euros = (cents) =>
      cents % 100 ? `${Math.floor(cents / 100)},${String(cents % 100).padStart(2, "0")} €` : `${cents / 100} €`;
    const minutes = (m) =>
      m < 60 ? `${m} min` : m % 60 ? `${Math.floor(m / 60)} h ${String(m % 60).padStart(2, "0")}` : `${m / 60} h`;

    const apply = () => {
style.css
:root {
  --ttp-card: #ffffff;
  --ttp-text: #14213d;
  --ttp-muted: #4b5675;
  --ttp-line: #dbe1ee;
  --ttp-soft: #f2f5fb;
  --ttp-accent: #1d4ed8;
  --ttp-accent-text: #ffffff;
  --ttp-row: #eaf0fe;
  --demo-tableau-tarifs-prestations-options-bg: #e9edf5;
  --demo-tableau-tarifs-prestations-options-text: #14213d;
}
tableau-tarifs-prestations-options.php
<?php
/**
 * Plugin Name: Forge, Tableau de tarifs avec options
 * Description: Un tableau de tarifs par prestation : une formule au choix, des options cochables, et le total avec la durée estimée recalculés à chaque clic. Ajoute la composition « Tableau de tarifs avec options » à 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-tableau-tarifs-prestations-options
 *

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

Data tables components in WordPress
  • A documentation table showing where a kit or component has been tested (static HTML, WordPress, Elementor, Webflow, v0…), with status, last test date and a remark, filterable by status.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A table of the towns and postcodes a tradesperson covers, with response time and travel fee, filtered by search and by zone.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A timetable table sorted by column and filtered with level and free-place chips, whose rows each become a card on phones.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A filterable table whose visible rows export in one click to a CSV file that opens cleanly in Excel or LibreOffice.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A product spec sheet as two-column tables in native collapsible sections, with a button to open or close them all.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • The results of a race or competition, sortable by place, name or category, with the podium highlighted, the gap to the winner and the sort order announced.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component