Create and manage selling plans
Selling plans represent how products can be sold and purchased. This tutorial shows you how to create and manage selling plans in your app by illustrating two use cases: "Subscribe and save" and "Prepaid" subscriptions.
"Subscribe and save", also known as "pay per delivery", is a selling method where a customer pays for goods or services per delivery. "Prepaid" is a selling method where a customer makes a single payment upfront.
- You've completed our Getting started with the GraphQL Admin and REST Admin APIs guide and you're authenticated with the API.
- You've created products and product variants in your development store.
- To be eligible to use Shopify subscriptions, merchants needs to meet the qualifying criteria.
To use the GraphQL mutations, your app needs to request the following access scopes for a Shopify store:
write_products: Allows an app to write products.
read_customer_payment_methods: Allows an app to read customer payment methods.
read_own_subscription_contracts: Allows an app to read subscription contract mutations for contracts they own.
write_own_subscription_contracts: Allows an app to write subscription contract mutations for contracts they own.
A selling plan group represents a selling method. Selling plans are organized into selling plan groups. Each selling plan group includes products or variants as well as a delivery, billing, and pricing policy.
|Selling plan group||Represents a selling method. For example, "Subscribe and save" or "Prepaid" subscriptions.|
|Selling plan||Represents an alternative way to buy a product or variant. Selling plans are organized into a selling plan group. For example, individual selling plans might be named "Deliver weekly" or "Deliver monthly".|
|Policies||Each selling plan is associated with the following policies:
Create a selling plan group
In the following example, a selling plan group is created using the
The input fields include
name (the plan group name that customers see),
merchantCode (the plan name that the merchant sees),
sellingPlansToCreate (the individual selling plans to create),
options (the selling plan options available in the drop-down list in the storefront), and
position (how the options are sorted).
Associate a selling plan group to a product variant
Selling plans can be created with products or product variants already associated in the
However, you can also use the
sellingPlanGroupAddProductVariants mutation to make a separate call to associate a selling plan group with a product or product variant, without having to delete and recreate the selling plan group.
In the following example, the selling plan group is associated with a product variant.
Associate multiple selling plan groups to a product or product variant
In the following example, two selling plan groups are associated with a product:
In the following example, two selling plan groups are associated with a product variant:
Configure a product to be sold only as a subscription
You can configure which products are sold on a subscription by specifying the
requiresSellingPlan field as
true in the
productUpdate mutation. In the following example, the product is only sold on subscription.
Edit a selling plan group
You can call the
sellingPlanGroupUpdate mutation to edit the attributes associated with a selling plan group. In the following example, the “Subscribe and save” selling plan group is renamed to “Pay per delivery”.
Remove a product or variant from a selling plan group
If you want to disassociate a product from a selling plan group, then you can use the
sellingPlanGroupRemoveProducts mutation. To remove a product variant from a selling plan group, you can use the
sellingPlanGroupRemoveProductVariants mutation. In this example, a product is removed from a selling plan group.
Collecting payment information
After you have created the selling plan group, customers can purchase a product on a subscription and add it to their cart. For more information on implementing storefront Liquid properties, refer to Showing selling plan groups and selling plans on a product page.
Customer payment methods allow merchants to initiate new charges, with or without the customer being present. After a checkout is complete, a customer payment method is associated with the customer.
When an order includes subscription products, the payment method is associated with the subscription contract. This allows subscription apps to know which payment method to use for recurring payments.
Advanced delivery behaviors for subscriptions
If you need to define more advanced delivery behaviors for subscriptions, then you can use anchors. Anchors are useful in the following scenarios:
- A merchant starts fulfillment on a specific date every month
- A merchant wants to bill the 1st of every quarter
- A customer expects their delivery every Tuesday
Anchors define the date when fulfillment is completed by a merchant or when delivery occurs for the customer for a given time cycle. You can also define a cutoff for which customers are eligible to enter this cycle and the desired behavior for customers who start their subscription inside the cutoff period.
To learn more about anchors, refer to the SellingPlanRecurringDeliveryPolicy reference topic. To learn how to manage orders and fulfillments associated with prepaid subscriptions, refer to Manage orders for prepaid subscriptions.
|Buy on anchor date, no cutoff (asap)||
|Buy on anchor date, no cutoff (next)||
|Buy before anchor date, no cutoff (asap)||
|Buy before anchor date, no cutoff (next)||
|Buy after anchor date, no cutoff (asap)||
|Buy after anchor date, no cutoff (next)||
|Buy inside cutoff date, no cutoff (asap)||
|Buy inside cutoff date, no cutoff (next)||
|Buy before cutoff date, no cutoff (asap)||
|Buy before cutoff date, no cutoff (next)||
The following example illustrates the use of
anchors in an API call. In the example, the fulfillment and billing dates are defined as the 15th of each month.
- Create and manage subscription contracts: Follow a step-by-step workflow to create and manage subscription contracts, and get familiar with how billing and webhooks for subscriptions work.
- Create and manage discounts on subscriptions: Learn how to apply different types of discounts on subscriptions, including percentage, fixed amount, and free shipping discounts.
- Create and manage subscription shipping rates and delivery methods: Learn how to update delivery methods on subscriptions and understand the shipping rates customers see during checkout.