Adding a cart to your page
In the page builder you can add:- Cart – A single cart block (list of items + total + checkout).
- Cart Dropdown – A “Cart” trigger (e.g. with item count) that opens a dropdown panel with the same cart inside. Handy in headers or sidebars.
Where to find them
- Open the Elements or Blocks panel.
- In the Cart category, choose Cart or Cart Dropdown.
- Drag the block onto your page where you want it (e.g. below the fold for Cart, in the top bar for Cart Dropdown).
- A row per item (name, quantity controls, unit price, line total).
- A footer with Total and a Checkout link.
What visitors see
- Item name – From your product/offer (e.g. “1 Bottle”).
- Item image – Product thumbnail (if the product has one).
- Quantity – Current quantity with − and + to decrease or increase.
- Unit price – Price per unit (e.g. “$69.00”).
- Line total – Price × quantity for that item (e.g. “$552.00”).
- Cart total – Sum of all line totals, shown in the footer (e.g. “Total: $552.00”).
- Checkout – Link to continue to checkout.
Customizing the cart layout
The cart is built from a template: you can change text, order of fields, and styling in the builder.Cart-level variables
These apply to the cart as a whole:Per-item row variables
Inside atemplate-foreach loop, each item exposes:
item.price and item.total are already formatted. Use them as-is. See Frontend Template Engine — Cart for the full data attributes reference.bonuses, courses, is_subscription, and subscription are populated after a brief async fetch when the cart loads. They are always present so templates never error on an undefined value.Subscription info
Whenitem.is_subscription is true, item.subscription contains:
[[ checkout.is_subscription ]] and [[ checkout.subscription.frequency ]] etc.
Bonus products
Products can have bonus items attached — free gifts or complementary products included with the purchase (configured in the product catalog). They are available asitem.bonuses — always an array, empty when no bonuses are configured.
Each bonus has: code, name, image, price, retail_price, original_price, currency.
Courses
When a product has linked courses (e.g. digital bonuses delivered via the course platform), they are available asitem.courses — always an array, empty when no courses are linked.
Each course has: id, title, slug, description, cover, instructor_name, status.
[[ ]] placeholder syntax and the ef-text binding attribute are supported. They are equivalent — use whichever fits your template:
Quantity controls
The cart plugin handles −, +, and Remove automatically via data attributes. No custom script is needed.
On checkout pages the minus button is always disabled at quantity 1, regardless of
data-disable-when-one.
Cart dropdown
The Cart Dropdown block gives you:- A trigger (e.g. “Cart” plus the number of items) that visitors click to open the cart.
- A panel that opens below (or in a suitable position) with the full cart inside: same items, quantities, totals, and checkout link.
[[ efCart.count ]].
Use it when you want the cart in a fixed spot (e.g. header) without taking space until the visitor opens it.
Checkout link
The cart plugin automatically resolves the checkout URL from your merchant settings and wires it to any element with the class.ef-cart-checkout or the attribute data-ef-cart-checkout. You do not need to hard-code the checkout URL in the builder.
The resolved URL is built as follows (in priority order):
- The element’s own
hrefattribute (if it is a real path, not#or#checkout). - A
data-ef-cart-checkout-hrefattribute on the element. - The checkout page configured in your merchant settings (injected as
window.efScope.checkout_url). - Falls back to
/checkoutif nothing else resolves.
The default Checkout button added by the builder already has
.ef-cart-checkout. You only need to set a custom href if you want to override the merchant-configured checkout page.Cart storage
The cart is stored in a browser cookie (ef_cart_{brandId}), not localStorage. Cookies persist for 365 days, so the cart survives navigation and browser restarts within the same browser.
The cart is shared across all pages on the same domain, so the Cart Dropdown in the header and a full Cart block below the fold always show the same contents.
JavaScript API
The cart plugin exposes awindow.ef object you can call from custom scripts or @click handlers in your templates:
Example — add to cart on button click:
cart-updated event
Every time the cart changes (add, remove, set quantity), the plugin dispatches a cart-updated custom event on window. You can listen to it to react to cart mutations in custom scripts:
detail contains { brandId, cart } where cart is the updated array.
Add-to-cart buttons
Buttons that add products to the cart usedata-ef-add-to-cart (or class .ef-add-to-cart) together with data-product-code. These attributes also let the plugin read the price without an extra API request:
When these attributes are present, adding to cart stores the price locally, so
item.price and item.total are available immediately without waiting for the /api/cart-products response.
Tips
- Placement – Put the cart or cart dropdown where visitors expect it (e.g. top-right for dropdown, above the fold for a full cart block).
- Sticky / mobile – You can place the cart in a sticky bar or in a mobile menu; the same block works anywhere.
- Multiple carts – You can add more than one cart or dropdown on a page; they all show the same cart data and stay in sync when the visitor changes quantity or adds items.
- Item count badge – Use
[[ efCart.count ]]anywhere on the page (e.g. in the header next to “Cart”) to show the total number of items in the cart. - Savings display – Show
[[ efCart.discount_total ]]in the cart footer or[[ item.retail_price ]]beside the unit price to highlight discounts when a retail price is set. - Subscription label – Use
[[ item.is_subscription ]]withtemplate-ifto show billing cadence (e.g. “Every 3 months”) only for subscription products. - Bonuses & courses – Use nested
template-foreachonitem.bonusesanditem.coursesto list included free products or digital courses beneath each cart line.