Endurance docs Theme Store ↗

Help

Custom code

Updated 20 Nov 2026Endurance 1.0.0Markdown

How to change code safely and keep your changes through updates.

Changing theme code isn't covered by support. An update copies your code edits only when they don't clash with the new version (see Update), so keep a copy of what you changed. Before you edit code, duplicate the theme (Online Store → Themes → … → Duplicate) and work on the copy. For larger changes, hire a Shopify Partner: shopify.com/partners/directory.

For small styling changes, prefer the Custom Liquid section and block, or Theme settings → Custom CSS, which carry over to new versions.

Theme settings → Custom CSS

Theme settings → Custom CSS

For developers: JavaScript events

The theme fires these events so apps and custom code can react without editing theme files. Listen with document.addEventListener('cart:updated', (event) => { … }).

EventFired onWhenevent.detail
cart:updateddocumentAfter any add, change or update through the theme, including the cart drawer, quick add and cart pageThe cart object from Shopify's Cart API (items, item_count, total_price and more)
cart:errordocumentWhen adding to the cart fails, for example when stock runs out{ button, message }: the add button and Shopify's error message
collection:updateddocumentAfter filtering, sorting, "Load more" or infinite scroll changes the products in a collection or search grid{ added }: how many products were added or are now shown
overlay:openthe drawer or dialog (bubbles)When a drawer, quick view, search or other overlay opensnone
overlay:closethe drawer or dialog (bubbles)When it closesnone
fit-profile:changeddocumentWhen a shopper saves their result in the fit finderThe saved profile, for example activity, support and summary
variant:changedocumentWhen the shopper picks another variant on a product page, a featured product or in quick view (not for the variant the page opened with){ variant, sectionId, productUrl }: the variant (id, price, available, sku, options and more, or null for a combination that doesn't exist)
product:variantthe product block (bubbles)Each time a product block settles on a variant, including when it first loads{ variant }
newsletter:subscribedthe sign-up form (bubbles)After a newsletter sign-up succeedsnone
endurance:readydocumentOnce the theme's script has run and window.Endurance (cart helpers below) is ready. Scripts loading later can check window.Endurance?.ready instead{ endurance }

Cart helpers

window.Endurance.cart uses the same requests as the theme, so the drawer, counters and rewards bar update for you:

If an app adds to the cart with its own request, call Endurance.cart.refresh() afterwards so the drawer and the cart count show the change.

Custom CSS

Theme settings → Custom CSS applies to the whole store, and each section has its own Custom CSS field at the bottom of its settings, which applies to that section only. Shopify limits how long these fields can be; for longer code, add a Custom Liquid section with a <style> tag. Custom CSS stays when you update the theme, but class names inside sections can change between versions, so prefer the variables below where you can.

The theme's look comes from CSS variables you can reuse or override:

VariableWhat it holds
--font-heading, --font-body, --font-labelThe three font families from Theme settings → Typography
--font-heading-weight, --font-body-weightTheir weights
--t-display, --t-h1 to --t-h4, --t-sub, --t-body, --t-small, --t-labelText sizes
--bg, --fg, --muted, --accent, --accent-fg, --surface, --lineColors of the current color scheme
--r-button, --r-card, --r-boxCorner radii
--page-width, --gutter, --section-gapPage width, side margin and the space between sections

For example, .section { --accent: #0b6e4f; } in a section's Custom CSS changes that section's accent color only.

Your own font

Theme settings offer Shopify's font library. To use a font you've bought or made yourself, you need a little code:

  1. Duplicate the theme and work on the copy.
  2. Upload the font files, preferably .woff2, in Content → Files and copy each file's link.
  3. In Theme settings → Custom CSS, add an @font-face rule for each weight you upload, then set the font on the parts you want, for example h1, h2, h3 { font-family: 'Your Font', sans-serif; }.

Upload only the weights you use, and check that your font license allows use on a website. If the font doesn't show, compare the font name in both rules (it must match exactly) and open the store in a private window.

Was this page helpful? No, ask support
Still stuck?

Send us a screenshot and your store link. We reply within two business days.

Contact support