• Resolved majidnasiri

    (@majidnasiri)


    I was wondering if there is a way that we can exclude purchasing a gift card from receiving points and rewards in the FREE version.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hello,
    you can try to use this script to add inside the file functions.php of your theme

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

    this script assign 0 points during the calculation of points to earn, and set the price to 0 during the calculation of the points that can be rewards.

    Thread Starter majidnasiri

    (@majidnasiri)

    That’s awesome. Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude Gift Card to get points’ is closed to new replies.