Payament
Free Photos
WordPress Themes

Make State not required in WooCommerce Checkout

<?php /** * * Make "state" field not required on checkout * */ add_filter( 'woocommerce_default_address_fields' , 'woo_filter_default_state_billing' ); 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_default_state_billing( $address_fields ) { $address_fields['state']['required'] = false; return $address_fields; } 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; }
Add this snippet to your functions.php file.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.