Tried other threads with similar problems to no avail I'm kinda of stuck.
In the cartpage I want to hide the div with class .woocommerce-shipping-destination
This should be shown, if any radio button other than the following is selected:
<li>
<input type="radio" name="shipping_method[0]" data-index="0" id="shipping_method_0_local_pickup5" value="local_pickup:5" class="shipping_method" checked="checked">
<label for="shipping_method_0_local_pickup5">Hämta själv</label>
</li>
The problem I am facing is that now, the pickup is selected by default, which it shouldn't and the div is hidden. However, If i start chosing other radiobuttons, the div is shown and never hidden again. What am I doing wrong?
<?php
add_action( 'wp_head', function () { ?>
<script>
jQuery( document ).ready(function( $ ) {
$('input[type="radio"]').click(function () {
if ($(this).attr("value") == "local_pickup:5") {
$(".woocommerce-shipping-destination").hide('slow');
}
if ($(this).attr("value") == "msunifaun_web-ta:6") {
$(".woocommerce-shipping-destination").show('slow');
}
});
$('input[type="radio"]').trigger('click'); // trigger the event
});
</script>
<?php } );
Has it something todo with the fact that the on-click the buttons are ajax-updated?