Add ordering to an existing site
One script and a few HTML tags turn a restaurant's own menu page into an ordering page, and add table booking. No build step and no framework: they are Web Components in a Shadow DOM, so the site's styles and the widgets' never clash.
1. The script
Put it once on every page, before </body>. The restaurant copies the exact line, with its own address, location and language, from Website & widgets in the dashboard:
<script
src="https://beastie.taventi.app/widgets.js"
data-location="beastie-antwerp"
data-lang="nl"
defer
></script>| Setting | What it does |
|---|---|
data-location | The location's slug: which menu, cart and tables. |
data-lang | nl, fr or en. Without it, the page's own lang attribute, else Dutch. |
data-api-url | The API to use; https://api.taventi.app unless told otherwise. |
Any element can override these with an attribute of the same name (location, lang, api-url), e.g. two locations on one page.
2. The elements
| Element | What it shows | Attributes |
|---|---|---|
<taventi-add-to-cart> | An “Add” button for one dish on the site's own menu. Dishes with options open a dialog first; sold-out dishes say so. | product |
<taventi-cart-button> | A cart icon with the number of items, for the site's header. Opens the cart. | |
<taventi-cart> | The cart drawer: items and the total Taventi computes, checkout (pickup time, contact details, pay at pickup), then the order number and its live status. Added by the script when the page has “Add” buttons, so you rarely place it yourself. | no-floating |
<taventi-book-table> | Table booking: party size, date, the free times, the guest's details, then the booking's status. A floating button in the bottom-right corner by default. | inline |
<taventi-menu> | The whole menu, read-only, for sites without a menu page of their own. |
The product id of each dish, with its ready-made button, is in the dashboard's product editor (Menu → a dish → “On your website”).
<article class="dish">
<h3>Beastie Burger</h3>
<p>Double smashed beef, cheddar, pickles · €12.50</p>
<taventi-add-to-cart product="a12a23c5-0ac0-4d19-b660-405611336bd2"></taventi-add-to-cart>
</article>
<!-- In the header -->
<taventi-cart-button></taventi-cart-button>
<!-- Booking, as a floating button -->
<taventi-book-table></taventi-book-table>3. Your own buttons
The site can open the cart or the booking panel from its own buttons by sending an event on window:
// Open the cart drawer
window.dispatchEvent(new CustomEvent("taventi:open-cart"));
// Open table booking (with <taventi-book-table inline> or the floating button on the page)
window.dispatchEvent(new CustomEvent("taventi:open-booking"));
// React when the cart changes, e.g. to update your own badge
window.addEventListener("taventi:cart-changed", () => {
/* … */
});With your own cart button, add no-floating to a <taventi-cart> on the page to hide the floating “View order” button.
4. Matching the site's look
Set CSS custom properties on the elements (or on :root); they pass into the Shadow DOM:
taventi-add-to-cart,
taventi-cart,
taventi-cart-button,
taventi-book-table {
--taventi-accent: #e4572e; /* buttons */
--taventi-accent-text: #ffffff; /* text on buttons */
--taventi-font: "Inter", sans-serif;
--taventi-radius: 6px; /* 999px is a pill, 0 is square */
--taventi-text: #1a1a1a;
--taventi-muted: #6b6b6b;
--taventi-border: #e5e5e5;
--taventi-surface: #ffffff; /* panels and dialogs */
}Good to know
- The cart is kept in the guest's browser per location, so it survives a page change or reload.
- Buttons follow the live menu: sold-out dishes can't be added, and checkout only offers pickup times that are still free.
- When the restaurant pauses takeaway, or doesn't take bookings online, the widgets say so instead of taking orders.
- Pages that build their menu with JavaScript later work too.