Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save greenhornet79/81dba27e67de95f9d7decd7e80c2617a to your computer and use it in GitHub Desktop.
Save greenhornet79/81dba27e67de95f9d7decd7e80c2617a to your computer and use it in GitHub Desktop.
<?php
add_filter('leaky_paywall_basic_shipping_validation', 'zeen_ignore_state_for_international', 10, 2);
function zeen_ignore_state_for_international($errors, $fields)
{
// if the user selects GB (Great Britian), then remove the state validation
if ($fields['country'] == 'GB') {
unset($errors['state_empty']);
}
return $errors;
}
add_action('wp_footer', 'zeen_remove_state_field');
function zeen_remove_state_field()
{
// if the country selected is GB (Great Britian), then remove the state field
?>
<script>
(function($) {
$(document).ready(function() {
$('#country').change(function() {
country = this.value;
if (country == 'GB') {
$('.state-field').hide();
} else {
$('.state-field').show();
}
});
});
})(jQuery);
</script>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment