WC remove_action not working for related products and upsells

Hi guys,

We’re trying to remove the related/up-sells products from their default position to build our own template.

The following actions are not working:

remove_action('woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15);
remove_action('woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);

After searching quite a bit we came across a thread that mentioned a theme having its own hook to call the related/upsells function. Does X/Pro has a custom hook for these? If yes what would they be so that we can disable them properly?

Thank you!

Hey @thisisbbc,

Our themes override those parts of WooCommerce. You can see them in \pro\framework\functions\plugins\woocommerce.php

What you will need to do is to remove our themes actions in order to add your own. That can be done after the theme setup. The code should look like this:

add_action('after_setup_theme', 'my_wc_funtions');

function my_wc_funtions() {
	remove_action( 'woocommerce_after_single_product_summary', 'x_woocommerce_output_related_products', 20 );
	remove_action( 'woocommerce_after_single_product_summary', 'x_woocommerce_output_upsells', 21 );
}

That sample code is tested and it works removing the theme’s related and upsell products display. Please note that you won’t be able to use the Related and Upsell options in the Theme Options when you use that.

You are then free to add your own actions to the woocommerce_after_single_product_summary.

Hope that helps.

Hey Christian,

Thank you for this snippet, this is exactly what I was looking for.

I’m really confused though… After adding your snippet, our entire description block disappeared.

You know what’s the weirdest thing? I removed your code and it still won’t display.

I literally deleted everything in our custom functions.php, cleared our cache, deleted our custom woocommerce.php file, nothing works. Going incognito doesn’t work either.

Are any of these hooks tied to the product description? It’s like I removed an action somehow that I can’t bring back.

I have no idea what happened and that’s one of the weirdest thing I have seen with WP/WooCommerce yet.

Help? :frowning:

PS: Added admin credentials to the secure note.

Hi There,

Could you please try switching to the parent theme to see if the issue is resolved or NOT?

If it doesn’t help, please test a plugin conflict. You can do this by deactivating all third-party plugins, and see if the problem remains. If it’s fixed, you’ll know a plugin caused the problem, and you can narrow down which one by reactivating them one at a time.

Let us know how it goes!

Hello Thai,

Switching to the default Pro theme did not fix the issue.

I have deactivated all plugins (except WooCommerce), cleared my cache and the problem remain.

Waiting for your feedback.

All best,
B

The Description didn’t show because you disabled the Product Tabs. Please enable it.

The sample code provided here could not remove the Product Tabs. Please also note that we do not have support for customizations. I checked your site to confirm the status of the Product Tabs setting only.

Hope that helps.

Hello Christian,

I had this settings deactivated because we do not use tabs. The content on the single product page is added with add_action.

I was able to catch the issue with the description disappearance, I mistakenly deleted the action that added the description block. I didn’t see that immediately because I’m not getting enough sleep… really sorry for bothering you for that.

After some thorough checking I sorted everything out.

Thank you again Christian!

Hi @thisisbbc,

You’re welcome!
We’re glad @Christian_y were able to help you out.

Cheers.

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