Skip to main content
When a shopper finishes a try-on, the result screen shows one final CTA. data-hemsy-action on the script tag sets the default, and any launcher element can override it with its own data-hemsy-action. It applies to every launch mode, including Instant. In the Shopify theme extension, this is the app embed’s “When shoppers finish” setting and each trigger block’s override — no attributes to write. The examples below show the equivalent script install markup. Use cart when your storefront owns cart state and should add the returned variants itself: headless storefronts, Hydrogen, or any site with a custom cart drawer.
To override the action for a single launcher, put data-hemsy-action on the element:
The legacy script-level data-hemsy-mode="cart" still maps to the cart action for backward compatibility, but prefer data-hemsy-action: data-hemsy-mode should be reserved for "instant". (data-hemsy-mode="checkout" has no effect; checkout is simply the default action.)

Native cart strategy

By default the cart action hands items to your code via onProductVariantData, which means writing a callback. If your storefront is a standard Shopify theme, skip that entirely with data-hemsy-cart-strategy="native":
With the native strategy, when the shopper clicks the final CTA Hemsy:
  1. Adds the returned items to the Shopify cart via the Ajax API (/cart/add.js), converting variant GIDs to numeric IDs and mapping item attributes to line-item properties.
  2. Dispatches cart:refresh, cart:updated, and cart:change events on document with the updated cart, so cart drawers and count bubbles that listen for them update in place.
  3. Closes the modal once the add completes (unless data-hemsy-auto-close="false").
Callbacks still fire if you define them, so you can layer analytics on top. A cart failure never traps the shopper: the modal closes regardless and the error is logged to the console.
The Shopify theme extension uses the native strategy automatically, so merchants who install through the theme editor get a working cart handoff with zero code.

Event callbacks

Callbacks are configured on window.HemsyEmbedConfig (not data attributes). Define it before the embed script loads:
onItemAdded and onItemRemoved fire live as the shopper edits their bag, regardless of action. onProductVariantData is the cart handoff itself: the items array includes any line-item attributes from the original payload (bundle keys and so on), so pass them through to your cart.

Keeping the modal open

By default, Hemsy closes the modal after the cart handoff. Set data-hemsy-auto-close="false" on the script tag (or autoClose: false on HemsyEmbedConfig) to keep it open (for example if you show your cart drawer next to the modal).

Hydrogen example

variantId is the numeric Shopify variant ID as a string. Convert it to GID format (gid://shopify/ProductVariant/...) for Hydrogen’s cart operations.