Stap 1:
Zorg dat je een child theme maakt van je huidige thema, anders ben je bij de eerstvolgende thema update je aanpassingen weer kwijt omdat het bestand dan overschreven word.
stap 2:
Ga in /wp-admin naar ‘Thema bestand editor’ en voeg hier in het actieve child theme dat bij stap 1 is gemaakt in het bestand functions.php helemaal onderaan onderaan deze code toe:
// No address for virtual products
add_filter( ‘woocommerce_checkout_fields’ , ‘remove_shipping_fields_virtual_products’ );
function remove_shipping_fields_virtual_products( $fields ) {
$virtual_cart = true;
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
if ( ! $cart_item[‘data’]->is_virtual() ) {
$virtual_cart = false;
break;
}
}
if ( $virtual_cart ) {
unset( $fields[‘shipping’] );
unset( $fields[‘billing’][‘billing_country’] );
unset( $fields[‘billing’][‘billing_address_1’] );
unset( $fields[‘billing’][‘billing_address_2’] );
unset( $fields[‘billing’][‘billing_city’] );
unset( $fields[‘billing’][‘billing_state’] );
unset( $fields[‘billing’][‘billing_postcode’] );
unset( $fields[‘billing’][‘billing_phone’] ); // add this line if you want it to stop asking for phone number too
}
return $fields;
}