Shopify Function to Apply discount to the compare at price instead of variant price

ShreyankJ
Shopify Partner
2 0 0

Hello,

    We are currently migrating from Shopify scripts to one-page checkout and are developing an extension that applies the product discount to certain customers based on the tag. What we want to do is,

   if a product is on sale, i.e. variant has a compare-at-price value, then apply the discount to the compare-at price and if the compare-at price is null then apply the discount to the regular price.

 

Wondering if this is possible with product discount functions or any other functions. If so, how can we achieve this?

 

Greatly appreciate your time for reading and your input.

 

Thanks !!

Replies 2 (2)

MastersHub
Shopify Partner
215 20 38

I had the same problem as you. I'm currently developing the transition from script to function. We cannot access the compare at input in the product discount api. My client and I developed a solution by moving the compare at input to the metafield. We can also access the Metafield area through the product discount API. If there are not many products and variants, I recommend you move the compare at input to the metafield. If it is not possible to move manually, it makes more sense to move it by programming.

Helpful ? Like and Accept Solution
Buy me a Coffee
Need a Shopify Developer?
Send Email or Chat on WhatsApp
ShreyankJ
Shopify Partner
2 0 0

That is one way to do it if you have fewer products, unfortunately, we have lots of different products with variants and the sale is done by the marketing team through the Launchpad app, which does this compare-at-price thing when the sale is live hence I needed somehow the access to compare at price, however, this does not look possible with product discount API at this moment. 

 

I thought this would be a simple use case but oh well, I spent a whole lot of time thinking the solutions from different angles. Anyways, thanks for replying and for the great suggestion.