Depending on how customers want their items shipped, you can adjust the email notifications. If they choose local pickup, there’s no need for a shipping address. The following code will display the shipping address only when a shipping method other than ‘local pickup’ is selected.
function ts_custom_display_shipping_address_in_email( $order, $sent_to_admin, $plain_text, $email ) { // ======================> Here begins the customization $shipping_local_pickup = false; if ( $items_totals = $order->get_order_item_totals() ) { foreach ( $items_totals as $items_total ) { if ( $items_total['value'] == 'Local Pickup' && ! $shipping_local_pickup ) { $shipping_local_pickup = true; } } } // End } add_action( 'woocommerce_email_order_details', 'ts_custom_display_shipping_address_in_email', 10, 4 );
Output
If a customer had chosen ‘local pickup’ during checkout then the shipping address will not be shown in the email notifications.
But, if any other shipping method was chosen then the code will show both shipping and billing address on the email notification.
Do you want to show the shipping address in all email notifications? Then you can find it here on how to display shipping address in email notifications.