Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Selectize.js update custom tax container
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
You can’t perform that action at this time.