Created
August 1, 2013 07:23
-
-
Save corsonr/6129163 to your computer and use it in GitHub Desktop.
WooCommerce - Make "state" field not required on checkout page
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
<?php | |
/** | |
* WooCommerce Extra Feature | |
* -------------------------- | |
* | |
* Make "state" field not required on checkout | |
* | |
*/ | |
add_filter( 'woocommerce_billing_fields', 'woo_filter_state_billing', 10, 1 ); | |
add_filter( 'woocommerce_shipping_fields', 'woo_filter_state_shipping', 10, 1 ); | |
function woo_filter_state_billing( $address_fields ) { | |
$address_fields['billing_state']['required'] = false; | |
return $address_fields; | |
} | |
function woo_filter_state_shipping( $address_fields ) { | |
$address_fields['shipping_state']['required'] = false; | |
return $address_fields; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, thanks for sharing this details. How can i do if i need to select specific country's to change from optional to required. Thanks