Skip to content

Instantly share code, notes, and snippets.

@blivic
Created January 27, 2021 14:30
Show Gist options
  • Save blivic/c9bd4319e6be38eed2cf6a4c2a240408 to your computer and use it in GitHub Desktop.
Save blivic/c9bd4319e6be38eed2cf6a4c2a240408 to your computer and use it in GitHub Desktop.
/**
* Hide R1 field for customers outside HR
**/
add_action( 'woocommerce_after_checkout_form', 'mx_show_r1_4hr' );
function mx_show_r1_4hr(){
if ( is_checkout() ) {
?>
<script>
jQuery(document).ready(function($){
$(document).on('updated_checkout', function(){
if ($('#billing_country').find('option:selected').val() == 'HR'){
$('#mx_custom_checkout_field').show();
} else {
$('#mx_custom_checkout_field').hide();
}
});
});
</script>
<?php
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment