Sonic Advisor
Sonic Advisor

Reputation: 44

Hide custom field on checkout page if shipping method changed

I have successfully added a custom field to the woocommerce page called 'delivery_day' which is placed below the Order Notes. This custom field is only added to the checkout page if a particular shipping method is selected on the cart page.

If the user decides to change the shipping method on the checkout page, I require the custom 'delivery_day' field to then be removed/hidden.

Any suggestions would be greatly appreciated.

Is there a way to refresh the billing/shipping section of the checkout page when shipping method is changed? Or could this be achieved using some jQuery?

Upvotes: 2

Views: 2365

Answers (1)

Sonic Advisor
Sonic Advisor

Reputation: 44

The following jQuery seemed to do the job!

<script>
$(document).ready(function (){
        $('#selectionOne').on('change',function() {
        if ($('#selectionOne').val() == '-none-'){
            $('#selectionTwo').show();  
        } else {
        $('#selectionTwo').hide();
        }
    })
})
</script>

Upvotes: 1

Related Questions