Why are Variant IDs null??

HunkyBill
Shopify Expert
4846 60 552

I have a product with a single variant. That variant has been assigned a subscription plan in a group.

When I experiment with the product subscription extension, and test out the Add which means "Add this product to some subscription plan", I am handed data by Shopify. The data I am handed only represents the product ID, and the variant is null. WHY? How is that helpful? If I am only supposed to show the subscription plans not currently assigned, I have to compare the variant ID to the plans to hide the ones it already has. But if Shopify does not provide this variant ID, that is not logically possible. Here is the data I am handed.

Screen Shot 2022-05-31 at 11.19.08 PM.png

Why is variant ID undefined? And since it is undefined, how is someone supposed to filter with solely the product ID?

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
Replies 6 (6)

JuanHoyos
Shopify Staff
43 4 6

Hi @HunkyBill, can you confirm the variantId is undefined when adding the variant (not the product) to a selling plan group?

 

I see the app extension is rendered in both the product and variant page.

To learn more visit the Shopify Help Center or the Community Blog.

HunkyBill
Shopify Expert
4846 60 552

In Shopify, when editing product details, there is no separate variant page when there exists only one variant. So in my case, I am viewing the product details page, and seeing the subscription set on the one variant, which is true. I assigned the variant to the selling plan.

I would like to know why setting subscriptions with a valid API key on a valid product, is failing trigger anything in Shopify checkout in my development store. This is super frustrating. Nothing seems correct with Subscription API work, at this time.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
JuanHoyos
Shopify Staff
43 4 6

I can reach the variant page of a product with a single variant by clicking/tapping in the variant.

 

01-58-41y4i-u79rp.png

To learn more visit the Shopify Help Center or the Community Blog.

JuanHoyos
Shopify Staff
43 4 6

I would like to know why setting subscriptions with a valid API key on a valid product, is failing trigger anything in Shopify checkout in my development store. This is super frustrating. Nothing seems correct with Subscription API work, at this time.


On your frustration, it might worth moving it to a new post to increase the visibility with the community.

 

In any case, can you guide us all with specific information to be more helpful? What do you mean with "trigger anything"? Feel free to DM me to share non-public information on this regards.

 

 

To learn more visit the Shopify Help Center or the Community Blog.

HunkyBill
Shopify Expert
4846 60 552

You are demonstrating a product with options, hence more than one variant. My product has just a single variant, and therefore is presented as per the image here. So there is only the product and its single variant, and why therefore Shopify is not sending the ID for the variant is seemingly weird.
Screen Shot 2022-06-01 at 11.28.50 AM.png

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
JuanHoyos
Shopify Staff
43 4 6

Oh! Got it, got it. Thank you for clarifying this.

 

If I am only supposed to show the subscription plans not currently assigned, I have to compare the variant ID to the plans to hide the ones it already has.


So, to solve for your case I suggest you to compare with both variant and product ID. In a single-variant product, SellingPlanGroup.productVariants [1] should be empty.

 

 

1: https://shopify.dev/api/admin-graphql/2022-04/objects/SellingPlanGroup#queries

To learn more visit the Shopify Help Center or the Community Blog.