This code enables you to add both upsells and cross sells, combined, to your WooCommerce checkout page in a grid like this :
The code will display any amount of products based on what has been linked on the Edit Product screen under the Product Data > Linked Products > Upsells and Cross-sells.
If no linked products have been configured based on the products in the cart, none will shown, however any which have been linked and added to cart will not be shown.
In this example, we add 1 product for each cross sell and upsell in a 2 column grid.
You can use the custom code to modify the output for each type of linked product without affecting other linked products displayed in other locations.
There’s 3 steps :
Step 1 – Copy and paste the PHP code ( without the opening php tag ) from the functions.php file to the end of your child themes functions.php file or custom functionality plugin.
Step 2 – Upload the woocommerce folder to your child theme folder.
Step 3 – Copy and paste the CSS from the style.css file to the end of your child themes style sheet and clear caching.