Skip to content
Advertisement

Remove checkout notice from plugin Points & Rewards in WooCommerce

I’m using the WooCommerce plugin “Points & Rewards” which displays two notices in my checkout.

I found the code of the notice generation in the plugin:

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 );
    ....
}

I tried to remove the notice with the following codes:

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 );

But they don’t work. Is there an other way to remove them? Or a correct way to adress them?

If I want to remove the coupon notice in the checkout, this code works fine:

remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );

Advertisement

Answer

You can use the following to remove “Points & Rewards” messages from checkout page:

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;
}

Code goes in function.php file of your active child theme (or theme).

Tested and works

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement