好吧,我在这里很挣扎——我觉得这应该是直截了当的,但我就是无法让它发挥作用。
我需要删除Woocommerce订阅添加的筛选器。该筛选器是在WC Subscriptions Switcher类中找到的WC\\U Subscriptions\\U Switcher类的一部分。php和添加如下
class WC_Subscriptions_Switcher {
/**
* Bootstraps the class and hooks required actions & filters.
*
* @since 1.4
*/
public static function init() {
...
// Display/indicate whether a cart switch item is a upgrade/downgrade/crossgrade
add_filter( \'woocommerce_cart_item_subtotal\', __CLASS__ . \'::add_cart_item_switch_direction\', 10, 3 );
...
该函数将文本添加到购物车(升级)、(降级)或(横向),我不想/不需要在我的案例中显示这些文本。我试着简单地从Wordpress Codex中使用下面的删除过滤器功能,但是不管怎样,仍会显示有问题的文本。
global $WC_Subscriptions_Switcher;
remove_filter( \'woocommerce_cart_item_subtotal\', array($WC_Subscriptions_Switcher, \'add_cart_item_switch_direction\') );
我也尝试了(我认为)我在下面的答案中找到的所有东西,也只是从remove_action or remove_filter with external classes?如何删除此过滤器,使其在第一时间不被触发?我知道我可以使用gettext覆盖文本,但我认为一开始不运行它会更干净(即使使用gettext,过滤器添加的html标记也会保留下来)。
感谢您的帮助。