WooCommerce Thank You Page Up-Sells

WooCommerce Thank You Page showing product upsells

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

Depending on your website theme, WooCommerce by default will only show product up-sells on the product page. Up-sells are products that you recommend instead of the currently viewed product. They are typically products that are more profitable or better quality or more expensive. However, at it’s core, an up-sell is purely a link to another product meaning they can be used in conjunction rather than to replace a currently used product (similar to a cross-sell). This guide shows you how you can show up-sells on the Thank You Page (Order Received Page), giving you the opportunity to increase your Average Order Value (AOV) if the customer missed the up-sells the first time. Make sure you have up-sells setup against your products, and this snippet will show all of them at the bottom of the thank you page. The positioning of the up-sell product loop can be changed by changing the priority in the very first function (we have set it to 10 in this example).

				
					/**
* Snippet Name: WooCommerce Thank You Page Up-Sells
* Snippet Author: ecommercehints.com
*/

add_action( 'woocommerce_thankyou', 'ecommercehints_get_up_sells', 10, 1 );
function ecommercehints_get_up_sells( $order_id ){
$up_sell_ids = array();
$order = wc_get_order( $order_id );
$items = $order->get_items();
foreach ( $items as $item ) {
if( $item_up_sell_ids = get_post_meta( $item['product_id'], '_upsell_ids', true ) ) {
$up_sell_ids = array_unique( array_merge( $item_up_sell_ids, $up_sell_ids ));
}
}

if(!empty($up_sell_ids)) {
$up_sell = new WP_Query( array(
'post_type' => array( 'product', 'product_variation' ),
'post_status' => 'publish',
'post__in' => $up_sell_ids,
'orderby' => 'post__in'
) );

if( $up_sell->have_posts() ) {
echo '<h2>You may also like...</h2>';
woocommerce_product_loop_start();
while ( $up_sell->have_posts() ) : $up_sell->the_post();
$product = wc_get_product( $up_sell->post->ID );
wc_get_template_part( 'content', 'product' );
endwhile;
woocommerce_product_loop_end();
woocommerce_reset_loop();
wp_reset_postdata();
}
}
}
				
			

Snippet Benefits

  • Increase your Average Order Value (AOV) and sales by exposing the customer to similar products (up-sells from products in the order) on the order received thank you page.
  • Show product up-sells on the thank you page.
WooCommerce Conversion Rate Optimisation (CRO) eBook
100 WooCommerce Conversion Rate Optimisation Tips

Leave a Reply

If you are going to write code in the comments, please wrap it between code tags.

Your email address will not be published. Required fields are marked *

Other Recent Guides

Subscribe To Emails

Get exclusive WooCommerce tips that I only share with email subscribers

Join hundreds of other subscribers