Last active
June 25, 2019 10:13
-
-
Save Alphabetus/000f9f7461ce0136f480945ce0c31dc1 to your computer and use it in GitHub Desktop.
Selectize.js update custom tax container
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
jQuery('.single-option-selector').selectize({ | |
{% if shop.currency_code == "EUR" %} | |
{% assign money_symbol = "€" %} | |
{% endif %} | |
{% if shop.currency_code == "USD" %} | |
{% assign money_symbol = "$" %} | |
{% endif %} | |
onChange: function(value){ | |
$(".tax_amount_display").text(""); | |
setTimeout(function(){ | |
$.ajax({ | |
url: "{{product.url}}" + ".json", | |
type: "GET", | |
success: function(data) { | |
if (data.product.id == getUrlParameter("variant")) { | |
$(".tax_amount_display").text(Shopify.formatMoney(data.product.tax_amount, "{{ shop.money_format }}") + " {{money_symbol}}") | |
} | |
else { | |
for (x = 0; x < data.product.variants.length; x++) { | |
if (data.product.variants[x].product.id == getUrlParameter("variant")) { | |
// console.log(data.product.variants[x]) | |
$.ajax({ | |
url: data.product.variants[x].product.full_url + ".json", | |
type: "GET", | |
success: function(data_inner) { | |
$(".tax_amount_display").text(Shopify.formatMoney(data_inner.product.tax_amount, "{{ shop.money_format }}") + " {{money_symbol}}") | |
} | |
}); | |
} | |
} | |
} | |
} | |
}) | |
}, 50); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment