How to remove pricing policies?

Mixlogue
Visitor
2 0 2

 

I want to delete the pricingPolicies in sellingPlanGroupUpdate mutation, but it doesn't work.

 

mutation {
  sellingPlanGroupUpdate(
    id: "gid://shopify/SellingPlanGroup/XXXXXX"
    input: {
      sellingPlansToUpdate: [
        {
          id: "gid://shopify/SellingPlan/XXXXXX", 
          pricingPolicies: [] // or null?
        }
      ]
    }
  ) {
    sellingPlanGroup {
      id
    }
    userErrors {
      field
      message
    }
  }
}

 

Running the above GraphQL mutation does not remove the pricing policy.
What is the correct way to write the input to remove the pricing policies?

Please help us.
Thank you.

Replies 3 (3)

kyle_truong
Shopify Partner
59 6 16

Any updates to this? I recently ran into this problem as well.

Creating pricing policies is no problem but updating them is odd. The documentation points to a "discountId" but there is no ID for the SellingPlanPricingPolicy type. Setting the pricingPolicies field to an empty array or null also does not remove or update the existing pricing policies of the selling plan.

https://shopify.dev/tutorials/create-and-manage-discounts-on-subscriptions#update-a-discount-on-a-su...
https://shopify.dev/docs/admin-api/graphql/reference/products-and-collections/sellingplanpricingpoli...

Edit:

Sometimes it works and sometimes it breaks. When it breaks, I get this message for the following sellingPlanGroupUpdate query:


errors\":[{\"message\":\"Internal error. Looks like something went wrong on our end.\\nRequest ID: 494e4f06-42b8-410c-b67e-1eca4a2cfc90 (include this in support requests)

 

 

{
  "appId": "testApp",
  "merchantCode": "ccc",
  "name": "ccc",
  "options": [
    "Delivery frequency"
  ],
  "sellingPlansToCreate": [],
  "sellingPlansToUpdate": [
    {
      "billingPolicy": {
        "recurring": {
          "anchors": [],
          "interval": "MONTH",
          "intervalCount": 2,
          "maxCycles": null,
          "minCycles": null
        }
      },
      "deliveryPolicy": {
        "recurring": {
          "anchors": [],
          "cutoff": null,
          "intent": "FULFILLMENT_BEGIN",
          "interval": "MONTH",
          "intervalCount": 2,
          "preAnchorBehavior": "ASAP"
        }
      },
      "description": "",
      "id": "gid://shopify/SellingPlan/476840093",
      "name": "ccccc",
      "position": 0,
      "options": [
        "ccccc-0"
      ],
      "pricingPolicies": [
        {
          "fixed": {
            "adjustmentType": "PERCENTAGE",
            "adjustmentValue": {
              "percentage": 3
            }
          }
        },
        {
          "recurring": {
            "adjustmentType": "PERCENTAGE",
            "adjustmentValue": {
              "percentage": 4
            },
            "afterCycle": 2
          }
        }
      ]
    }
  ],
  "sellingPlansToDelete": []
}

 


It also breaks quite a lot when I try to update a selling plan with existing pricingPolicies to one without.




freya0328
Pathfinder
140 1 6

Have you solved this problem?

banned
Philibert_Dugas
Shopify Staff
36 13 16

Hey there,

Using the latest version of the API `2021-07` you should now be able to use the initial mutation described to delete pricing policies with `pricingPolicies: []`

 

To learn more visit the Shopify Help Center or the Community Blog.