Post-sale cross-sell with WooCommerce
Have you ever seen post-sale selling techniques?
I purchased a product, and then on the checkout page I noticed that they have a table of products related to their courses.
In their case, they are external products, but I thought to use that section to cross-sell some products post-sale. Let’s see how to do it!
Preparing the post-sale products tempate
Open your functions.php file in wp-content/themes/your-child-theme-name/ and add this code at the end of the file:
This function will take care of getting the cross-sale products set for the products that have been purchased, and show them on the Thank you page.
Feel free to edit the text and HTML code to what you prefer most!
Settings cross-sell products
WooCommerce has a way to do it directly in the core.
Edit your product in Products > All Products and open the Linked Products tab. In the Cross-sells field choose the products that you want to cross-sell when that specific product is purchased:

That’s all! This setup will get you a result like this, on the Thank you page:

Works exactly as described. I have disabled the Related Products from the Cart page. I always thought adding to the Checkout/Thank You page would be better in not disrupting the Checkout flow.
Thank you again for a very useful snippet!
You’re welcome Amit!
Well! It’s not working for me!
Is there a way to make product cross-sell on the fly? In other words on the cart page have a static Id that you can make a cross-sell for any product in the cart.
Hey, I tried the code and I hard coded the product Id but only the html code comes through. I do not have any cross-sell defined in woocommerce. I only have one product that I want to offer. So if $cross-sells is empty until it does the diff with $in_order[ ] will it still work.