I'm desperately trying to remove an action while the cart calculates the total.
Here is my code:
remove_action('woocommerce_cart_calculate_fees', array('WCS_Cart_Renewal', 'remove_non_recurring_fees'), 1000);
While the original action hook is taking place on the WooCommerce Subscriptions plugin:
// Remove non-recurring fees from renewal carts. Hooked in late (priority 1000), to ensure we handle all fees added by third-parties.
add_action( 'woocommerce_cart_calculate_fees', array( $this, 'remove_non_recurring_fees' ), 1000 );
Unfortunately I could not remove the remove_non_recurring_fees
hooked function.
Any idea why?
Instead of trying to remove the action hook that trigger this function, you have 2 other choices:
1). For custom fees added by you via your theme's
functions.php
file:You will have just to use a greater priority like in this following example:
2). Or better using
woocommerce_subscriptions_is_recurring_fee
available filter hook:This filter hook that allows to re-add all desired fees that are not recurring with this simple code line:
Code goes in functions.php file of the active child theme (or active theme). Tested and works.