Anchor to sellingPlanGroupUpdateselling
sellingPlanGroupUpdate
mutation
Requires access scope as well as any of
,
access scopes. Also: The user must have
permissions.
Update a Selling Plan Group.
Anchor to Arguments
Arguments
- •ID!required
The Selling Plan Group to update.
- Anchor to inputinput•Selling
Plan requiredGroup Input! The properties of the Selling Plan Group to update.
Was this section helpful?
Anchor to SellingPlanGroupUpdatePayload returnsSellingPlanGroupUpdatePayload returns
- Anchor to deletedSellingPlanIdsdeleted•
Selling Plan Ids The IDs of the deleted Subscription Plans.
- Anchor to sellingPlanGroupselling•
Plan Group The updated Selling Plan Group.
- Anchor to userErrorsuser•
Errors [SellingPlan non-nullGroup User Error!]! The list of errors that occurred from executing the mutation.
Was this section helpful?
- Update a selling plan group and its metafields
- sellingPlanGroupUpdate reference
Examples
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 mutation sellingPlanGroupUpdate($id: ID!, $input: SellingPlanGroupInput!) {6 sellingPlanGroupUpdate(id: $id, input: $input) {7 sellingPlanGroup {8 id9 sellingPlans(first: 1) {10 edges {11 node {12 id13 metafields(first: 1) {14 edges {15 node {16 id17 namespace18 key19 value20 }21 }22 }23 }24 }25 }26 }27 userErrors {28 field29 message30 }31 }32 }`,33 {34 variables: {35 "id": "gid://shopify/SellingPlanGroup/964742479",36 "input": {37 "sellingPlansToUpdate": [38 {39 "id": "gid://shopify/SellingPlan/563068713",40 "metafields": [41 {42 "value": "waterproof",43 "type": "single_line_text_field",44 "key": "test_key",45 "namespace": "example-selling-plan"46 }47 ]48 }49 ]50 }51 },52 },53);5455const data = await response.json();56
mutation sellingPlanGroupUpdate($id: ID!, $input: SellingPlanGroupInput!) {
sellingPlanGroupUpdate(id: $id, input: $input) {
sellingPlanGroup {
id
sellingPlans(first: 1) {
edges {
node {
id
metafields(first: 1) {
edges {
node {
id
namespace
key
value
}
}
}
}
}
}
}
userErrors {
field
message
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation sellingPlanGroupUpdate($id: ID!, $input: SellingPlanGroupInput!) { sellingPlanGroupUpdate(id: $id, input: $input) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id metafields(first: 1) { edges { node { id namespace key value } } } } } } } userErrors { field message } } }",
"variables": {
"id": "gid://shopify/SellingPlanGroup/964742479",
"input": {
"sellingPlansToUpdate": [
{
"id": "gid://shopify/SellingPlan/563068713",
"metafields": [
{
"value": "waterproof",
"type": "single_line_text_field",
"key": "test_key",
"namespace": "example-selling-plan"
}
]
}
]
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation sellingPlanGroupUpdate($id: ID!, $input: SellingPlanGroupInput!) {
sellingPlanGroupUpdate(id: $id, input: $input) {
sellingPlanGroup {
id
sellingPlans(first: 1) {
edges {
node {
id
metafields(first: 1) {
edges {
node {
id
namespace
key
value
}
}
}
}
}
}
}
userErrors {
field
message
}
}
}`,
{
variables: {
"id": "gid://shopify/SellingPlanGroup/964742479",
"input": {
"sellingPlansToUpdate": [
{
"id": "gid://shopify/SellingPlan/563068713",
"metafields": [
{
"value": "waterproof",
"type": "single_line_text_field",
"key": "test_key",
"namespace": "example-selling-plan"
}
]
}
]
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation sellingPlanGroupUpdate($id: ID!, $input: SellingPlanGroupInput!) {
sellingPlanGroupUpdate(id: $id, input: $input) {
sellingPlanGroup {
id
sellingPlans(first: 1) {
edges {
node {
id
metafields(first: 1) {
edges {
node {
id
namespace
key
value
}
}
}
}
}
}
}
userErrors {
field
message
}
}
}`,
"variables": {
"id": "gid://shopify/SellingPlanGroup/964742479",
"input": {
"sellingPlansToUpdate": [
{
"id": "gid://shopify/SellingPlan/563068713",
"metafields": [
{
"value": "waterproof",
"type": "single_line_text_field",
"key": "test_key",
"namespace": "example-selling-plan"
}
]
}
]
}
},
},
});
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 sellingPlanGroupUpdate($id: ID!, $input: SellingPlanGroupInput!) {
sellingPlanGroupUpdate(id: $id, input: $input) {
sellingPlanGroup {
id
sellingPlans(first: 1) {
edges {
node {
id
metafields(first: 1) {
edges {
node {
id
namespace
key
value
}
}
}
}
}
}
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"id": "gid://shopify/SellingPlanGroup/964742479",
"input": {
"sellingPlansToUpdate": [{"id"=>"gid://shopify/SellingPlan/563068713", "metafields"=>[{"value"=>"waterproof", "type"=>"single_line_text_field", "key"=>"test_key", "namespace"=>"example-selling-plan"}]}]
}
}
response = client.query(query: query, variables: variables)
Input variables
JSON1{2 "id": "gid://shopify/SellingPlanGroup/964742479",3 "input": {4 "sellingPlansToUpdate": [5 {6 "id": "gid://shopify/SellingPlan/563068713",7 "metafields": [8 {9 "value": "waterproof",10 "type": "single_line_text_field",11 "key": "test_key",12 "namespace": "example-selling-plan"13 }14 ]15 }16 ]17 }18}
Response
JSON1{2 "sellingPlanGroupUpdate": {3 "sellingPlanGroup": {4 "id": "gid://shopify/SellingPlanGroup/964742479",5 "sellingPlans": {6 "edges": [7 {8 "node": {9 "id": "gid://shopify/SellingPlan/563068713",10 "metafields": {11 "edges": [12 {13 "node": {14 "id": "gid://shopify/Metafield/616145134",15 "namespace": "example-selling-plan",16 "key": "test_key",17 "value": "waterproof"18 }19 }20 ]21 }22 }23 }24 ]25 }26 },27 "userErrors": []28 }29}