Skip to content

Instantly share code, notes, and snippets.

@ChromeOrange
Created June 14, 2013 01:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChromeOrange/5778923 to your computer and use it in GitHub Desktop.
Save ChromeOrange/5778923 to your computer and use it in GitHub Desktop.
Remove postcode requirement if billing or shipping country is Ireland
/**
* Remove postcode requirement if billing or shipping country is Ireland
* Add to your theme functions.php file
*/
add_action( 'woocommerce_checkout_process', 'custom_country_check' );
function custom_country_check(){
global $woocommerce;
if ( ( !empty($_POST['billing_country']) && $_POST['billing_country'] == 'IE' ) || ( $checkout->get_value( 'billing_country' ) == 'IE' ) ):
add_filter( 'woocommerce_billing_fields', 'custom_woocommerce_remove_billing_postcode_requirement', 10, 1 );
endif;
if ( ( !empty($_POST['shipping_country']) && $_POST['shipping_country'] == 'IE' ) || ( $checkout->get_value( 'shipping_country' ) == 'IE' ) ):
add_filter( 'woocommerce_billing_fields', 'custom_woocommerce_remove_billing_postcode_requirement', 10, 1 );
endif;
}
function custom_woocommerce_remove_billing_postcode_requirement( $address_fields ) {
$address_fields['billing_postcode']['required'] = false;
return $address_fields;
}
add_filter( 'woocommerce_shipping_fields', 'custom_woocommerce_remove_shipping_postcode_requirement', 10, 1 );
function custom_woocommerce_remove_shipping_postcode_requirement( $address_fields ) {
$address_fields['shipping_postcode']['required'] = false;
return $address_fields;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment