Member exclusive deal
<JoyMemberExclusiveDeal/> is the headless counterpart of the Liquid Member exclusive deal block. On a product page it shows one card per deal that applies to the product, with that deal's own text, the Member price of the selected variant, quantity rules and countdown. Guests also get a Sign-in link. The deals and their design are set in the Joy admin under Membership → Member-exclusive deal (the Deal settings and Design tabs).
The block is display only. Shopify applies the automatic discount at checkout; the block never creates or applies a discount.
Requires @joy-loyalty/hydrogen 0.5.0 or later and @joy-loyalty/sdk 0.4.0 or later (@joy-loyalty/weaverse-hydrogen 0.3.0 or later for the Weaverse block), plus the setup from the Overview and Authentication (root-loader initial data and the /api/joy-token route). It also needs the Ultimate (Enterprise) plan.
What it shows
| Shopper | The block renders |
|---|---|
| Guest | Each deal that applies to the product, with the deal's text and its Sign-in link (the deal's call-to-action text). The link goes to loginUrl, then initialData.login_url, then /account/login. |
| Member | Each deal that applies to the product, with the deal's text but no Sign-in link. |
| Member who left the program, is excluded by a membership segment, or has no deal that applies | Nothing. |
| Logged-in shopper whose Joy token can't be minted, or who has no Joy customer yet | Nothing, and one [joy] JoyMemberExclusiveDeal: … console warning. The block never shows guest content to a logged-in shopper. |
When no deal applies the block renders an empty element with no warning — that is expected.
Deal text and member price
Each deal card shows, when they apply:
- Deal text — the deal's own Description and Call to action from the admin (
blockTextin the API).{{value}}in the description is replaced with the deal's discount value: the percentage number for a percentage discount, the formatted amount for an amount discount. The call-to-action is the guest Sign-in link and is not shown to members. - Member price — the selected variant's price with the deal applied, next to the struck-through original price, in the storefront currency. It is shown only for a deal with deal text, a percentage discount without a maximum discount amount, or an amount discount that targets specific products or collections (not all products) and is not applied once per order; with no minimum order amount or quantity, not limited to the POS sales channel, and while the deal's total usage limit is not used up. Changing the variant, or a market switch that changes its price or currency, refreshes it.
- Remaining spots — the deal's own remaining-spots text (
{{remainingSpots}}is replaced with the number left), falling back to the shop-level design text. - The countdown, quantity rules and order-requirement lines.
Legacy intro. Deals saved before per-deal text have no blockText. While at least one such deal is shown, the block also shows the shop-level intro (the Design tab description and call-to-action) above the cards, as the Liquid block does. Once every shown deal has its own text, the intro is gone.
Install with an AI agent
The joy-headless-member-exclusive-deal (opens in a new tab) agent skill can do the steps below for you. It walks your coding agent (Claude Code, Codex, Cursor or any agent the Skills CLI (opens in a new tab) supports) through the setup on this page: upgrading @joy-loyalty/hydrogen, returning isLoggedIn from the root loader, adding the Joy product/variant fragments to your product query, mounting <JoyMemberExclusiveDeal/> next to the buy buttons (or registering the Weaverse block), and a verification checklist.
Run this in your Hydrogen project root. Run it again if you installed the skills before this one was added — npx skills update only refreshes skills you already have.
npx skills add tinhnv2001/joy-loyalty-hydrogen-skillsThen ask your agent:
Use the joy-headless-member-exclusive-deal skill to add the Joy Member exclusive deal to my
product page, under the add-to-cart button. Return isLoggedIn from my root loader and reuse the
Joy product fragments if they are already in my product query. Do not deploy anything.
When you are done, walk me through the verification checklist.The skill stops when Joy headless isn't installed yet (no getJoyInitialData() in the root loader or no /api/joy-token route) and points to joy-headless-install in the same repository. It tells the agent not to touch JOY_API_SECRET and not to deploy — review the diff before you commit.
1. Add the fragments to your product query
The block reuses the Points calculator product fragments. If the calculator is already installed, there is nothing to add.
import {JOY_POINTS_PRODUCT_FRAGMENT, JOY_POINTS_VARIANT_FRAGMENT} from '@joy-loyalty/hydrogen';
const PRODUCT_QUERY = `#graphql
query Product($handle: String!, $selectedOptions: [SelectedOptionInput!]!) {
product(handle: $handle) {
...JoyPointsProduct
selectedOrFirstAvailableVariant(selectedOptions: $selectedOptions) {
...JoyPointsVariant
}
# …your own fields
}
}
${JOY_POINTS_PRODUCT_FRAGMENT}
${JOY_POINTS_VARIANT_FRAGMENT}
`;- Keep
collections(first: 20)at 20 (see Limitations). - No customer tags, B2B flag or cart fields are needed; the block reads everything it needs from the endpoint below.
2. Return isLoggedIn from the root loader
The block decides guest vs. member from the root loader's initial data. Also return a top-level isLoggedIn for every visitor, so the block hides, instead of showing the guest teaser, when the token mint fails for a logged-in shopper:
const isLoggedIn = await context.customerAccount.isLoggedIn();
return {joy, isLoggedIn /* , …the rest of your root data */};3. Mount the block
import {JoyMemberExclusiveDeal} from '@joy-loyalty/hydrogen';
import {useLoaderData, useNavigate, useRouteLoaderData} from 'react-router';
export function ProductMemberDeal() {
const {product} = useLoaderData<typeof loader>();
const root = useRouteLoaderData('root');
const navigate = useNavigate();
if (!root?.joyApiUrl || !root.joyShopDomain) return null;
return (
<JoyMemberExclusiveDeal
apiUrl={root.joyApiUrl}
shopDomain={root.joyShopDomain}
initialData={root.joy ?? null}
product={product}
selectedVariant={product.selectedOrFirstAvailableVariant}
isLoggedIn={root.isLoggedIn === true}
onNavigate={navigate}
/>
);
}Product pages only: there are no cart props, and the block is not meant for the cart or a collection page.
Props
| Prop | Type | Notes |
|---|---|---|
apiUrl | string | Required. Headless API base URL (JOY_API_URL). |
shopDomain | string | Required. The shop's *.myshopify.com domain. |
initialData | JoyInitialDataResultor null | Required. The root loader's getJoyInitialData() result. null renders nothing. |
product | PointsStorefrontProduct | Required. The product with ...JoyPointsProduct. Missing: the block hides and warns once (product snapshot missing). |
selectedVariant | PointsStorefrontVariant | Required. The selected variant with ...JoyPointsVariant. Changing the variant refreshes the block. |
isLoggedIn | boolean | await customerAccount.isLoggedIn(). Pass false for guests. The shopper also counts as logged in when initialData carries a customer or shopifyCustomer. |
align | 'left', 'center'or 'right' | Default left, as the Liquid block. Read at mount. |
loginUrl | string | Target of the guest Sign-in link. Falls back to initialData.login_url, then /account/login. |
tokenRoute | string | Same-origin token route for logged-in shoppers. Default /api/joy-token. |
onNavigate | (url) => void | Client-side navigation (useNavigate()). Omitted: full page load. |
assetUrl | string | Overrides the widget-core CDN URL (JOY_WIDGET_ASSET_URL). Leave unset in production. |
className | string | Class for the wrapper element. |
Weaverse
JoyMemberExclusiveDeal is exported from @joy-loyalty/weaverse-hydrogen but is not part of joyComponents, so it never appears in a merchant's block palette by accident. Register it explicitly:
import {joyComponents, JoyMemberExclusiveDeal} from '@joy-loyalty/weaverse-hydrogen';
export const components = [...joyComponents, JoyMemberExclusiveDeal];The block is joy-member-exclusive-deal ("Joy — Member exclusive deal") with one setting, Alignment (left, center or right; default left). It reads JOY_API_URL, JOY_SHOP_DOMAIN and JOY_WIDGET_ASSET_URL from the Weaverse env, the root loader's joy and isLoggedIn, and product / selectedOrFirstAvailableVariant from the current route loader — so place it on a product route whose loader returns the points fragments. Without those env variables the block shows a short setup message in the editor.
Data endpoint
The block calls GET /member-exclusive-deal (the spec is in API references). Authentication is optional:
- Guest — no token and no call to the token route. The response has
discountSettingsandtranslationonly, and is CDN-cacheable:Cache-Control: public, s-maxage=300withVary: Authorization. - Member —
Authorization: Bearer <token>fromPOST /auth/token. The response also carries a deliberately minimalcustomerobject, and isCache-Control: private, no-store. A token that does not verify is treated as a guest; a token issued for a different shop is401 UNAUTHORIZED.
Query parameters: d (or shop) is the shop domain, l (or locale) the locale, and join=true, honoured only for a verified member. If shop and d name different shops the endpoint never returns data (400 BAD_REQUEST, or 403 PLAN_NOT_ELIGIBLE when the plan gate rejects one of the two first). Success uses the standard envelope {success: true, data, timestamp}; every error is no-store.
data.customer is a closed set of keys: id, type, isExcludeBySegment, tierId, exclusiveDealLastUsedAt, birthMonth ("MM" or null), defaultAddressCountry, and exclusiveDeal (per-deal count, countInPeriod, lastDateAppliedCoupon). state, tags, becomeMemberAt and createdAt are added only when a returned deal has a matching customer condition. Names, email, phone, addresses and the raw birthday are never returned.
Each entry of data.discountSettings is a closed set of deal fields. Besides the eligibility, date, usage-limit and condition fields, it carries the inputs for the deal text and member price: earnAmount (number, or a numeric string on older deals, or null), appliedDiscountToSaleChannel, maxDiscountAmountEnabled, applyOncePerOrder, and blockText — {description, callAction, remainingSpots}, string fields only, absent on a legacy deal. See MemberExclusiveDeal in the API reference.
With the SDK: client.getMemberExclusiveDeal({join?: boolean}) returns data typed as MemberExclusiveDealPayload; the per-deal text is typed as MemberExclusiveDealBlockText.
Join hand-off
When a guest clicks Sign-in, the block sets joy_join_engaged in localStorage before navigating. On the next logged-in mount it sends join=true once, then clears the flag when the server answers (like the Liquid block). If storage is unavailable the hand-off is simply skipped; rendering is unaffected.
Behaviour
- Money in deal text, quantity rules and the minimum order amount is in the shop currency and is not converted. When the storefront currency differs from the shop currency, or is unknown, these amounts are shown with the ISO currency code (for example
USD 10.00). A minimum order amount is shown as a condition line; it does not hide the deal, as on Liquid. - Member price and currency. The member price uses the selected variant's price and currency from the Storefront API. Headless has no Shopify currency rate, so unlike Liquid an amount discount shows no member price when the storefront currency differs from the shop currency; a percentage discount still does. When the variant has no currency, no member price is shown.
- Member conditions fail closed. For a member, a deal that has a customer condition the block cannot evaluate is hidden. The block can evaluate customer country, state, tags and join date; tax-exempt is ignored, as on Liquid. Any other customer condition (email, segment, …) hides the deal. This differs from the Liquid block and only affects legacy or imported deals — the current admin form offers only country.
- Deal text is plain text. The per-deal description, call-to-action and remaining-spots text are rendered as text, not HTML, as on Liquid.
- Merchant HTML in the legacy intro is sanitized. The shop-level description and call-to-action are cleaned with the widget core's DOMPurify profile before they are rendered. Ordinary rich text is kept: bold, italic, links, lists, line breaks and inline
style;targetis kept and links getrel="noopener noreferrer".<script>,on*event-handler attributes,javascript:URLs,<iframe>,<object>/<embed>and form controls are removed. Copy that relied on inline script oronclickshows the text without the behaviour on headless; Liquid is unchanged. - Degrade. Any failure — an older widget core, a failed fetch, a malformed deal — renders nothing and logs one
[joy] JoyMemberExclusiveDeal: …warning. A malformed deal never hides the other deals, and nothing throws into your page.
Limitations
Enterprise plan only. GET /member-exclusive-deal answers 403 PLAN_NOT_ELIGIBLE for any shop not on the Ultimate plan, and the block then renders nothing.
- Product page only, display only. The block shows the deal; Shopify's automatic discount is what changes the price.
- Collections. Products in more than 20 collections have a truncated collection list. A deal that excludes collections then fails closed (hidden), so this is not full Liquid parity. Keep
collections(first: 20). - Member customer conditions the block cannot evaluate hide the deal (see Behaviour).
- Multi-currency member price. With no Shopify currency rate on headless, an amount discount shows no member price when the storefront currency differs from the shop currency, and no deal shows a member price when the storefront currency is unknown. Liquid converts with Shopify's rate.
- No runtime kill switch. There is no setting to turn the headless block off remotely; remove it from your storefront code or Weaverse layout.
- Widget core. The block needs a widget core that provides
loadMemberExclusiveDealCore. Against an older core it renders nothing and logs one warning. - Texts. The "Buy" / "Save" labels of quantity rules come from the
[[WidgetV4]]translation dictionary, so they can differ from the Liquid block in some languages.
Related
- Points calculator — shares the product fragments.
- Authentication