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 this popular feature of cross-sell blocks to make customers buy additional or related items present in the cart. Let’s adapt this tactics and spotlight customer’s attention to products featuring BOGO offers or discounts.

Solution: Add Free Products to Cross-Sell Blocks on the WooCommerce Cart Page

The code snippet given below will be overriding the template file, specifically the ‘cross-sells.php’ file helps to customize the cross-sell functionality to include a specific complementary 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

Instead of showcasing the free product in the cross-sell block, you can also automatically add upsell products to cart via custom link in WooCommerce.

.

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