First, you’re correct that removing the action calling the products_links
method would work, and that this is specifically MrBara_WooCommerce->products_links()
.
In your functions.php, you can just use remove_action
without wrapping it in a function used as a callback for another add_action
, btw.
so:
remove_action('products_links, array('MrBara_WooCommerce', 'woocommerce_single_product_summary, 0)
10 is default priority, and while we may assume your priority needs to be higher than the add_action
so it is called to remove it after it is included, WP codex notes this:
To remove an action the priority must match the priority with with the
function was originally added.
And
You cannot successfully remove the action before it has been added.
You also cannot remove an action after it has been run.
So, one issue you’re having may be that by hooking an add_action
with a default priority (10) to call a function that does the remove action
with a 0 priority, is doing so after the action with a zero priority has been run.
Child versus Parent
Since child theme functions.php runs before the parent, you need to hook this after the theme is set up. [wp_loaded]
1, [after_setup_theme]
1, and init
are possible options here.
an example using our earlier back and forth:
function remove_products_links() {
global $mrbara;
remove_action('product_links', array($mrbara, 'woocommerce_single_product_summary') );
}
add_action('after_setup_theme', 'remove_products_links');
original answer
The second argument needs to be an array like so:
remove_action('products_links', array('MrBara_WooCommerce', 'woocommerce_single_product_summary' ) );
To access it from a global variable that holds the class, something like:
global $mrbara;
$mrbara = new MrBara_WooCommerce();
function remove_product_links() {
global $mrbara;
remove_action('product_links', array($mrbara, 'woocommerce_single_product_summary') );
}
add_action('woocommerce_single_product_summary', 'remove_products_links');