Remove X/Pro WooCommerce Hooks and Filters

I wish to remove hooks and filters related to WooCommerce from the X/Pro parent theme however, it does not work.

Using a child theme and reference point: FUNCTIONS/GLOBAL/PLUGINS/WOOCOMMERCE.PHP

Note as stipulated in the WordPress guide I am using the exact priority used when adding the original action callback. https://developer.wordpress.org/reference/functions/remove_action/ https://developer.wordpress.org/reference/functions/remove_filter

Some examples in functions.php:

// Title
// -----
remove_action('woocommerce_shop_loop_item_title', 'x_woocommerce_template_loop_product_title', 10);

// Add/Remove Product Tabs
// -----------------------
function my_remove_filter_product_tabs()
{
    remove_filter('woocommerce_product_tabs', 'x_woocommerce_add_remove_product_tabs', 98);
}
add_action('after_setup_theme', 'my_remove_filter_product_tabs');

// AJAX
// =============================================================================
if (function_exists('x_woocommerce_navbar_cart_ajax_notification')):
    remove_action('x_before_site_end', 'x_woocommerce_navbar_cart_ajax_notification');
endif;

Hi @strobley,

Thanks for reaching out.
I have checked your Hooks, the Product Tabs can be removed by disabling the Theme Options > WooCommerce > Single Product(Tabs) option shown in the following screenshot. Also, you can disable the Ajax Notification by disabling the Ajax Add to Cart Button from WooCommerce > Settings > Product as shown in the given screenshot, you can use the code if you want to disable the notification only.

NOTE: The Hooks for removing the title is working fine.

Thanks

thanks @tristup - the hooks for removing the title is not working. I am working on a local wp-env setup. Below is the full set of hooks and filters I refer to that are not removing the content from the pages.

// Shop

// =============================================================================

// Title

// -----

remove_action('woocommerce_shop_loop_item_title', 'x_woocommerce_template_loop_product_title', 10);

// Columns and Posts Per Page

// --------------------------

function my_remove_filter_shop_columns()

{

remove_filter('loop_shop_columns', 'x_woocommerce_shop_columns');

}

add_action('after_setup_theme', 'my_remove_filter_shop_columns');

// Shop Product Thumbnails

// -----------------------

remove_action('woocommerce_before_shop_loop_item_title', 'x_woocommerce_shop_product_thumbnails', 10);

// Shop Item Wrapper

// -----------------

remove_action('woocommerce_before_shop_loop_item', 'x_woocommerce_before_shop_loop_item', 10);

remove_action('woocommerce_after_shop_loop_item', 'x_woocommerce_after_shop_loop_item', 10);

remove_action('woocommerce_before_shop_loop_item_title', 'x_woocommerce_before_shop_loop_item_title', 10);

remove_action('woocommerce_after_shop_loop_item_title', 'x_woocommerce_after_shop_loop_item_title', 10);

// Product

// =============================================================================

// Product Wrapper

// ---------------

remove_action('woocommerce_before_single_product', 'x_woocommerce_before_single_product', 10);

remove_action('woocommerce_after_single_product', 'x_woocommerce_after_single_product', 10);

// Add/Remove Product Tabs

// -----------------------

function my_remove_filter_product_tabs()

{

remove_filter('woocommerce_product_tabs', 'x_woocommerce_add_remove_product_tabs', 98);

}

add_action('after_setup_theme', 'my_remove_filter_product_tabs');

// Checkout

// =============================================================================

remove_action('woocommerce_review_order_after_submit', 'x_woocommerce_add_submit_spinner');

// Cross Sells (Cart Only)

// =============================================================================

remove_action('woocommerce_cart_collaterals', 'x_woocommerce_output_cross_sells', 21);

// Related Products

// =============================================================================

remove_action('woocommerce_after_single_product_summary', 'x_woocommerce_output_related_products', 20);

// Upsells

// =============================================================================

remove_action('woocommerce_after_single_product_summary', 'x_woocommerce_output_upsells', 21);

