Updated
You can use this simple code snippet, to hide shipping address from orders based on specific defined shipping methods:
add_filter( 'woocommerce_order_needs_shipping_address', 'filter_order_needs_shipping_address', 10, );
function filter_order_needs_shipping_address( $needs_address, $hide, $order ) {
// Here set your shipping method instance Ids
$targeted_instances_ids = array( 1, 2 );
// Loop through "shipping" order items
foreach ( $order->get_items('shipping') as $item ) {
if( in_array( $item->get_instance_id(), $targeted_instances_ids ) ) {
return false;
}
}
return $needs_address;
}
Code goes in functions.php file of the active child theme (or active theme). Tested and works.
Note: The shipping instance ID is the number after :
in a shipping method rates ID.
So for example for flat rate:2
, the shipping instance Id is 2
.