query sellingPlanGroup from sellingPlan

Shopify Partner
20 2 3

GraphQL API can query Order.LineItems.SellingPlan.SellingPlanId


I can use query node(id:"sellingPlanIdHere") and obtain the selling plan from the sellingPlanId.


However, I also need to get the group for the selling plan. The selling plan does not have a `sellingPlanGroupId` property and neither does the line item . Is there a way to obtain the selling plan group from the selling plan without hunting through all the product's selling plans? (would be too inefficient and likely exceed throttle)

Replies 3 (3)

Shopify Staff
29 7 5

Hello @appdev2023!

We currently do not return the `sellingPlanGroupId` as part of the `sellingPlan`, but I will pass along this feedback to the team!


One other option, is that we can expose the `sellingPlanGroups` that are linked to the `Product`:


However, I realize that is also not the best solution as a single product can have multiple selling plan groups, each with multiple selling plans.

Josh (aka Master Chief) | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Shopify Partner
20 2 3

This actually will be immediately rejected by shopify throttle. hunt through unknown # products * unknown # groups * unknown # plans... it is just too much (ex: first10products*first10groups*first10plans is already 1000)


Any one of the following would resolve this:

  1. add a LineItemSellingPlanGroup as a property of LineItem
  2. add sellingPlanGroupId as a property of LineItemSellingPlan 
  3. add sellingPlan & sellingPlanGroup as connections on LineItem. (this is better than the one-off LineItemSellingPlan type) 
  4. add sellingPlanGroup as a connection on SellingPlan

Of course, #4 is preferable because the benefit isn't limited to line items.