Skip to content

Instantly share code, notes, and snippets.

@kyleaparker
Created July 31, 2013 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyleaparker/6122816 to your computer and use it in GitHub Desktop.
Save kyleaparker/6122816 to your computer and use it in GitHub Desktop.
Shopify - Add percentage saved to the price in the Select callback.
---Find the select callback:
var selectCallback = function(variant, selector) {
if (variant && variant.available) {
---Add this with the select callback:
var per_saved = ((variant.compare_at_price - variant.price)/variant.compare_at_price)* 100.0;
$('.options .price').html('<strong>'+Shopify.formatMoney(variant.price, "{{shop.money_with_currency_format }}").toString().replace(',', '.') + '</strong><span class="compare_at_price"><del>' + Shopify.formatMoney(variant.compare_at_price, "{{shop.money_with_currency_format}}").toString().replace(',', '.') + '</del><br>You save ' + per_saved + '%</span>');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment