doc-site
Reference

Theme globals

Every window.theme key, what writes it, and what reads it.

Theme globals

Liquid hands data to JavaScript through window.theme. Every key is declared in the theme interface in src/@types/global.ts, which is the authoritative list.

A key is only present on pages where the Liquid that writes it rendered. Treat every read as possibly undefined.

const config = window.theme?.medispaCalendarConfig;
if (!config) return;

Regenerate this page

sed -n '/^    theme: {/,/^    };/p' src/@types/global.ts

Feature configuration

KeyWritten byRead by
medispaCalendarConfigsnippets/medispa-calendar-config.liquidThe React booking calendar
cartRewardBannerlayout/theme.liquidsrc/entrypoints/cart-reward-banner.ts, src/entrypoints/homepage-prominence-banner.ts
popupManagerConfigsnippets/popup-logic.liquidThe popup manager
needHelpPopupsections/need-help-popup.liquidneed-help-popup definition
packOptionssnippets/pack-options-config.liquidsrc/entrypoints/pack-options.ts
selectOptionsModalConfigsections/select-options-modal.liquidsrc/entrypoints/select-options-modal.ts
plpSegmentationTilessections/plp-segmentation-tiles.liquidThe segmentation tiles entrypoint

The layout writes cartRewardBanner, so it is present on every page. cartTotal is in dollars, computed in Liquid as the sum of final_price times quantity across lines without the __free_gift property, divided by 100. rewardTiers comes from the four tiers in the Rewards Tiers settings group, skipping any tier with an empty title.

cartRewardBanner.instance holds either a CartRewardBanner or a HomepageProminenceBanner, depending on which entrypoint ran for the current template. The two are separate classes with the same purpose, so check the type before calling anything on it.

src/entrypoints/cart-reward-banner.ts converts cartTotal a second time. See the known discrepancy in Legacy and unused code.

Labels and formatting

KeyContents
moneyFormat, moneyWithCurrencyFormatShopify money format strings
labels.addToCartAdd to cart button text
labels.preorderPre-order button text
labels.product_gift_skip_cta_labelSkip label in the gift promotion modal
labels.klaviyo.trigger.button_labelKlaviyo trigger button text
labels.medispa.remainingAmountLineItemLabelBalance owing label on a booking line
labels.medispa.remainingAmountLineItemValueTemplateTemplate for that balance
labels.medispa.depositAmountDefault deposit

Money values from theme settings are in dollars. Money values from Shopify are in cents. Convert once, at the point of display. src/entrypoints/utils.ts provides formatMoney, shopifyFormatCurrency and formatCentsInMoneyTemplate.

Page context

KeyContents
pageTypeCurrent template type
productImageSizeConfigured product image size
searchModeSearch behaviour setting
showPageTransition, showElementStaggering, showImageZoomingAnimation switches

Other globals the theme sets

These sit on window directly rather than under window.theme.

GlobalPurpose
window.defer(fn, selector)Run fn once selector matches, polling every 50 ms
window.deferJS(fn, validator)Run fn once validator() is true, polling every 50 ms
window.enableLogging(value), window.disableLogging()Debug logging switches
window.popupMonitorThe popup manager instance
window.popupTimerThe popup interval timer
window.klaviyoSniffer, window.customSnifferPopup detection
window.PurchaseGiftManagerMulti-buy gift promotion logic
window.miniCartGiftsConfigFree gift configuration read from the metaobject
window.addCheckoutEventChain(cb)Register a callback that runs before checkout
window.nativeFetchThe original fetch, captured before Yett and the cart interceptor patch it
window.YETT_BLACKLISTScript patterns Yett holds back

The layout's first script tag captures window.nativeFetch. Use it when you need a request that neither Yett nor the cart interceptor should see.

App globals the theme reads

These belong to installed apps. The theme waits for them rather than loading them.

GlobalApp
window.SesamiSDKSesami booking
window._klOnsiteKlaviyo
window._swat, window.SwymCallbacksSwym wishlist
window.StampedFnStamped reviews
window.upez__chainEventManagerUpnova
window.CurrencyCurrency conversion

Every one of these can be absent. deferJS is the theme's usual way of waiting for one.

Adding a key

  1. Write it from Liquid.
<script>
  window.theme = window.theme || {};
  window.theme.myFeature = {{ my_value | json }};
</script>
  1. Declare it in the theme interface in src/@types/global.ts.
  2. Read it defensively in TypeScript.

The interface ends with an index signature, so an undeclared key type checks. Declare it anyway, or every call site is any and a rename goes unnoticed.

On this page