Querying for existing SellingPlanGroups

ToyboxZach1
New Member
2 0 1

I'm working through adding a shopify subscription custom app and I'm getting stuck on exactly how this part should be done:

Add an existing selling plan group to a product or variant

The Add mode allows a user to add the current product to an existing selling plan group. The Add plan UI should display a searchable list of selling plan groups on the shop. Selling plan groups that are already associated with the product either directly or through one of its variants should not be listed. The Add mode triggers the modal container.

https://shopify.dev/tutorials/create-manage-product-subscription-extension

It is not exactly clear where this information is supposed to live or how to query it.

I have already gotten my site connected with the session token to the extension and I can successfully call sellingPlanGroupCreate so I know I have the base of it working, but I'm not exactly sure how I should get the names and ids of the existing sellingPlanGroups so I can display that.

This is data completely stored in shopify, so is there a way to directly call shopify apis for the extension to get the stored data or do I have to provide a middle-ware call like this: http://mywebsite.com/shopify/extension/selling-plan/list

Then if I have to do it from my own site, how do I exactly form a graphql to get the list of them? 
I tried various forms of this:

 

query {
  sellingPlanGroups { 
    name
    id
  }
}

 

But was not able to be successful and the API documents are not clear about this particular item as the links don't go where I expect, or I am greatly misunderstanding how this all works.

If none of that works, I believe all I need is the Id of a selling plan I create, is there any way to find that if I don't save it right when I create it.

 

nick_f
New Member
1 0 0

Hi there,

Did you ever work this out?

I am thinking I will need to track the id's as they get created since I also can't seem to find a way to query for them.

 

0 Likes