Hi there,
I have a variable product which I need to update the selected variables via JavaScript. Basically the variable on the value of a select box which I have added to the product template.
$('#translate-to').on('change',function() {
const selected = $(this).find('option:selected');
const val = selected.attr('value');
const tier = selected.data('tier');
$('.option_languagetier option').removeAttr('selected').filter('[value='+tier+']').attr('selected','selected').trigger('change');
})
The variable select box gets updated and assigned the correct value, however the product variant doesn’t get updated, and so the product price isn’t updated.
If I manually select an option in the variable ‘.option_languagetier’ the product price gets updated properly, but not when I change the select value dynamically with JS. As far as I can tell using .trigger(‘change’) doesn’t execute the theme’s update variants functions.
The Shopify theme I’m using is Debut.
Any help?
Thanks in advance,
Matt.