Sorry Not really a great answer. However, I haven’t got enough Reputation points to add a comment yet 🙁
I was just reading this site, and I saw the following snippet that could be useful for what you are trying to do.
(this is not my code I use this page for a lot of great ideas & tips)
/** * @snippet Simplify Checkout if Only Virtual Products * @how-to Get CustomizeWoo.com FREE * @sourcecode https://businessbloomer.com/?p=78351 * @author Rodolfo Melogli * @compatible WooCommerce 3.5.4 * @donate $9 https://businessbloomer.com/bloomer-armada/ */ add_filter( 'woocommerce_checkout_fields' , 'bbloomer_simplify_checkout_virtual' ); function bbloomer_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 ) { unset($fields['billing']['billing_company']); unset($fields['billing']['billing_address_1']); unset($fields['billing']['billing_address_2']); unset($fields['billing']['billing_city']); unset($fields['billing']['billing_postcode']); unset($fields['billing']['billing_country']); unset($fields['billing']['billing_state']); unset($fields['billing']['billing_phone']); add_filter( 'woocommerce_enable_order_notes_field', '__return_false' ); } return $fields; }
I hope you find it useful 🙂