Hide shipping address from orders based on specifically defined shipping methods WooCommerce

Hide shipping address from orders based on specifically defined shipping methods WooCommerce on your child site.

Snippet Type

Execute on Child Sites

Snippet

add_filter( 'woocommerce_order_needs_shipping_address', 'filter_order_needs_shipping_address', 10,  );
function change_order_received_page_title_based_on_order_status( $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;
}
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.