Thank You Page

WooCommerce Show Customer Addresses On Thank You Page For Guest Checkouts

WooCommerce Thank You Page Order Received showing customer details (Billing and Shipping Address) for a guest checkout

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About This Solution

WooCommerce thank you page not showing customer details like the Billing Address and Shipping Address? It may be because the user is not logged in and checking out as a guest! By default, WooCommerce does not show customer details on the thank you page (order received endpoint of the checkout) if they checkout as a guest. The customer details being the Billing Address, including the billing email and billing phone, and Shipping Address. After tearing my hair out thinking there was a conflict somewhere, it turns out this is native behaviour of WooCommerce. The customer details are not shown on the order received page for security purposes. The customer details is not protected in the same way for logged in, registered users. This snippet will run on the thank you page and tests whether the user is logged in or not. If they are, nothing happens because when a user is logged in, these customer details are shown. However, if the code picks up that the user is not logged in, it will force the thank you page to output the order-details-customer.php template which is the customer details (Billing Address, including the billing email and billing phone, and Shipping Address (if enabled and entered)).

/**
 * Snippet Name:	WooCommerce Show Customer Addresses On Thank You Page For Guest Checkouts
 * Snippet Author:	ecommercehints.com
 */

add_action( 'woocommerce_thankyou', 'ecommercehints_show_customer_addresses_on_thank_you_if_guest', 10, 1 );
function ecommercehints_show_customer_addresses_on_thank_you_if_guest($order_id) {
    if (!$order_id || is_user_logged_in()) { // Do nothing if there is no order or the customer is logged in
		return;
	}
    $order = wc_get_order($order_id);
    wc_get_template( 'order/order-details-customer.php', array('order' => $order )); // Show the addresses
}

Snippet Benefits

  • Show the customer Billing Address (including billing email and billing phone) on the thank you page even if the user checks out as a guest user.
  • Show the customer Shipping Address (if enabled and entered) on the thank you page even if the user checks out as a guest user.

100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 20% off on your first month with us.

26027
WELCOME OFFER