Удалите сообщение об изменении продукта в плагине Woocommerce Points & rewards - PullRequest
0 голосов
/ 15 мая 2018

Я пытаюсь создать действие по удалению для плагина woocommerce и вознаграждений, но не могу заставить его работать.

Я не пытался удалить действие, подобное этому, поэтому любая помощь будет оценена :)

Спасибо за чтение

Моя операция удаления:

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

Оригинальные add_actions в своем классе:

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

EDIT Я забыл упомянуть, что если вы закомментируете это, то информация, которую я пытаюсь удалить, фактически удаляется.

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

Дополнительная информация

Я не упоминал об этом раньше, потому что я думал, что это только раздувает вопрос, но цель состоит в том, чтобы убрать его с того места, где он есть (до добавления в корзину), и добавить его обратно под цену, чтобы эффективно двигать его вверх. страница.

Я не включал это раньше, так как думал, что это будет простое действие удаления и добавления.

1 Ответ

0 голосов
/ 17 августа 2018
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;
}

Может быть удалено этим, но я не знаю, как добавить его обратно в другое место (

...