How to automatically set compare at prices to be 20% more than sale prices?

Hi,

I have reduced all of my prices manually to the sale price (20% off the original price) but I would like to add the “compare at price” to be 20% more than my sale price.

I have over 5,000 products so bulk editing each compare at price is impossible.

How can I add a code so that it automatically creates my “compare at price” to be 20% more than my current “price”? I would essentially want to divide my current price by .80 to get my compare at price.

I found this code but not sure how to use it or if there is a better option?

/* Bulk update prices */

var prices = $('input[name^="product[variants_attributes]"][name$="[price]"]');

var compare_at = $('input[name^="product[variants_attributes]"][name$="[compare_at_price]"]');

var percentage = 0.2;

$.each(prices, function(key, price){

   $(compare_at[key]).val($(price).val());

   $(compare_at[key]).trigger("change");

   $(price).val( ($(price).val() - ($(price).val() * percentage)).toFixed(2) );

   $(price).trigger("change");
});

/* Revert price updates */

var prices = $('input[name^="product[variants_attributes]"][name$="[price]"]');

var compare_at = $('input[name^="product[variants_attributes]"][name$="[compare_at_price]"]');

$.each(compare_at, function(key, value){

   $(prices[key]).val($(value).val()).trigger("change");

   $(value).val('').trigger("change");

});

in this i have to code customize can you please add me as staff member

Hi @Diamond2

Just so I understand, you want to fill the compare at price field inside the Shopify backend correct? If this is the case, I suggest you use the following app to do just that: Ablestar Bulk Product Editor – Ecommerce Plugins for Online Stores – Shopify App Store

There is a free plan available that will solve this for you.

Let me know if you require assistance on that!

Hey @Diamond2 ! I have just made an app for that: Laine: Sales Manager.

I would be happy to have your feedback ! There is a free plan

Best