Last active
August 12, 2019 21:10
-
-
Save ddbs/9282829 to your computer and use it in GitHub Desktop.
woocommerce: make checkout fields not required
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
//make billing fields not required in checkout | |
add_filter( 'woocommerce_billing_fields', 'wc_npr_filter_phone', 10, 1 ); | |
function wc_npr_filter_phone( $address_fields ) { | |
$address_fields['billing_phone']['required'] = false; | |
return $address_fields; | |
} | |
//make shipping fields not required in checkout | |
add_filter( 'woocommerce_shipping_fields', 'wc_npr_filter_shipping_fields', 10, 1 ); | |
function wc_npr_filter_shipping_fields( $address_fields ) { | |
$address_fields['shipping_first_name']['required'] = false; | |
$address_fields['shipping_last_name']['required'] = false; | |
$address_fields['shipping_address_1']['required'] = false; | |
$address_fields['shipping_city']['required'] = false; | |
$address_fields['shipping_postcode']['required'] = false; | |
return $address_fields; | |
} | |
// force mandatory fields in checkout - NIF | |
// add_filter( 'woocommerce_billing_fields', 'wc_dbs_filter_company', 10, 1 ); | |
// function wc_dbs_filter_company( $address_fields ) { | |
// $address_fields['billing_company']['required'] = true; | |
// return $address_fields; | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment