GraphQL clear CompareAtPrice

Highlighted
New Member
1 0 0

Hi everyone,

we are developing an external app that can import some products into our Shopify or change some data of the existing ones (price or other).

The problem we are facing is that we can't in any way clear the CompareAtPrice field, but we might need to.

Take this case:

 

Current productVariant prices:

  • Price = 100
  • CompareAtPrice = 120

 

From our import, the price should become 120, without any discount, so we should set Price to 120 and CompareAtPrice to "blank".

We tried many mutations, setting CompareAtPrice to 0, '', nil, ... but nothing worked.

 

How should we fix that case? We really need to be able to update our prices eventually removing the discount.

 

That's our mutation (example)

mutation
{
productVariantUpdate(input:
{
id: \"gid://shopify/ProductVariant/..\",
title: \" Variant title\",
sku: \"Variant SKU\",
barcode: \"Variant Barcode\",
price: \"100\",
compareatprice: nil,
})
{
productVariant
{
id
}
userErrors
{
field message
}
}
}

 

What should we do?

 

thanks all!

0 Likes
Highlighted
Shopify Expert
4 0 1

Hey - Did you manage to solve this?

 

Clearing fields in general is pretty key.

 

0 Likes