Anchor to sellingPlanGroupCreateselling
sellingPlanGroupCreate
mutation
Requires access scope as well as any of
,
access scopes. Also: The user must have
permissions.
Creates a Selling Plan Group.
Anchor to Arguments
Arguments
- Anchor to inputinput•Selling
Plan requiredGroup Input! The properties of the new Selling Plan Group.
- Anchor to resourcesresources•
The resources this Selling Plan Group should be applied to.
Was this section helpful?
Anchor to SellingPlanGroupCreatePayload returnsSellingPlanGroupCreatePayload returns
- Anchor to sellingPlanGroupselling•
Plan Group The created selling plan group object.
- Anchor to userErrorsuser•
Errors [SellingPlan non-nullGroup User Error!]! The list of errors that occurred from executing the mutation.
Was this section helpful?
- Create a TBYB selling plan group
- Create a prepaid selling plan group with anchor dates
- Create a selling plan group with metafields
- sellingPlanGroupCreate reference
Examples
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) {6 sellingPlanGroupCreate(input: $input, resources: $resources) {7 sellingPlanGroup {8 id9 sellingPlans(first: 1) {10 edges {11 node {12 id13 }14 }15 }16 }17 userErrors {18 field19 message20 }21 }22 }`,23 {24 variables: {25 "input": {26 "name": "TBYB",27 "merchantCode": "tbyb",28 "options": [29 "Try before you buy"30 ],31 "sellingPlansToCreate": [32 {33 "name": "TBYB",34 "options": "Try free for 14 days",35 "category": "TRY_BEFORE_YOU_BUY",36 "billingPolicy": {37 "fixed": {38 "checkoutCharge": {39 "type": "PRICE",40 "value": {41 "fixedValue": 042 }43 },44 "remainingBalanceChargeTrigger": "TIME_AFTER_CHECKOUT",45 "remainingBalanceChargeTimeAfterCheckout": "P14D"46 }47 },48 "inventoryPolicy": {49 "reserve": "ON_SALE"50 },51 "deliveryPolicy": {52 "fixed": {53 "fulfillmentTrigger": "ASAP"54 }55 }56 }57 ]58 },59 "resources": {60 "productIds": [61 "gid://shopify/Product/121709582"62 ],63 "productVariantIds": []64 }65 },66 },67);6869const data = await response.json();70
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-07/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": "TBYB",
"merchantCode": "tbyb",
"options": [
"Try before you buy"
],
"sellingPlansToCreate": [
{
"name": "TBYB",
"options": "Try free for 14 days",
"category": "TRY_BEFORE_YOU_BUY",
"billingPolicy": {
"fixed": {
"checkoutCharge": {
"type": "PRICE",
"value": {
"fixedValue": 0
}
},
"remainingBalanceChargeTrigger": "TIME_AFTER_CHECKOUT",
"remainingBalanceChargeTimeAfterCheckout": "P14D"
}
},
"inventoryPolicy": {
"reserve": "ON_SALE"
},
"deliveryPolicy": {
"fixed": {
"fulfillmentTrigger": "ASAP"
}
}
}
]
},
"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": "TBYB",
"merchantCode": "tbyb",
"options": [
"Try before you buy"
],
"sellingPlansToCreate": [
{
"name": "TBYB",
"options": "Try free for 14 days",
"category": "TRY_BEFORE_YOU_BUY",
"billingPolicy": {
"fixed": {
"checkoutCharge": {
"type": "PRICE",
"value": {
"fixedValue": 0
}
},
"remainingBalanceChargeTrigger": "TIME_AFTER_CHECKOUT",
"remainingBalanceChargeTimeAfterCheckout": "P14D"
}
},
"inventoryPolicy": {
"reserve": "ON_SALE"
},
"deliveryPolicy": {
"fixed": {
"fulfillmentTrigger": "ASAP"
}
}
}
]
},
"resources": {
"productIds": [
"gid://shopify/Product/121709582"
],
"productVariantIds": []
}
},
},
);
const data = await response.json();
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": "TBYB",
"merchantCode": "tbyb",
"options": [
"Try before you buy"
],
"sellingPlansToCreate": [
{
"name": "TBYB",
"options": "Try free for 14 days",
"category": "TRY_BEFORE_YOU_BUY",
"billingPolicy": {
"fixed": {
"checkoutCharge": {
"type": "PRICE",
"value": {
"fixedValue": 0
}
},
"remainingBalanceChargeTrigger": "TIME_AFTER_CHECKOUT",
"remainingBalanceChargeTimeAfterCheckout": "P14D"
}
},
"inventoryPolicy": {
"reserve": "ON_SALE"
},
"deliveryPolicy": {
"fixed": {
"fulfillmentTrigger": "ASAP"
}
}
}
]
},
"resources": {
"productIds": [
"gid://shopify/Product/121709582"
],
"productVariantIds": []
}
},
},
});
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": "TBYB",
"merchantCode": "tbyb",
"options": ["Try before you buy"],
"sellingPlansToCreate": [{"name"=>"TBYB", "options"=>"Try free for 14 days", "category"=>"TRY_BEFORE_YOU_BUY", "billingPolicy"=>{"fixed"=>{"checkoutCharge"=>{"type"=>"PRICE", "value"=>{"fixedValue"=>0}}, "remainingBalanceChargeTrigger"=>"TIME_AFTER_CHECKOUT", "remainingBalanceChargeTimeAfterCheckout"=>"P14D"}}, "inventoryPolicy"=>{"reserve"=>"ON_SALE"}, "deliveryPolicy"=>{"fixed"=>{"fulfillmentTrigger"=>"ASAP"}}}]
},
"resources": {
"productIds": ["gid://shopify/Product/121709582"],
"productVariantIds": []
}
}
response = client.query(query: query, variables: variables)
Input variables
JSON1{2 "input": {3 "name": "TBYB",4 "merchantCode": "tbyb",5 "options": [6 "Try before you buy"7 ],8 "sellingPlansToCreate": [9 {10 "name": "TBYB",11 "options": "Try free for 14 days",12 "category": "TRY_BEFORE_YOU_BUY",13 "billingPolicy": {14 "fixed": {15 "checkoutCharge": {16 "type": "PRICE",17 "value": {18 "fixedValue": 019 }20 },21 "remainingBalanceChargeTrigger": "TIME_AFTER_CHECKOUT",22 "remainingBalanceChargeTimeAfterCheckout": "P14D"23 }24 },25 "inventoryPolicy": {26 "reserve": "ON_SALE"27 },28 "deliveryPolicy": {29 "fixed": {30 "fulfillmentTrigger": "ASAP"31 }32 }33 }34 ]35 },36 "resources": {37 "productIds": [38 "gid://shopify/Product/121709582"39 ],40 "productVariantIds": []41 }42}
Response
JSON1{2 "sellingPlanGroupCreate": {3 "sellingPlanGroup": {4 "id": "gid://shopify/SellingPlanGroup/1039518935",5 "sellingPlans": {6 "edges": [7 {8 "node": {9 "id": "gid://shopify/SellingPlan/1070277430"10 }11 }12 ]13 }14 },15 "userErrors": []16 }17}