首页 > 解决方案 > 使用贝宝时如何设置代码片段以禁用yith积分奖励

问题描述

我正在寻找一种在使用贝宝作为付款方式时禁用 yith 积分奖励的方法。

我有此代码可以禁用特定产品的 yith 积分奖励,但无法找到禁用付款方式的方法

其他代码是默认代码,用于排除特价产品并在兑换时禁用赚取积分。

我认为混合使用贝宝时可能会禁用赚取积分。

我真的很感激一些帮助!

        'exclude_product_on_sale'                           => array(
            'name'      => esc_html__( 'Exclude on sale products', 'yith-woocommerce-points-and-rewards' ),
            'desc'      => esc_html__( 'If enabled, sale products will not assign points to your users', 'yith-woocommerce-points-and-rewards' ),
            'yith-type' => 'onoff',
            'type'      => 'yith-field',
            'id'        => 'ywpar_exclude_product_on_sale',
            'default'   => 'no',
        ),

if( class_exists('YITH_WC_Points_Rewards_Frontend')){
    add_filter('ywpar_get_product_point_earned', 'ywpar_get_product_point_earned_gift_card', 10, 2 );
    function ywpar_get_product_point_earned_gift_card( $points, $product ){
        if( $product->is_type('gift-card')){
            $points = 0;
        }
        return $points;
    }

    add_filter('ywpar_calculate_rewards_discount_item_price', 'ywpar_calculate_rewards_discount_item_price', 10, 3);
    function ywpar_calculate_rewards_discount_item_price( $price, $value, $product_id){
        $product = wc_get_product( $product_id );
        if( $product->is_type('gift-card')){
            $price = 0;
        }
        return $price;
    }
}

'disable_point_earning_while_reedeming'             => array(
            'name'      => esc_html__( 'Do not assign points to orders in which the user is redeeming points', 'yith-woocommerce-points-and-rewards' ),
            'desc'      => esc_html__( 'Enable to not assign points to orders in which the user redeems points', 'yith-woocommerce-points-and-rewards' ),
            'id'        => 'ywpar_disable_earning_while_reedeming',
            'type'      => 'yith-field',
            'yith-type' => 'onoff',
            'default'   => 'no',
            'deps'      => array(
                'id'    => 'ywpar_enable_points_upon_sales',
                'value' => 'yes',
                'type'  => 'hide',
            ),
        ),

标签: woocommercepayment-gatewaycode-snippets

解决方案


推荐阅读