Change variation of product with JavaScript
-
Hey all! I would like to change the variant of a product using JavaScript. To do this, I change the value of the corresponding select field and then trigger the change.
$('.variations input').change(function() { let value = $(this).val(); $(this).parents('.variations').find('select').val(value); $('.variations select').trigger('change'); });
The value of the select fields also changes, however Woocommerce does not seem to register the change as I cannot add the product to the cart. Only when I manually selected a value again via the select fields, this seems to work.
Do I need to notify another element about the change?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Change variation of product with JavaScript’ is closed to new replies.