Re: Cannot delete option values and the variants referencing that option with productOptionUpdate

Solved

Cannot delete option values and the variants referencing that option with productOptionUpdate

jam_chan
Shopify Partner
909 23 185

I'm trying to delete variants with an option value following this thread. I want to use the variantStrategy of MANAGE to delete an option value and the related variants. The doc states that:

If an option value is deleted, all variants referencing that option value will be deleted.

 

But it gives me an error in the Shopify GraphiQL App:

{
  "data": {
    "productOptionUpdate": {
      "userErrors": [
        {
          "field": [
            "optionValuesToDelete",
            "0"
          ],
          "message": "Cannot delete an option value that is currently associated with a variant with the selected variant strategy.",
          "code": "OPTION_VALUE_HAS_VARIANTS"
        }
      ],
}
}
}

Why does the

My graphql:

mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToDelete: [ID!]) {
  productOptionUpdate(productId: $productId, option: $option, optionValuesToDelete: $optionValuesToDelete) {
    userErrors {
      field
      message
      code
    }
    product {
      id
      options {
        id
        name
        values
        position
        optionValues {
          id
          name
          hasVariants
        }
      }
      variants(first: 5) {
        nodes {
          id
          title
          selectedOptions {
            name
            value
          }
        }
      }
    }
  }
}

My input variable:

{
  "productId": "gid://shopify/Product/7917543227547",
  "option": {
    "id": "gid://shopify/ProductOption/10157249953947"
  },
  "optionValuesToDelete": [
    "gid://shopify/ProductOptionValue/3185625858203"
  ],
  "variantStrategy": "MANAGE"
}

Why is the variantStrategy not working? The error message ("Cannot delete an option value that is currently associated with a variant with the selected variant strategy.) seems like contradicts the variantStrategy mentioned in the doc 

 

BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview
Accepted Solution (1)

Eric-HAN
Shopify Partner
105 15 8

This is an accepted solution.

Hi, there

 

you missing one param in your graphql input , see below pic 

EricHAN_0-1717661724739.png

 

- Helpful? Please hit Like and mark it as a solution
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me    Buy Me A Coffee

View solution in original post

Replies 3 (3)

AsafGitai
Shopify Staff
50 8 11

Hi @jam_chan,

 

That indeed sounds odd, we will look into this and get back to you

Eric-HAN
Shopify Partner
105 15 8

This is an accepted solution.

Hi, there

 

you missing one param in your graphql input , see below pic 

EricHAN_0-1717661724739.png

 

- Helpful? Please hit Like and mark it as a solution
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me    Buy Me A Coffee
AsafGitai
Shopify Staff
50 8 11

Thanks @Eric-HAN, totally missed that - will mark as solution for now.

@jam_chan let us know if you still have an issue