Re: Why no Variant ID

Solved

Why no Variant ID

HunkyBill
Shopify Partner
4853 60 562

I have asked this before, and I am not sure I ever got an answer.


When Shopify bundles up a product and sends it the subscription create code, it only ever sends the product ID not the variant ID. If a product has only one variant why is that not included in the payload? Anytime I use the mutation sellingPlanGroupCreate I am expected to provide a variant ID and it seems like Shopify is making that difficult. Am I wrong? Here is my console log, so if anyone has any filler info on this, I would appreciate what I am missing here. Must be something obvious.

 

HunkyBill_0-1670253417186.png

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
Accepted Solution (1)
qc11
Shopify Staff (Retired)
47 14 12

This is an accepted solution.

Hi, just to be clear, you are talking about extensions on the product details page, is that correct?

After investigating, I confirmed that the presence of the variant id depends on which page you are.

 

Detailed behaviors of these extension points were implemented as follows:

- Product admin page `e.g. https://example.myshopify.com/admin/products/12345` 

  •  Admin::Product::SubscriptionPlan::Edit:
    • sellingPlanGroupId : the SellingPlanGroup id of the group being edited
    • productId : the product id of the current product admin page
    • variantId : the variant id is null
  • Admin::Product::SubscriptionPlan::Create:
    • productId : the product id of the current product admin page
    • variantId : the variant id is null
  •  Admin::Product::SubscriptionPlan::Remove:
    • sellingPlanGroupId : the SellingPlanGroup id of the group being removed from the product
    • productId : the product id of the current product admin page - variantId : the variant id is null
    • variantIds : an array of the product's child variant ids for which we should also remove the selling plan group association
  •  Admin::Product::SubscriptionPlan::Add:
    • productId : the product id of the current product admin page
    • variantId : the variant id is null


-  Variant admin page `e.g. https://example.myshopify.com/admin/products/12345/variants/6789` 

  • Admin::Product::SubscriptionPlan::Edit:
    • sellingPlanGroupId : the SellingPlanGroup id of the group being edited
    • productId : the product id of the parent product
    • variantId : the variant id of the current variant admin page
  • Admin::Product::SubscriptionPlan::Create:
    • productId : the product id of the parent product
    • variantId : the variant id of the current variant admin page
  • Admin::Product::SubscriptionPlan::Remove:
    • sellingPlanGroupId : the SellingPlanGroup id of the group being removed from the variant
    • productId : the product id of the parent product
    • variantId : the variant id of the current variant admin page
    • variantIds : this will be empty because the variant has no "child" variants
  • Admin::Product::SubscriptionPlan::Add:
    • productId : the product id of the parent product
    • variantId : the variant id of the current variant admin page

 

We also realized that this information is not documented anywhere. We will update the page accordingly.

Hope this helps!

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

View solution in original post

Replies 6 (6)

qc11
Shopify Staff (Retired)
47 14 12

Hi,

Would you mind offering me the mutation that doesn't return the variant ID so I can have a closer look?

Thanks!

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

HunkyBill
Shopify Partner
4853 60 562

I don't think you understand. This is an internal Shopify Subscription extension API issue. Shopify supplies data about the product for creating a subscription to the extension, and I am seeing it send a product ID but NO variant ID. Therefore when I want to USE a mutation like the one I pointed out, I do not have the information I need from Shopify. Can you explain why that is? Why do I not get a variant ID here? And how does this work when there are > 1 variants and we want to set a subscription against only 1 of many variants?

Shopify is lacking a lot of clarity here it seems?

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
qc11
Shopify Staff (Retired)
47 14 12

This is an accepted solution.

Hi, just to be clear, you are talking about extensions on the product details page, is that correct?

After investigating, I confirmed that the presence of the variant id depends on which page you are.

 

Detailed behaviors of these extension points were implemented as follows:

- Product admin page `e.g. https://example.myshopify.com/admin/products/12345` 

  •  Admin::Product::SubscriptionPlan::Edit:
    • sellingPlanGroupId : the SellingPlanGroup id of the group being edited
    • productId : the product id of the current product admin page
    • variantId : the variant id is null
  • Admin::Product::SubscriptionPlan::Create:
    • productId : the product id of the current product admin page
    • variantId : the variant id is null
  •  Admin::Product::SubscriptionPlan::Remove:
    • sellingPlanGroupId : the SellingPlanGroup id of the group being removed from the product
    • productId : the product id of the current product admin page - variantId : the variant id is null
    • variantIds : an array of the product's child variant ids for which we should also remove the selling plan group association
  •  Admin::Product::SubscriptionPlan::Add:
    • productId : the product id of the current product admin page
    • variantId : the variant id is null


-  Variant admin page `e.g. https://example.myshopify.com/admin/products/12345/variants/6789` 

  • Admin::Product::SubscriptionPlan::Edit:
    • sellingPlanGroupId : the SellingPlanGroup id of the group being edited
    • productId : the product id of the parent product
    • variantId : the variant id of the current variant admin page
  • Admin::Product::SubscriptionPlan::Create:
    • productId : the product id of the parent product
    • variantId : the variant id of the current variant admin page
  • Admin::Product::SubscriptionPlan::Remove:
    • sellingPlanGroupId : the SellingPlanGroup id of the group being removed from the variant
    • productId : the product id of the parent product
    • variantId : the variant id of the current variant admin page
    • variantIds : this will be empty because the variant has no "child" variants
  • Admin::Product::SubscriptionPlan::Add:
    • productId : the product id of the parent product
    • variantId : the variant id of the current variant admin page

 

We also realized that this information is not documented anywhere. We will update the page accordingly.

Hope this helps!

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

HunkyBill
Shopify Partner
4853 60 562

One thing does not really make sense here, and it seems like an undercooked turkey in the oven, bear with me, I may be wrong... you have a case where the variant is selected, for example the variant admin page versions. However, when only the default variant exists, that has no analog. Why not? If I say "create me a plan", from this aspect, I do not get the luxury of having the variantId? Seems like an oversight remains.

But yes, thanks for more clarity as per that above explanation.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
qc11
Shopify Staff (Retired)
47 14 12

I see, so the ask here is to include the default `variantId` when product doesn't have variants.
I will take your feedback back to the team!

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

HunkyBill
Shopify Partner
4853 60 562

I think it makes sense this ask. So I appreciate your understanding here! Thanks.

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