Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

How to remove a compareAtPrice from a price list using priceListFixedPricesAdd

Solved

How to remove a compareAtPrice from a price list using priceListFixedPricesAdd

Luke-C
Shopify Partner
2 0 0

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
}
}
}
Accepted Solution (1)

ShopifyDevSup
Shopify Staff
1453 238 527

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

View solution in original post

Reply 1 (1)

ShopifyDevSup
Shopify Staff
1453 238 527

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