// AJAX

// =============================================================================

if (function_exists('x_woocommerce_navbar_cart_ajax_notification')):

remove_action('x_before_site_end', 'x_woocommerce_navbar_cart_ajax_notification');

endif;

// Cart Fragment

// -------------

if (function_exists('x_woocommerce_navbar_cart_fragment')):

function my_remove_filter_navbar_cart_fragment()

{

remove_filter('woocommerce_add_to_cart_fragments', 'x_woocommerce_navbar_cart_fragment');

}

add_action('after_setup_theme', 'my_remove_filter_navbar_cart_fragment');

endif;

// Cart Menu Item

// --------------

if (function_exists('x_woocommerce_navbar_menu_item')):

function my_remove_filter_navbar_menu_item()

{

remove_filter('wp_nav_menu_items', 'x_woocommerce_navbar_menu_item', 9999);

}

add_action('after_setup_theme', 'my_remove_filter_navbar_menu_item');

endif;

// Fragments

// =============================================================================

function my_remove_filter_fragments()

{

remove_filter('woocommerce_add_to_cart_fragments', 'x_woocommerce_fragments');

}

add_action('after_setup_theme', 'my_remove_filter_fragments');

// Stack Wrapper

// =============================================================================

remove_action('template_redirect', 'x_woocommerce_setup_stack_wrapper');

Hi @strobley,

What you are trying to do was beyond the scope of our theme support because it involves customizing the core functionality of our theme. You may seek 3rd party developers to help you with your problems or you can avail One where we can answer questions outside of the features of our theme.

Thank you for understanding.

@marc_a this is NOT customising core functionality - this is for following standard process for hooks and filters… any well developed good theme adheres to this basic WordPress developer guideliness provide this simple abiitiy to override theme hooks and filters. Are you saying X and Pro are not good themes adhering basic WordPress developer guidelines?

This is adding nothing new, simply using WordPress core features and not changing functionality to remove what is not needed.

Are you not familiar with your own documentation? https://theme.co/docs/actions-filters-and-hooks

Hello @strobley,

Sorry for the confusion. Yes, we do adhere to the WordPress standards. You may need to add some priority to your actions. For example, instead of having add_action('after_setup_theme', 'my_remove_filter_fragments');, you may have add_action('after_setup_theme', 'my_remove_filter_fragments', 50); to make sure that the functions will be rendered last thus removing what needs to be removed. If this is still not working, kindly provide us access to your site so that we can check your child theme’s functions.php file. Please create a secure note with the following info:
– Link to your site
– WP login URL
– WP username
– WP password
– WP Administrator Role
- Confirmation that we can access and make changes to your site

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

Best Regards.

I’ve tried this @ruenel using priorty 99999 and it makes no difference and does not work. As notied in the official documentation; https://developer.wordpress.org/reference/functions/remove_action/

$priority
(int) (Optional) The exact priority used when adding the original action callback.
Default value: 10

I have tried using the exact same priority and increasing, neither make any difference. All hooks and filters I am trying to revert are located in pro/framework/functions/plugins/woocommerce.php

As stated I am working locally using wp-env. You spin a local install of your choice and use the code I’ve already provided from my functions.php to prove and validate it is not working and then provide me with a working solution.

The code not complex or heavily customised, it simply reverts the pro woocommerce.php using basic core WordPress remove_action and remove_filter.

Hello @strobley,

All your remove_filter() and remove_action() must be inside the add_action('after_setup_theme', 'your function name here', 50); And always make sure that you child theme is active.

Please provide us access to your site for us to check your site settings and the child theme’s functions.php file.

Regards.

Thanks @ruenel this may have worked - am testing and will let you know. My thanks agian.

You are most welcome @strobley.

thanks @ruenel for understanding the requirement - after testing I can confirm this has worked,

Hi @strobley,

We’re glad that my colleague @ruenel is able to help you with your issues. If you have any other concerns or clarifications regarding our theme features, feel free to open up a new thread.

Thank you.

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