Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Add Free Products to Cross-Sell Blocks on the WooCommerce Cart Page?

Store owners might use the cross-sell block to highlight clearance or promotional items, driving attention to products with BOGO offers or discounts. The code snippet given below and by overriding the template file, specifically the ‘cross-sells.php’ file helps to customize the cross-sell functionality to include a specific product in the cross-sell block on the cart page.

add_filter( 'woocommerce_cart_crosssell_ids', 'ts_custom_cross_sells' );
function ts_custom_cross_sells( $cross_sell_ids ){ 
    $cross_sell_ids = [470]; 
    return $cross_sell_ids;
}

Follow these steps to change the default text of the cross-sell block.

  • Find the template file from: wp-content/themes/your-theme/woocommerce/cart/cross-sells.php
  • Use a code editor to open cross-sells.php in your theme directory.
  • Look for a line that sets the heading, and Update the Heading Text with this line: $heading = apply_filters( ‘woocommerce_product_cross_sells_products_heading’, __( ‘Get this product for Free:’, ‘your-theme-text-domain’ ) );
  • Save the cross-sells.php file.

Output

The following output shows that a specific free product is featured in the cross-sell block on the cart page.

How to Add Free Products to Cross-Sell Blocks on the WooCommerce Cart Page? - Tyche Softwares

And the blow image represents the default text and the cross-sell block that appears on the cart page.

How to Add Free Products to Cross-Sell Blocks on the WooCommerce Cart Page? - Tyche Softwares

So, instead of showcasing the free product in the cross-sell block, you can also automatically add a free product to your WooCommerce cart based on 6 different conditions.

.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x