A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Has anyone been able to fully remove a compareAtPrice from a price list using the priceListFixedPricesAdd mutation? It seems like it sets the compareAtPrice to be the same as the price when either leaving it out of the input or setting it to null. Leads to the price being struck through on the front end with the same price next to it which is not ideal. Mutation below:
thanks
mutation priceListFixedPricesAdd(
$priceListId: ID!,
$prices: [PriceListPriceInput!]!
) {
priceListFixedPricesAdd(priceListId: $priceListId, prices: $prices) {
prices {
variant {
id
}
}
userErrors {
field
message
}
}
}
Solved! Go to the solution
This is an accepted solution.
Hey @Luke-CN ,
Thanks for sharing this. It's an interesting one. I was testing on my end and was able to remove it by setting the compare at as null. Here's an example of my mutation.
mutation {
priceListFixedPricesUpdate(
priceListId: "gid://shopify/PriceList/123456",
pricesToAdd: [
{
compareAtPrice: null,
price: {
amount: "13.0",
currencyCode: CAD
},
variantId: "gid://shopify/ProductVariant/123456"
}
],
variantIdsToDelete: []
) {
deletedFixedPriceVariantIds
priceList {
id
}
pricesAdded {
compareAtPrice {
amount
currencyCode
}
}
userErrors {
field
message
}
}
}
When I query the price list after, it also returns null for this field.
If you're theme is still showing the same price crossed off I would recommend looking in to your theme code to make sure the compare at price is only shown when the value is greater than the current price.
Hope that helps.
- Kyle G.
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
This is an accepted solution.
Hey @Luke-CN ,
Thanks for sharing this. It's an interesting one. I was testing on my end and was able to remove it by setting the compare at as null. Here's an example of my mutation.
mutation {
priceListFixedPricesUpdate(
priceListId: "gid://shopify/PriceList/123456",
pricesToAdd: [
{
compareAtPrice: null,
price: {
amount: "13.0",
currencyCode: CAD
},
variantId: "gid://shopify/ProductVariant/123456"
}
],
variantIdsToDelete: []
) {
deletedFixedPriceVariantIds
priceList {
id
}
pricesAdded {
compareAtPrice {
amount
currencyCode
}
}
userErrors {
field
message
}
}
}
When I query the price list after, it also returns null for this field.
If you're theme is still showing the same price crossed off I would recommend looking in to your theme code to make sure the compare at price is only shown when the value is greater than the current price.
Hope that helps.
- Kyle G.
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog