Created
July 31, 2013 15:09
-
-
Save kyleaparker/6122816 to your computer and use it in GitHub Desktop.
Shopify - Add percentage saved to the price in the Select callback.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---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