Upselling is a powerful strategy to increase your average order value by suggesting related or higher-end products to customers. One effective place to present upsells is on the Thank You page, where customers are already in a buying mindset. This guide will show you how to display product upsells on the WooCommerce Thank You page without using any plugins.
Why Display Upsells on the Thank You Page?
The Thank You page is the final step in the purchasing process, and it’s a prime opportunity to suggest additional products. Customers who have just completed a purchase are often still open to buying more, especially if they see complementary or upgraded items.
Step 1: Create a Function to Display Upsells
First, we need to create a function that will fetch and display upsell products. Add the following code to your theme’s functions.php file:
/*
* * Snippet: How to Display Product Upsells on the Thank You Page in WooCommerce – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1297
* Tested with WooCommerce 10.7.0
* "Function to display upsells on thank you page"
*/
function wcsuccess_display_upsells_on_thank_you_page($order_id) {
$order = wc_get_order($order_id);
$upsell_products = [];
foreach ($order->get_items() as $item) {
$product_id = $item->get_product_id();
$product = wc_get_product($product_id);
$upsells = $product->get_upsell_ids();
if (!empty($upsells)) {
foreach ($upsells as $upsell_id) {
$upsell_products[] = wc_get_product($upsell_id);
}
}
}
if (!empty($upsell_products)) {
echo '<h2>You may also like...</h2>';
echo '<ul class="products upsells">';
foreach ($upsell_products as $upsell) {
echo '<li class="product">';
echo '<a href="' . get_permalink($upsell->get_id()) . '">';
echo $upsell->get_image();
echo '<h2 class="woocommerce-loop-product__title">' . $upsell->get_name() . '</h2>';
echo '</a>';
echo '<span class="price">' . $upsell->get_price_html() . '</span>';
echo '</li>';
}
echo '</ul>';
}
}
This function retrieves the upsell products for each item in the order and displays them on the Thank You page.
Step 2: Hook the Function to the Thank You Page
Next, we need to hook our function to the Thank You page. Add the following code to your theme’s functions.php file:
/*
* * Snippet: How to Display Product Upsells on the Thank You Page in WooCommerce – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1297
* Tested with WooCommerce 10.7.0
* "Hook the upsells function to thank you page"
*/
add_action('woocommerce_thankyou', 'wcsuccess_display_upsells_on_thank_you_page');
This line ensures that our upsell display function runs when the Thank You page is rendered.
Step 3: Style the Upsells Section
To ensure the upsells section looks good on the Thank You page, add some CSS to your theme’s style.css file or the Additional CSS section in the Customiser:
/*
* * Snippet: How to Display Product Upsells on the Thank You Page in WooCommerce – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1297
* Tested with WooCommerce 10.7.0
* "CSS for upsells section on thank you page"
*/
.upsells {
display: flex;
flex-wrap: wrap;
gap: 20px;
margin-top: 30px;
}
.upsells .product {
border: 1px solid #ddd;
padding: 15px;
text-align: center;
width: 100%;
max-width: 200px;
}
.upsells .product img {
max-width: 100%;
height: auto;
}
.upsells .product h2 {
font-size: 1.25em;
margin: 10px 0;
}
.upsells .product .price {
font-size: 1.1em;
color: #333;
}
This CSS ensures that the upsells section is styled nicely and fits well with your theme.
Step 4: Test Your Changes
After adding the code and CSS, make a test purchase on your WooCommerce store to ensure the upsell products appear correctly on the Thank You page. Adjust the styling and functionality as needed to fit your store’s design and requirements.
Use Cases for Upsells on the Thank You Page
- Complementary Products: Suggest products that complement the items just purchased, such as accessories or related items.
- Higher-End Alternatives: Present upgraded versions of the purchased products, encouraging customers to consider a higher-quality option.
- Limited-Time Offers: Highlight special deals or limited-time offers to create a sense of urgency.
- Seasonal Promotions: Show seasonal or holiday-related products that customers might be interested in.
- Subscription Services: If you offer subscription services, suggest them as an add-on to the purchased products.
Conclusion
Displaying product upsells on the Thank You page in WooCommerce is a great way to increase sales and enhance the customer experience. By following the steps outlined in this guide, you can easily implement this feature without relying on plugins. Customise the upsell products and styling to match your store’s unique needs and watch your average order value grow.
I have been working with WordPress and WooCommerce since 2012 and have developed a deep knowledge of the content management system. Since 2012, I have developed several plugins and designed dozens of websites utilising different frameworks, CMS’s and programming languages. I am proficient in PHP, Python, Java, C, C++, R and JavaScript with limited experience in Go, Kotlin and Swift.
Educationally, I have a Master’s degree in cyber security a Bachelor’s (Hons, First Class) in Applied Research and a Graduate Certificate in Data Science. I’m currently undertaking PhD studies investigating IoT cybersecurity. I recently graduated with First Class Honours and Masters of Information Technology, receiving the Executive Dean’s Award for studies undertaken in the 2021 and 2022 academic years. I have worked in the information technology industry for the past 11 years primarily as a software/web developer specific to design, optimisation, network management and security. My research interests are in the areas of Internet of Things (IoT), 5G and Beyond Networks, information security for wireless networks and software development.
Stay In Touch

