删除 Woocommerce 积分和奖励插件中的产品变体消息

Remove product variation message in Woocommerce points & rewards plugin

我正在尝试为 woocommerce 积分和奖励插件创建一个删除操作,但我无法让它工作。

我之前没有尝试删除类似这样的操作,因此我们将不胜感激 :)

感谢阅读

我的 remove_action 是:

remove_action( 'woocommerce_before_add_to_cart_button', 'add_variation_message_to_product_summary', 25 );

原add_actions在他们class:

    class WC_Points_Rewards_Product {
        /**
         * Add product-related hooks / filters
         *
         * @since 1.0
         */
        public function __construct() {

            // add single product message immediately after product excerpt
            add_action( 'woocommerce_before_add_to_cart_button', array( $this, 'render_product_message' ), 15 );

            // add variation message before the price is displayed
            add_action( 'woocommerce_before_add_to_cart_button', array( $this, 'add_variation_message_to_product_summary' ), 25 );

            // add the points message just before the variation price.
            add_filter( 'woocommerce_variation_price_html', array( $this, 'render_variation_m

essage' ), 10, 2 );
        add_filter( 'woocommerce_variation_sale_price_html', array( $this, 'render_variation_message' ), 10, 2 );
        add_filter( 'woocommerce_available_variation', array( $this, 'render_available_variation_message' ), 10, 3 );

        add_filter( 'woocommerce_show_variation_price', '__return_true' );

        // delete transients
        add_action( 'woocommerce_delete_product_transients', array( $this, 'delete_transients' ) );
    }

以及我试图删除的功能:

/**
     * Add a message about the points to the product summary
     *
     * @since 1.2.6
     */
    public function add_variation_message_to_product_summary() {
        global $product;

        // make sure the product has variations (otherwise it's probably a simple product)
        if ( method_exists( $product, 'get_available_variations' ) ) {
            // get variations
            $variations = $product->get_available_variations();

            // find the variation with the most points
            $points = $this->get_highest_points_variation( $variations, $product->get_id() );

            $message = '';
            // if we have a points value let's create a message; other wise don't print anything
            if ( $points ) {
                $message = $this->create_variation_message_to_product_summary( $points );
            }

            echo $message;
        }
    }

编辑 我忘了说,如果你注释掉这个,那么我试图删除的信息实际上被删除了。

//add_action( 'woocommerce_before_add_to_cart_button', array( $this, 'add_variation_message_to_product_summary' ), 25 );

附加信息

我之前没有提到这个,因为我认为它只会使问题膨胀,但目标是将它从原来的位置移除(在添加到购物车之前),然后将其重新添加到低于价格的位置,这样可以有效地移动它在页面上。

我之前没有包括这个,因为我认为这将是一个简单的删除添加操作。

add_filter( 'wc_points_rewards_single_product_message', 
'remove_rewards_earn_points_message_single', 15, 2 );
function remove_rewards_earn_points_message_single( $message, $data ) {
if( is_product() )
    return '';
return $message;
}

可以通过这个删除,但我不知道如何将它添加回另一个位置(