Always display shipping address in WooCommerce email notifications
Asked Answered
A

2

6

WooCommerce used to show shipping address no matter which shipping method was selected during checkout, if you had to hide the shipping address from emails you had to do a custom job like in "https://mcmap.net/q/1739030/-hide-shipping-address-on-local-pickup-in-woocommerce-email-notifications/38937106#38937106" answer thread.

After new updates, WooCommerce hides the shipping address from the order emails if local pickup is selected during checkout. I want to show the shipping address on order emails even if local pickup is chosen, if no shipping address is provided, it should default to billing address (this is what happens if any other shipping method is selected to checkout). No idea where to start on this.

I discussed with Woocommerce support, the change isn't documented but they were able to guide me where this is coming from. According to them I should be able to use woocommerce_order_needs_shipping_address filter hook and it'll start showing shipping address on order emails even when local pickup is used to checkout.

Araceli answered 2/4, 2019 at 2:49 Comment(0)
B
11

This can be done using one simple line of code:

add_filter( 'woocommerce_order_needs_shipping_address', '__return_true' );

Code goes in function.php file of your active child theme (or active theme). Tested and works.

Bursar answered 2/4, 2019 at 19:43 Comment(0)
A
3

Here's a filter hook that fixed the issue. This will show shipping address on order emails no matter what shipping method is used to checkout. Add this to functions.php:

function show_ship_add_for_local_pickup( $needs_address, $hide ) {
    $needs_address = true;
    return $needs_address;
}
add_filter( 'woocommerce_order_needs_shipping_address', 'show_ship_add_for_local_pickup', 10, 2 );
Araceli answered 2/4, 2019 at 16:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.