首页 > 解决方案 > 如何从钩子 woocommerce_subscription_totals_table 中删除 get_subscription_totals_template 函数

问题描述

我想用我的插件版本的订阅总计表替换 WooCommerce 订阅提供的订阅总计。

在 WooCommerce Subsciptions 插件class-wcs-template-loader.php中有一行加载订阅总模板

add_action( 'woocommerce_subscription_totals_table', array( __CLASS__, 'get_subscription_totals_template' ) );

我正在尝试从钩子中删除该函数并将其替换为我自己的模板版本。但它不工作!

我在我的插件文件中写了以下内容

remove_action( 'woocommerce_subscription_totals_table', array( __CLASS__, 'get_subscription_totals_template' ) );

但它不工作。

标签: woocommercewoocommerce-subscriptions

解决方案


把这个改为:

remove_action( 'woocommerce_subscription_totals_table', array( 'WCS_Template_Loader', 'get_subscription_totals_template' ) );

推荐阅读