2
votes

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?

1
yes, you can use jquery/javascript to hide it when the shipping method is changed. Listen for the change event on the shipping method select box, detect the value and if it's anything but the one you want, hide the delivery_day field. api.jquery.com/change, api.jquery.com/val, api.jquery.com/hideWill
I want do the same stuff please guide me how can I add the custom field 'delivery_day' and also show and hide base on shipping method.Faraz Ahmed

1 Answers

1
votes

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>