For discussing the development and integration of subscription-enabled shops using Shopify's Subscription APIs.
I made a Selling Plan to go along with the Group I created. The plan involves a subscription product with recurring billing.
I sold this product in my development shop, so I have an order where a customer bought a subscription.
I query that shop using GraphQL for the subscription contract based on a reading of this from the documentation:
A subscription contract is the result of purchasing a selling plan that has recurring policies. After a customer purchases a subscription product or variant at checkout, Shopify generates a subscription contract
I assumed in the response I would see a single subscription contract waiting for me to deal with it. But I get back an empty array. Is there some feature I do not know about that would prevent Shopify from creating a contract on a valid Subscription Plan? I will try another order to see if that helps. But otherwise? What is one to do if Shopify fails to create a contract?
Note. A second order attempt proved futile. So what gives? What are my options for debugging why a contract is not being generated?
Hi,
It should work. Mostly you need to have all these:
- Your selling plan has recurring policies?
- Does your selling plan group is associated to a product or variant?
- When purchasing that variant the subscription option is selected?
If everything is correct and a contract is not created, can you send a bit more details how your selling plan / selling plan group looks like?
To learn more visit the Shopify Help Center or the Community Blog.
My selling plan has recurring policies. As per this bit of code:
billingPolicy: {
recurring: {
interval: YEAR,
intervalCount: 1,
maxCycles: 3
}
}
Indeed, the product/variant are clearly hard-wired to the plan. I can see this by doing a simple GraphQL query with the product and variant, and it shows up as such. The product in Shopify Admin shows up in the Subscription box too.
There is no option other than the single variant of the product, which is assigned the subscription. So when purchasing this product, the variant ID is a subscription product.
So this is why I am confused. What else does one need to do to get a contract to work with?
Here is the group and plan, assigned to the product and variant.
mutation {
sellingPlanGroupCreate(
input: {
name: "Subscription, access to all videos",
merchantCode: "yearly-video-access",
options: ["yearly membership"],
position: 1,
sellingPlansToCreate: [
{
name: "Subscription, access to all videos",
options: "Year",
position: 1,
billingPolicy: {
recurring: {
interval: YEAR,
intervalCount: 1
}
}
deliveryPolicy: {
recurring: {
interval: YEAR,
intervalCount: 1
}
},
pricingPolicies: [
{
fixed: {
adjustmentType: PRICE
adjustmentValue : {
fixedValue : 0
}
}
}
]
}
]
},
resources: {
productIds: ["gid://shopify/Product/123"]
productVariantIds: ["gid://shopify/ProductVariant/456"],
}
)
{
sellingPlanGroup {
id
sellingPlans(first: 10) {
edges {
node {
id
}
}
}
}
userErrors {
field
message
}
}
}
Hello Hunky Bill,
Thank you for your post. I find myself grappling with the exact same issue you've described. Have you found a solution to this problem yet? If so, would you be willing to share any insights or approaches that worked for you?
Thank you in advance,
Best regards,