Overview
In Shopify, subscriptions and alternative purchase options (preorders, try-before-you-buy) are modeled using Selling Plans.
Instead of creating duplicate product records for subscriptions, a single ProductVariant is linked to a SellingPlanGroup.
Product / Variant
└── SellingPlanGroup (e.g. "Subscribe & Save")
├── SellingPlan (Deliver Monthly - 10% off)
└── SellingPlan (Deliver Every 2 Months - 10% off)
Liquid Integration
{% if product.selected_or_first_available_selling_plan_allocation %}
<p class="selling-plan-note">
Subscribing saves {{ product.selected_selling_plan_allocation.price_adjustments[0].value }}
</p>
{% endif %}
Developer Takeaway
Checkout Line Item Selling Plan: When adding a subscription variant to cart, pass the selling_plan ID alongside the id parameter to convert the line item into a recurring subscription contract.