WooCommerce: Display Customer Address @ Order Pay

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 CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 6
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

add_action( 'before_woocommerce_pay', 'bbloomer_order_pay_billing_address' );

function bbloomer_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!

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if you have it there). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.3.

If you think this code saved you time & money, feel free to join 14,000+ WooCommerce Weekly subscribers for blog post updates or 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

6 thoughts on “WooCommerce: Display Customer Address @ Order Pay

  1. Another excellent snippet. Works great!!

    How would one go about also adding the shipping address?

    Also, I read in the previous comment about editing the address as custom work – how big of a job would this be?

    1. Hi Cory! This should already add both Billing & Shipping.

      Editing the addresses (therefore showing forms instead), would be roughly 3-4 hours of dev work.

      1. Thanks Rodolfo,

        I am only getting the billing address: tinyurl.com/4ujdn9fc –> ignore the local pickup under address as I just put this as the street address.

        Regarding custom work – can you email me a quote for the job.

        1. Not sure to be honest, works for me out of the box: https://www.screencast.com/t/ajcKyr9MtT

          Sure the order contains physical products? Otherwise may not show shipping.

          I will email you the quote, no worries. Thank you!

  2. hi
    thanks for your solotion , but i need edit address by customer before pay in pay address link
    this code just display address
    if has adresss editable after login is good

    1. Hi Mr, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

Questions? Feedback? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

Your email address will not be published.