Skip to content

Instantly share code, notes, and snippets.

@Alphabetus
Last active June 25, 2019 10:13
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 Alphabetus/000f9f7461ce0136f480945ce0c31dc1 to your computer and use it in GitHub Desktop.
Save Alphabetus/000f9f7461ce0136f480945ce0c31dc1 to your computer and use it in GitHub Desktop.
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