Home » WooCommerce: Display Customer Address @ Order Pay

WooCommerce: Display Customer Address @ Order Pay

by Tutor Aspire

The WooCommerce Order Pay page URL is generated by the store admin while creating a manual order from the backend. This URL is then forwarded onto the client, where they can pay for the order and complete their purchase.

The other annoying thing about the order pay page, together with strict page permissions, is the fact that the Order Pay page shows no customer billing/shipping address whatsoever. The customer needs to trust in you 100000%, because they’re about to submit a payment without knowing whether they’re paying for the right thing.

Let’s see how we can add the billing/shipping customer address at the top of the Order Pay page. Please note that printing personal data on a public URL is dangerous, so you need to make sure you don’t share the Order Pay URL with anyone but the customer in such case.

So, here’s a quick fix for you. Enjoy!

The default Order Pay page does not display the customer billing and shipping addresses. With the snippet below you can achieve exactly that (highlighted with a red squadre in the screenshot)

PHP Snippet: Show Customer Billing/Shipping Addresses @ WooCommerce Order Pay Page

/**
 * @snippet       Show Addresses @ WooCommerce Order Pay
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 6
 * @donate $9     https://tutoraspire.com
 */

add_action( 'before_woocommerce_pay', 'tutoraspire_order_pay_billing_address' );

function tutoraspire_order_pay_billing_address() {

   // ONLY RUN IF PENDING ORDER EXISTS
if ( isset( $_GET['pay_for_order'], $_GET['key'] ) ) {

      // GET ORDER ID FROM URL BASENAME
$order_id = intval( basename( strtok( $_SERVER["REQUEST_URI"], '?' ) ) );
$order = wc_get_order( $order_id );

      // INCLUDE CUSTOMER ADDRESS TEMPLATE
wc_get_template( 'order/order-details-customer.php', array( 'order' => $order ) );

}
}

Where to find the Order Pay page URL

Manually create an order or set an existing order to “Pending payment” status – a “Customer payment page” link will automatically show in the backend. That’s the Order Pay page!

You may also like