Duplicated display of cross-sells on cart page (solution included)

Short info:
remove_action for woocommerce_cross_sell_display fails in X v8 (wrong priority)

Longer info:
X v7.x has an override template for cross-sells.php, X v8.x doesn’t, but instead uses remove_action to unhook woocommerce_cross_sell_display and then hooks its own function (see wp-content/themes/x/framework/functions/plugins/woocommerce.php:323)

However, X fails unhooking, because X assumes a hook priority of 20, but WooCommerce (4.8.0) has it hooked at the default priority of 10 (see wp-content/plugins/woocommerce/includes/wc-template-hooks.php:238).

As a temporary fix, I added this to wp-content/themes/x-child/functions.php:
remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' );

Hi @toponline,

Thanks for sharing this! Super helpful breakdown of what’s going on and I appreciate you working all that out. Glad to hear you have a solution. We will correct this in the next patch.

1 Like

Hi there. I’m using the brand new X Theme 8.0.10 and Cornerstone 5.0.10 and my Cross-sells are still being duplicated on my cart page, even though the theme’s changelog reports that problem fixed.

And the user-suggested line of code (below) placed in my x-child/functions.php doesn’t fix it either
remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' );

Hello @a101web,

Thanks for updating the thread. At this time we kindly ask that you open up your issue in a separate thread along with your login details in a secure note. The longer threads get in the forum, they become more difficult to support as they tend to drift off-topic and they also make it troublesome for users trying to search for solutions. Keeping threads relevant to their original inquiry ensures that we can keep better track of what has been resolved and that users can more effectively find answers to similar issues they might be experiencing.

In your new thread, kindly provide us access to your site so that we can check your page and settings. Please create a secure note with the following info:
– Link to your site
– WP login URL
– WP username
– WP password
– WP Administrator Role

To know how to create a secure note, please check this out: How The Forum Works

Best Regards.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.