Make field not required with code
-
Hi. I’ve got Last name required on my Checkout page http://prntscr.com/nd57lb
I want to change this and make NOT required if virtual products are in cart.add_filter( 'woocommerce_checkout_fields', 'woo_simplify_checkout_virtual' ); function woo_simplify_checkout_virtual( $fields ) { $only_virtual = true; foreach( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { // Check if there are non-virtual products if ( ! $cart_item['data']->is_virtual() ) $only_virtual = false; } if( $only_virtual ) { // WHAT SHOULD I PLACE HERE? return $fields; }I’m trying to unset Lat Name with
$fields['billing_last_name']['required'] = false;but it doesn’t work.
What code should I use to unset required field with code?
Thanks.
The topic ‘Make field not required with code’ is closed to new replies.