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
- sellingPlanGroupCreate reference
Examples
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"
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": "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
JSON{
"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": {
Response
JSON{
"sellingPlanGroupCreate": {
"sellingPlanGroup": {
"id": "gid://shopify/SellingPlanGroup/1039518935",
"sellingPlans": {
"edges": [
{
"node": {
"id": "gid://shopify/SellingPlan/1070277430"
}
}
]
}
},
"userErrors": []
}
}