Wow! Thank you for this awesome answer!
Nike, Adidas and Puma have different sizes though, so Its a little more complicated :/ Btw I’m gonna use your snippet for sure!
Anyway, I’ve managed to do it with the use of Advanced Custom Fields plugin. I’ve added 3 more custom fields in the Attribute -size- (UK, US, CM). So if I click in an attr then I can put some more info. Then I’ve added some data-attr for each region and with JS I’ve managed to do the switch but adding and removing classes for show/hide.
Here is a php snippet
$us_size = get_field('us_size', $term);
$uk_size = get_field('uk_size', $term);
$cm_size = get_field('cm_size', $term);
printf( '<div class="sizeRadio">
<input type="radio" name="%1$s" value="%2$s" id="%3$s" %4$s>
<label for="%3$s">
<span class="label_show" data-region="eu">%5$s</span>
<span data-region="us">%6$s</span>
<span data-region="uk">%7$s</span>
<span data-region="cm">%8$s</span>
</label>
</div>', $input_name, $esc_value, $id, $checked, $filtered_label, $us_size, $uk_size, $cm_size );
}
Here is a JS snippet
$('[data-chooseregion]').on('click', function(e) {
$(this).addClass('active--sizeSelect').siblings().removeClass('active--sizeSelect');
var $active = $('[data-region=' + $(this).data('chooseregion') + ']').addClass('label_show');
$('[data-region]').not($active).removeClass('label_show');
e.preventDefault();
});
Here is the markup for the switcher
<?php
echo '<a class="sizeSelect active--sizeSelect" data-chooseregion="eu" href="#">EU</a>';
echo '<a class="sizeSelect" data-chooseregion="us" href="#" >US</a>';
echo '<a class="sizeSelect" data-chooseregion="uk" href="#" >UK</a>';
echo '<a class="sizeSelect" data-chooseregion="cm" href="#" >CM</a>';
?>
Is it a good practice or not?
Thanks again