The WooCommerce Thank you page is where the customer is sent after placing an order. It displays data like the order number, order date, customer email, total paid amount, the payment method, the products themselves and the billing/shipping information.

This is the basic Thank you page – boring. You can benefit a lot by customizing the WooCommerce thank you page. This is great place to thank the customer for shopping by giving them bonus discount coupon, giving them a special offer or letting them download something for free. Read few more bonus tips at the end of this article.

WooCommerce Thank you Page Hooks

The WooCommerce Thank you page has 3 hooks:

  • woocommerce_before_thankyou
  • woocommerce_thankyou_
  • woocommerce_thankyou

Few notes about the woocommerce_thankyou_ hook

The action defined in the WooCommerce thankyou.php template file is

do_action( 'woocommerce_thankyou_' . $order->get_payment_method(), $order->get_id() );

This means that the hook itself is not woocommerce_thankyou_, but woocommerce_thankyou_{PAYMENT METHOD SLUG}

This allows you to add a specific content on your thank page depending on the payment gateway an order has been paid with. For example, if the user paid by Bank transfer, the hook will be woocommerce_thankyou_bacs. This is great if you want to add different message according to the used payment method.

How to get a payment method slug? Go to WordPress admin WooCommerce > Settings > Payments, click on the payment gateway you want to hook and look at the URL in browser, the slug will be there.

WooCommerce Thank you Page Visual Hooks Guide

Order received

woocommerce_before_thankyou

Thank you. Your order has been received.

Order number:Date:Email:Total:Payment method:
73February 28, 2020jack.sparrow@mail.com€100.00Direct bank transfer

woocommerce_thankyou_

Order details

Product Total
T-shirt × 1 100.00
Subtotal: 100.00
Payment method: Direct bank transfer
Total: 100.00

Billing address

Jack Sparrow
Strasse 24
14199 BERLIN
Germany
738428372
jack.sparrow@mail.com

woocommerce_thankyou

PHP Snippet: Add custom content to the WooCommerce Thank you page

Now that we know which are the Thank you page hooks and where they are, we can add our custom content. For the example, lets add bonus coupon code before Order Details if the user’s payment method is Direct bank transfer:

add_action('woocommerce_thankyou_bacs', 'webroom_custom_bank_thankyou_message', 5);
function webroom_custom_bank_thankyou_message(){
	echo '<p>Thank you for shopping with us! Here is 10% OFF of your next purchase. Use coupon code: <b>10OFF</b></p>';
}

PHP Snippet: Add custom content to the WooCommerce Thank you page after Order Received Title

add_action('woocommerce_thankyou_bacs', 'webroom_custom_bank_thankyou_message', 5);
function webroom_custom_bank_thankyou_message(){
	echo '<p>Thank you for shopping with us! Here is 10% OFF of your next purchase. Use coupon code: <b>10OFF</b></p>';
}

Bonus: Change the Thank You page title

add_filter( 'woocommerce_endpoint_order-received_title', 'webroom_change_thankyou_title' );
 
function webroom_change_thankyou_title( $old_title ){
 
 	return 'We received your order! Thank you!';
 
}

Bonus: Change Thank you page text after Order Received

Lets make it more personal by adding the customers first name:

add_filter( 'woocommerce_thankyou_order_received_text', 'webroom_change_thankyou_sub_title', 20, 2 );
 
function webroom_change_thankyou_sub_title( $thank_you_title, $order ){
 
	return $order->get_billing_first_name() . ', thank you very much for your order!';
 
}

Bonus tips for adding content to the WooCommerce Thank you page

  1. Ask for a review/feedback – a great example of taking advantage of the Thank you page is to ask the customers for a review on Google or Facebook or anywhere or to ask them to share the order/product on social media.
  2. Keep visitors engaged – you can even add content from your blog posts in order to keep them browsing the site after the purchase.
  3. Track marketing results – the Thank you page is the right place to put your conversion tracking code from Google Ads or Facebook Ads.
  4. Hidden custom notification – the user visits the Thank you page only after placing the order, so you can add function to send a customized email to someone in order to notify them about new orders.

Do you know more tips for engaging customers on the Thank you page? Leave a comment below.

See all Visual Hooks Guide here.




Recent Articles

From Our Community Forums

Blog Categories

Related Articles

If you enjoyed reading this, then please explore our other articles below:

Comments

Leave a comment

Leave a Reply

Comment policy: We love comments and appreciate the time that readers spend to share ideas and give feedback. However, all comments are manually moderated and those deemed to be spam or solely promotional will be deleted.