Member exclusive deal on Hydrogen (headless)
Show your Member exclusive deals on Hydrogen and Weaverse product pages, with the same deals and design as the Exclusive Deal block on your Online Store theme.
Requires @joy-loyalty/hydrogen 0.5.0 or later (it needs @joy-loyalty/sdk 0.4.0 or later; the Weaverse block needs @joy-loyalty/weaverse-hydrogen 0.3.0 or later). Headless storefronts, and this block, are available on the Ultimate (Enterprise) plan.
Overview
<JoyMemberExclusiveDeal/> is the headless version of the Member exclusive deal block. Mount it on your product page and:
- Guests see the deal and, after its description, the deal's Action text (by default "Join us now") as a link to your login page, so they can join and unlock it.
- Signed-in members see the deals they qualify for on that product.
- Each deal shows its own text, and a Member price row with the selected variant's price after the deal, next to the original price.
- The block is product page only. It follows the selected variant, so it updates when the customer changes variant.
You set up the deals, dates, limits, text and design in Joy admin, exactly as for the theme block (Membership → Member exclusive deal). Your Hydrogen storefront picks them up. You don't write the text or style the block in code.
What's the same as the theme block
- The same deals, with the same active dates, usage limits, applicable products and collections, and tier / quantity rules.
- The same words. Each deal shows the Description, Action text and Remaining spots text you wrote in its Block text card. See Write the text for each deal.
- The same style from the Design tab: text font, text size, text color, button icon, icon color and background color, applied to every deal.
- The same Member price row. It shows for a Discount percentage deal, and for a Discount amount deal whose Discount applies to isn't All orders and whose Apply once per order is off. It doesn't show for other deal types (such as free shipping or bonus points), for a deal with an order requirement, or once a deal's total limit is used up.
- Deals saved before per-deal text show your older shop-wide text at the top of the block until you save text for them, as on your theme. The shop-wide text disappears once every deal on the product has its own text.
- The block hides itself when no deal applies to the product, or when the customer already left the program.
What's different on headless
- Amounts are in your store's currency. Deal amounts aren't converted, including the
{{value}}in a Discount amount deal's Description. When the shopper browses in another currency, or the currency can't be determined, the amount shows with your store's currency code (for example "USD 50"), so nobody reads it as a converted price. - No member price for a discount amount in another currency. Your theme converts a Discount amount deal with Shopify's exchange rate. Hydrogen has no exchange rate, so when the shopper browses in a currency other than your store's, the Member price row is hidden for Discount amount deals. Discount percentage deals still show it, in the shopper's currency.
- Minimum order amount. On your theme, a deal (other than free shipping) whose minimum order amount is higher than the product price is hidden. On Hydrogen the deal stays visible, with its "Minimum order amount: …" line.
- "Buy" and "Save" are translatable. The words in quantity-rule rows (for example "Buy 2, save 10%") can be edited per language in Joy Loyalty → Translations → Unified widget. See Translations.
- Older shop-wide text is sanitized (headless only). This only concerns the shop-wide text that deals saved before per-deal text still show. It keeps ordinary formatting — bold, italics, links, lists and line breaks. Scripts, click handlers (
onclick…),javascript:links, embedded frames and form fields are removed, so only the text shows. If that text relied on a tracking snippet or an inline click handler, it keeps its text on Hydrogen but not the behavior. Each deal's own Block text shows as plain text, on Hydrogen and on your theme alike. - Members don't see some older deals. For signed-in members, Joy doesn't send customer details such as email, phone or city to a headless storefront. A deal whose conditions depend on one of those customer fields is therefore hidden from members, instead of risking a wrong result. Conditions on country, state, customer tags and join date work as on your theme. Deals created in today's admin only offer country, so they aren't affected — this only concerns older, imported or API-created deals. Guests aren't affected. If a deal shows on your theme but not on Hydrogen for a member, check its conditions and move to one of the four supported fields.
- Products in more than 20 collections. For these products, a deal that excludes certain collections may be hidden, because Joy can't be sure the product isn't in an excluded collection.
- No theme-editor preview mode. The preview shortcut used in the Shopify theme editor doesn't exist on Hydrogen.
Before you start
Complete Install manually or Install with an AI agent first. You need:
- The
JOY_API_URLandJOY_SHOP_DOMAINenvironment variables, and the root loader returninggetJoyInitialData()— the samejoydata<JoyWidget/>uses. - The
/api/joy-tokenroute so signed-in members see their own deals. Guests don't need it. - Customer Account API login, so your product page knows whether the customer is signed in.
- At least one active Member exclusive deal in Joy admin.
Install with an AI agent (recommended)
Let your AI coding agent (Claude Code, Cursor, Codex and others) add the block for you. The joy-headless-member-exclusive-deal (opens in a new tab) skill walks it through the same steps as Add the block manually below: the package upgrade, isLoggedIn in the root loader, the Joy fields in your product query, and where to mount the block. Joy isn't on your Hydrogen storefront yet? The skill stops and sends the agent to joy-headless-install first.
1. Add the Joy skills to your Hydrogen project. Run this in your project root:
npx skills add tinhnv2001/joy-loyalty-hydrogen-skillsThis installs joy-headless-member-exclusive-deal next to joy-headless-install. Added the Joy skills before? Run the same command again — npx skills update only refreshes skills you already have and won't add the new one.
2. Paste this prompt into your agent:
Use the joy-headless-member-exclusive-deal skill to add the Joy Member exclusive deal
to my product page, next to the buy buttons. Do not deploy anything.
When you are done, walk me through the verification checklist.3. Review the changes before you commit, then run the Verify checklist below.
Add the block manually
1. Upgrade the package
npm install @joy-loyalty/hydrogen@^0.5.02. Return isLoggedIn from your root loader
return {
joy,
isLoggedIn: await context.customerAccount.isLoggedIn(),
/* …the rest of your root data */
};Pass this for every visitor, guests included. A signed-in customer who isn't known to Joy yet shows nothing instead of being treated as a guest.
3. Add the Joy fields to your product query
The block reuses the same product fields as the Point calculator. Spread them into your product query:
...JoyPointsProducton the product (JOY_POINTS_PRODUCT_FRAGMENT)....JoyPointsVarianton the selected variant (JOY_POINTS_VARIANT_FRAGMENT).
Already installed the Point calculator on Hydrogen? You're covered.
4. Mount the component
import {JoyMemberExclusiveDeal} from '@joy-loyalty/hydrogen';
import {useRouteLoaderData} from 'react-router';
export function ProductDeal({product, selectedVariant}) {
const root = useRouteLoaderData('root');
if (!root?.joyApiUrl || !root.joyShopDomain) return null;
return (
<JoyMemberExclusiveDeal
apiUrl={root.joyApiUrl}
shopDomain={root.joyShopDomain}
initialData={root.joy ?? null}
product={product}
selectedVariant={selectedVariant}
isLoggedIn={root.isLoggedIn}
/>
);
}Optional props: align (left, center or right), loginUrl (where the guest Action text link goes; defaults to your Joy login URL, then /account/login), onNavigate (for client-side navigation) and className. For every prop, see Member exclusive deal (opens in a new tab) on the developer docs.
Add it on Weaverse
On a Weaverse storefront the block is Joy — Member exclusive deal, with one Alignment setting (left, center, right). It isn't registered by default, because it only works on product pages. Register it next to the Joy blocks:
import {joyComponents, JoyMemberExclusiveDeal} from '@joy-loyalty/weaverse-hydrogen';
export const components = [...pilotComponents, ...joyComponents, JoyMemberExclusiveDeal];Then add it to a product template whose loader returns the product with the Joy product and variant fields (step 3). The root loader must return isLoggedIn (step 2). See Weaverse.
Customize the design
Use the same settings as the theme block. Your storefront picks the changes up without a code change.
- Words: open the deal and edit its Block text card at the bottom of the Deal settings tab. Each deal has its own text.
- Style: use Membership → Member exclusive deal → Design. These settings apply to every deal.
Where the block appears is decided by where you mount it.
Verify
- As a guest, open a product covered by an active deal — the deal shows its Description and its Action text as a link.
- Click the Action text link — it opens your login page.
- Sign in as a member — each deal shows its own text, without the link. It matches the same product on your Online Store theme.
- On a Discount percentage deal, the Member price row shows the selected variant's price after the discount.
- Change the variant — the block, including the Member price, stays in sync.
- Open a product that no deal covers — the block shows nothing and leaves no gap.
- Switch the storefront to another currency — amounts show your store's currency code.
Troubleshooting
| What you see | Cause | Fix |
|---|---|---|
| The block shows nothing on a product | No active deal covers it, or the product query is missing the Joy fields. | Check the deal in Joy admin, and add the fields from step 3. A [joy] JoyMemberExclusiveDeal: … warning in the console says which. |
| The block shows nothing and the console says the core has no member-exclusive-deal surface | The Joy widget code on the CDN is older than your package. | Contact Joy support to update it. |
| It works for guests but not for a signed-in customer | /api/joy-token returns an error, or the customer left the program. | Check JOY_API_SECRET matches the Headless secret in Joy admin. See Troubleshooting. |
| A member sees the deal on the theme but not on Hydrogen | The deal's conditions use a customer field Joy doesn't send to headless. | Use country, state, customer tags or join date in the conditions. |
| The block shows older shop-wide text above the deals | At least one deal on the product was saved before per-deal text. | Open that deal, change the text in its Block text card and click Save. |
| A deal has no Member price row | The deal type or its settings don't give a per-item price, its total limit is used up, or it's a Discount amount deal and the shopper browses in another currency. | See What's the same and What's different. |
| The older shop-wide text lost a script or click behavior | Headless removes scripts and click handlers from that text. | Use plain formatting and links, or give the deal its own Block text. |
Requests fail with PLAN_NOT_ELIGIBLE | The store isn't on the Ultimate plan. | Upgrade the plan. |
Related
Last updated on