# Map Link for the Shipping Address in New Order Emails

> Adds an "Open in Maps" link under the shipping address in the shop's new order email, handy for local delivery drivers.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, email, local-delivery, maps
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-admin-email-map-link/

## Code

```php
add_action( 'woocommerce_email_customer_details', function ( $order, $sent_to_admin, $plain_text ) {
    if ( ! $sent_to_admin || ! $order instanceof WC_Order || ! $order->has_shipping_address() ) {
        return;
    }

    $address = implode( ', ', array_filter( array( $order->get_shipping_address_1(), $order->get_shipping_address_2(), $order->get_shipping_city(), $order->get_shipping_postcode(), $order->get_shipping_country() ) ) );
    $url     = 'https://www.google.com/maps/search/?api=1&query=' . rawurlencode( $address );

    if ( $plain_text ) {
        echo "\n" . esc_html( 'Map: ' ) . esc_url_raw( $url ) . "\n";
        return;
    }

    printf( '<p><a href="%s">%s</a></p>', esc_url( $url ), esc_html( 'Open the delivery address in Maps' ) );
}, 25, 3 );
```

## Notes

Only added to emails sent to the shop, and nothing is requested from Google until someone clicks the link.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Map Link for the Shipping Address in New Order Emails" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
