I have 2 time the same variation on my Woo product page. I try to apply the changes of the first variation of a product lets say "Size: M" to the second variation on the same page.
I tried this code but no sucesss - i am still learning ....
Can you help with this ?
jQuery(document).ready(function($) {// Get the first variation elementvar firstVariation = $('.elementor-product-variable:eq(0)');
// Get the second variation elementvar secondVariation = $('.elementor-product-variable:eq(1)');
// Listen for changes in the first variationfirstVariation.on('change', '.variations select', function() {// Get the selected optionsvar selectedOptions = $(this).find('option:selected');
// Apply the same selection to the second variation
selectedOptions.each(function() {
var attribute = $(this).parent().data('attribute_name');
var value = $(this).val();
secondVariation.find('.variations select[data-attribute_name="' + attribute + '"]').val(value).trigger('change');
});
});});