GraphQL clear CompareAtPrice

MudAndSnow
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
Jonny8
Shopify Expert
4 0 2

Hey - Did you manage to solve this?

 

Clearing fields in general is pretty key.

 

0 Likes
FrankAuwers
New Member
2 0 0

I have the same problem.

If we don't wont a compareAtPrice anymore, we must be able to clear it out.

I can't find any Rest API or GraphQL instruction for this.

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 237

This worked for me using the GraphQL API. See below. Hope this helps!

Untitled1.pngUntitled2.pngUntitled3.png