selling Plan Group Createmutation
mutation
2024-04
Requires
write_products
access scope as well as any of write_own_subscription_contracts
, write_purchase_options
access scopes. Also: The user must have manage_orders_information
permissions.
Creates a Selling Plan Group.
Arguments
The properties of the new Selling Plan Group.
The resources this Selling Plan Group should be applied to.
Was this section helpful?
SellingPlanGroupCreatePayload returns
The created selling plan group object.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Examples
Hide code
Copy
mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id } } } } userErrors { field message } } }
curl -X POST \ https://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id } } } } userErrors { field message } } }", "variables": { "input": { "name": "Delivered every week and billed every three weeks", "merchantCode": "prepaid-weekly", "options": [ "1 week" ], "sellingPlansToCreate": [ { "name": "Delivered every week", "options": "1 Week(s)", "category": "SUBSCRIPTION", "billingPolicy": { "recurring": { "interval": "WEEK", "intervalCount": 3, "anchors": [ { "cutoffDay": 2, "day": 4, "type": "WEEKDAY" } ] } }, "pricingPolicies": [ { "fixed": { "adjustmentType": "PERCENTAGE", "adjustmentValue": { "percentage": 25.0 } } } ], "deliveryPolicy": { "recurring": { "interval": "WEEK", "intervalCount": 1, "anchors": [ { "cutoffDay": 2, "day": 4, "type": "WEEKDAY" } ] } } } ] }, "resources": { "productIds": [ "gid://shopify/Product/121709582" ], "productVariantIds": [ ] } } }'
const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id } } } } userErrors { field message } } }`, { variables: { "input": { "name": "Delivered every week and billed every three weeks", "merchantCode": "prepaid-weekly", "options": [ "1 week" ], "sellingPlansToCreate": [ { "name": "Delivered every week", "options": "1 Week(s)", "category": "SUBSCRIPTION", "billingPolicy": { "recurring": { "interval": "WEEK", "intervalCount": 3, "anchors": [ { "cutoffDay": 2, "day": 4, "type": "WEEKDAY" } ] } }, "pricingPolicies": [ { "fixed": { "adjustmentType": "PERCENTAGE", "adjustmentValue": { "percentage": 25.0 } } } ], "deliveryPolicy": { "recurring": { "interval": "WEEK", "intervalCount": 1, "anchors": [ { "cutoffDay": 2, "day": 4, "type": "WEEKDAY" } ] } } } ] }, "resources": { "productIds": [ "gid://shopify/Product/121709582" ], "productVariantIds": [ ] } }, }, ); const data = await response.json();
session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id } } } } userErrors { field message } } } QUERY variables = { "input": { "name": "Delivered every week and billed every three weeks", "merchantCode": "prepaid-weekly", "options": ["1 week"], "sellingPlansToCreate": [{"name"=>"Delivered every week", "options"=>"1 Week(s)", "category"=>"SUBSCRIPTION", "billingPolicy"=>{"recurring"=>{"interval"=>"WEEK", "intervalCount"=>3, "anchors"=>[{"cutoffDay"=>2, "day"=>4, "type"=>"WEEKDAY"}]}}, "pricingPolicies"=>[{"fixed"=>{"adjustmentType"=>"PERCENTAGE", "adjustmentValue"=>{"percentage"=>25.0}}}], "deliveryPolicy"=>{"recurring"=>{"interval"=>"WEEK", "intervalCount"=>1, "anchors"=>[{"cutoffDay"=>2, "day"=>4, "type"=>"WEEKDAY"}]}}}] }, "resources": { "productIds": ["gid://shopify/Product/121709582"], "productVariantIds": [] } } response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id } } } } userErrors { field message } } }`, "variables": { "input": { "name": "Delivered every week and billed every three weeks", "merchantCode": "prepaid-weekly", "options": [ "1 week" ], "sellingPlansToCreate": [ { "name": "Delivered every week", "options": "1 Week(s)", "category": "SUBSCRIPTION", "billingPolicy": { "recurring": { "interval": "WEEK", "intervalCount": 3, "anchors": [ { "cutoffDay": 2, "day": 4, "type": "WEEKDAY" } ] } }, "pricingPolicies": [ { "fixed": { "adjustmentType": "PERCENTAGE", "adjustmentValue": { "percentage": 25.0 } } } ], "deliveryPolicy": { "recurring": { "interval": "WEEK", "intervalCount": 1, "anchors": [ { "cutoffDay": 2, "day": 4, "type": "WEEKDAY" } ] } } } ] }, "resources": { "productIds": [ "gid://shopify/Product/121709582" ], "productVariantIds": [ ] } }, }, });
use Shopify\Clients\Graphql; $client = new Graphql("your-development-store.myshopify.com", $accessToken); $query = <<<QUERY mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id } } } } userErrors { field message } } } QUERY; $variables = [ "input" => [ "name" => "Delivered every week and billed every three weeks", "merchantCode" => "prepaid-weekly", "options" => ["1 week"], "sellingPlansToCreate" => [{"name"=>"Delivered every week", "options"=>"1 Week(s)", "category"=>"SUBSCRIPTION", "billingPolicy"=>{"recurring"=>{"interval"=>"WEEK", "intervalCount"=>3, "anchors"=>[{"cutoffDay"=>2, "day"=>4, "type"=>"WEEKDAY"}]}}, "pricingPolicies"=>[{"fixed"=>{"adjustmentType"=>"PERCENTAGE", "adjustmentValue"=>{"percentage"=>25.0}}}], "deliveryPolicy"=>{"recurring"=>{"interval"=>"WEEK", "intervalCount"=>1, "anchors"=>[{"cutoffDay"=>2, "day"=>4, "type"=>"WEEKDAY"}]}}}], ], "resources" => [ "productIds" => ["gid://shopify/Product/121709582"], "productVariantIds" => [], ], ]; $response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{ "input": { "name": "Delivered every week and billed every three weeks", "merchantCode": "prepaid-weekly", "options": [ "1 week" ], "sellingPlansToCreate": [ { "name": "Delivered every week", "options": "1 Week(s)", "category": "SUBSCRIPTION", "billingPolicy": { "recurring": { "interval": "WEEK", "intervalCount": 3, "anchors": [ { "cutoffDay": 2, "day": 4, "type": "WEEKDAY" } ] } }, "pricingPolicies": [ { "fixed": { "adjustmentType": "PERCENTAGE", "adjustmentValue": { "percentage": 25 } } } ], "deliveryPolicy": { "recurring": { "interval": "WEEK", "intervalCount": 1, "anchors": [ { "cutoffDay": 2, "day": 4, "type": "WEEKDAY" } ] } } } ] }, "resources": { "productIds": [ "gid://shopify/Product/121709582" ], "productVariantIds": [] } }
Hide code
Response
JSON
{ "sellingPlanGroupCreate": { "sellingPlanGroup": { "id": "gid://shopify/SellingPlanGroup/1039518901", "sellingPlans": { "edges": [ { "node": { "id": "gid://shopify/SellingPlan/1070277392" } } ] } }, "userErrors": [] } }