Monthly gifts on a custom storefront page
Use this integration when members should choose sizes and claim a monthly gift on an existing Shopify Online Store page. This requires developer setup. It works alongside the existing Members Area and Shopify POS claim flow.
Before you start
Enable and configure Monthly Free Product for the membership tier, including the current month's product or collection and quantity limit.
Use Shopify customer sign-in on the storefront, including stores using new customer accounts. Confirm the signed-in page session belongs to the intended member. A separate custom login or a customer ID stored in JavaScript is not sufficient.
Keep your existing variant selection and Ajax add-to-cart code. Test on a theme preview with a test membership before publishing changes.
Confirm the Memberply app-proxy path. The default is
/apps/memberply_proxy; use your store's configured path if it has been customized.
No admin API secret is required in the theme. The endpoints derive the customer from Shopify's signed logged_in_customer_id and resolve the membership tier on the server. They do not accept a browser-supplied customer, shop or tier as authorization.
Endpoints
Call these paths on the storefront origin, never directly on the Memberply API domain:
GET /apps/memberply_proxy/monthly-gift
Current eligible offer, or HTTP 204 when no gift is available.
POST /apps/memberply_proxy/monthly-gift/claim
Creates or retrieves the same monthly gift code. Send Content-Type: application/json and {}.
Both responses use the existing monthly gift offer fields, including periodKey, quantityLimit, resourceType, shopifyResourceId, resourceTitle, discountCode and alreadyClaimed. alreadyClaimed means a code has been prepared, not that it has been redeemed. claimUrl is provided for redirect-based experiences; do not navigate to it for an inline experience.
Responses are private and must not be cached. Handle HTTP 401 by asking the member to sign in, 403 by showing that an eligible active membership is required, 409 by showing that the gift is unavailable or still being prepared, and 429 by waiting before retrying. Respect Retry-After. Recovery after an interrupted issuance can take five minutes. Do not create another code yourself.
JavaScript helper
The helper checks eligibility, prepares a code and applies it to the current cart without navigation. It does not choose products or add them to the cart. This keeps a retry from adding the same selection again.
For a customized proxy path, pass {proxyPath: '/apps/your-memberply-path'}. Locale-aware cart URLs use Shopify.routes.root by default. The helper preserves existing discount codes when adding the gift code, but Shopify's discount-combination rules still determine which discounts apply. It throws discount_not_applied if Shopify does not mark the gift code applicable. Show that error instead of promising a free gift. Never automatically remove another customer's cart item or discount to make the gift work.
The helper does not mount a UI or refresh a particular theme's drawer. Connect its result to the theme's own cart rendering. Concurrent claim clicks within the helper share one request; also disable your own button to avoid duplicate add-to-cart operations.
Shopify Bundles and separate sizes
Validate that the size selectors add a real eligible bundle variant representing the chosen top and bottom, rather than two unrelated variants. Include the correct bundle product in the configured gift selection. Test the resulting cart and checkout with different top and bottom sizes.
The monthly allowance counts eligible quantities in the discount function. Do not assume two component lines count as one set, trust shopper-supplied line properties as proof of a bundle, or increase the allowance to two as a workaround. If your bundle appears as separate component lines, stop and ask Memberply to review that actual cart structure before launch.
Validation before launch
Test an active member, a signed-out visitor, an ineligible member, repeat clicks, an interrupted request, a used code, cancellation and rejoining, and online/POS use of the same code. Confirm the current month's selection and expiry in the store's time zone. Verify cancellation after benefit access ends, allowing for membership-status synchronization to Shopify.
For sets, verify both sizes and the full intended discount, plus a cart containing an extra eligible standalone item. Confirm that the extra item is charged. Confirm existing discounts and the cart drawer still behave correctly.
The endpoints reuse one claim per member, tier configuration and calendar month. Rejoining the same tier does not reset it. Deleting/recreating a tier or moving between tiers is not a store-wide gift allowance and should not be used to manage retries.
Last updated