For discussing the development and integration of subscription-enabled shops using Shopify's Subscription APIs.
The easiest way I found to reproduce this is to create a selling plan group with no pricing policies and then update it with both a fixed and recurring pricing policy.
My mutation query looks like this (excluding most of the non-pricing policy data):
mutation (
$id: ID!,
$input: SellingPlanGroupInput
) {
sellingPlanGroupUpdate(
id: $id,
input: $input
) {
sellingPlanGroup {
sellingPlans(first: 25) {
edges {
node {
id
createdAt
description
name
pricingPolicies {
...on SellingPlanFixedPricingPolicy {
adjustmentType
adjustmentValue {
...on SellingPlanPricingPolicyPercentageValue {
percentage
}
...on MoneyV2 {
amount
}
}
createdAt
}
...on SellingPlanRecurringPricingPolicy {
adjustmentType
adjustmentValue {
...on SellingPlanPricingPolicyPercentageValue {
percentage
}
...on MoneyV2 {
amount
}
}
createdAt
afterCycle
}
}
}
}
}
}
userErrors {
code
field
message
}
}
}
and my input:
{
"appId": "test",
"merchantCode": "asdasd",
"name": "asd",
"options": [
"Delivery frequency"
],
"sellingPlansToUpdate": [
{
"pricingPolicies": [
{
"fixed": {
"adjustmentType": "PERCENTAGE",
"adjustmentValue": {
"percentage": 10
}
}
},
{
"recurring": {
"adjustmentType": "PERCENTAGE",
"adjustmentValue": {
"percentage": 20
},
"afterCycle": 2
}
}
]
}
]
}
and Shopify's response:
...
sellingPlanGroupUpdate": {
"deletedSellingPlanIds": [],
"sellingPlanGroup": {
"id": "gid://shopify/SellingPlanGroup/92209309",
"appId": "kasb",
"createdAt": "2021-06-11T22:35:31Z",
"description": null,
"merchantCode": "asdasd",
"name": "asd",
"position": null,
"summary": "1 delivery frequency, 10% discount",
"options": [
"Delivery frequency"
],
"sellingPlans": {
"edges": [
{
"node": {
"id": "gid://shopify/SellingPlan/477692061",
"createdAt": "2021-06-11T22:35:31Z",
"pricingPolicies": [
{
"adjustmentType": "PERCENTAGE",
"adjustmentValue": {
"percentage": 10
},
"createdAt": "2021-06-11T22:35:47Z"
}
]
}
}
]
}
},
"userErrors": []
}
In the above example, Shopify doesn't respond with the recurring pricing policy. I've tried a similar input structure for creating sellingPlanGroups with pricing policies and it works fine, it just doesn't work as expected with updates. I'm not sure the reason for the differences but I also see this happening in many of my other update queries that involve pricing policies.
Is there something I'm missing, or is there a better way to go about updating pricing policies?
Solved! Go to the solution
This is an accepted solution.
Nevermind, it works now.
This is an accepted solution.
Nevermind, it works now.