Created
June 14, 2013 01:59
-
-
Save ChromeOrange/5778923 to your computer and use it in GitHub Desktop.
Remove postcode requirement if billing or shipping country is Ireland
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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