Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hi there, I want to get which selling plan associate with the product variants using storefront graphql API, I have already gotten the selling plan groups for the product, but not able to get which plan is associated with product variants. also, I have tried the "sellingPlanAllocations" (Ref :- https://shopify.dev/api/storefront/2022-04/objects/SellingPlanAllocation) connection but it gives me an error "Field 'sellingPlanAllocations' doesn't exist on type 'ProductVariant'".
Here is my storefront graphql code (i am not able to put whole code here so i add shorter version)
product(id: "gid://shopify/Product/'.$prd_list.'") {
variants(first: 10){
edges{
node{
id
sellingPlanAllocations{
edges{
node{
id
}
}
}
}
and the code gives me an error: message: "Field 'sellingPlanAllocations' doesn't exist on type 'ProductVariant'" please provide me a way to fix this. Thanks
Hey @Snehal64
What version of the storefront API are you using?
In the 2022-04 version you linked there is a Product
The selling
Cheers,
JamesG | API Support @ 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
Hi JamesG,
Thanks for reply.
I am using 2022-04 API Version.
Can you please send me example of the "sellingPlanAllocations" query with product variant?
Thanks.
Hey @Snehal64
To find a selling plan id for the variant's on a product I used this with the storefront API :
endpoint:
https://{{store}}.myshopify.com/api/2022-04/graphql.json
query:
query productSellingPlans($product: ID!) {
product(id: $product) {
variants(first: 3) {
edges {
node {
id
title
sellingPlanAllocations(first: 1) {
edges {
node {
sellingPlan{
id
}
}
}
}
}
}
}
}
}
hope that helps
JamesG | API Support @ 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