WooCommerce Thank You Page Cross-Sells


There are no pre-requisites in order for you to be able to implement this solution. Although you do need cross-sells setup against your products.

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 cross-sells in the cart based on products added. These are user defined from the product editor under the Linked Products tab. They are typically complementary items. For example, if you are selling a laptop, cross-sells might be a protective case or stickers or a special adapter. Or if you’re selling a ninja t-shirt, they could be a ninja hoodie and ninja socks. A lot of the time, users will skip the cart page and navigate straight to the checkout meaning you miss the opportunity to increase your Average Order Value (AOV) because the user simply doesn’t see the cross-sells. This guide shows you how you can show cross-sells on the Thank You Page (Order Received Page), a page which cannot be skipped. Make sure you have cross-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 cross-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 Cross-Sells
* Snippet Author: ecommercehints.com

add_action( 'woocommerce_thankyou', 'ecommercehints_get_cross_sells', 10, 1 );
function ecommercehints_get_cross_sells( $order_id ){
$cross_sell_ids = array();
$order = wc_get_order( $order_id );
$items = $order->get_items();
foreach ( $items as $item ) {
if( $item_cross_sell_ids = get_post_meta( $item['product_id'], '_crosssell_ids', true ) ) {
$cross_sell_ids = array_unique( array_merge( $item_cross_sell_ids, $cross_sell_ids ));

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

if( $cross_sell->have_posts() ) {
echo '<h2>You may also like...</h2>';
while ( $cross_sell->have_posts() ) : $cross_sell->the_post();
$product = wc_get_product( $cross_sell->post->ID );
wc_get_template_part( 'content', 'product' );

Snippet Benefits

  • Increase your sales by exposing similar products (cross-sells from products in the order) to a new customer on the order received thank you page.
  • Show product cross-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