从 WooCommerce 的插件积分和奖励中删除结帐通知
Remove checkout notice from plugin Points & Rewards in WooCommerce
我正在使用 WooCommerce 插件 "Points & Rewards",它会在我的结账时显示两个通知。
我在插件中找到了通知生成的代码:
public function __construct() {
....
// add earn points/redeem points message above cart / checkout
add_action( 'woocommerce_before_checkout_form', array( $this, 'render_earn_points_message' ), 5 );
add_action( 'woocommerce_before_checkout_form', array( $this, 'render_redeem_points_message' ), 6 );
....
}
我尝试使用以下代码删除通知:
remove_action( 'woocommerce_before_checkout_form', array( 'WC_Points_Rewards_Cart_Checkout->render_earn_points_message' ), 5 );
remove_action( 'woocommerce_before_checkout_form', array( 'render_earn_points_message' ), 5 );
remove_action( 'woocommerce_before_checkout_form', array( 'woocommerce_render_earn_points_message' ), 5 );
但它们不起作用。还有其他方法可以删除它们吗?或者正确的称呼方式?
如果我想在结帐时删除优惠券通知,此代码可以正常工作:
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
您可以使用以下方法从结帐页面删除 "Points & Rewards" 消息:
add_filter( 'wc_points_rewards_earn_points_message', 'remove_rewards_earn_points_message', 20, 2 );
add_filter( 'wc_points_rewards_redeem_points_message', 'remove_rewards_earn_points_message', 20, 2 );
function remove_rewards_earn_points_message( $message, $data ) {
if( is_checkout() )
return '';
return $message;
}
代码进入您活跃的子主题(或主题)的 function.php 文件。
已测试并有效
我正在使用 WooCommerce 插件 "Points & Rewards",它会在我的结账时显示两个通知。
我在插件中找到了通知生成的代码:
public function __construct() {
....
// add earn points/redeem points message above cart / checkout
add_action( 'woocommerce_before_checkout_form', array( $this, 'render_earn_points_message' ), 5 );
add_action( 'woocommerce_before_checkout_form', array( $this, 'render_redeem_points_message' ), 6 );
....
}
我尝试使用以下代码删除通知:
remove_action( 'woocommerce_before_checkout_form', array( 'WC_Points_Rewards_Cart_Checkout->render_earn_points_message' ), 5 );
remove_action( 'woocommerce_before_checkout_form', array( 'render_earn_points_message' ), 5 );
remove_action( 'woocommerce_before_checkout_form', array( 'woocommerce_render_earn_points_message' ), 5 );
但它们不起作用。还有其他方法可以删除它们吗?或者正确的称呼方式?
如果我想在结帐时删除优惠券通知,此代码可以正常工作:
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
您可以使用以下方法从结帐页面删除 "Points & Rewards" 消息:
add_filter( 'wc_points_rewards_earn_points_message', 'remove_rewards_earn_points_message', 20, 2 );
add_filter( 'wc_points_rewards_redeem_points_message', 'remove_rewards_earn_points_message', 20, 2 );
function remove_rewards_earn_points_message( $message, $data ) {
if( is_checkout() )
return '';
return $message;
}
代码进入您活跃的子主题(或主题)的 function.php 文件。
已测试并有效