• Hi,
    Is possible disable add points when customer select specific shipping methods?
    Any hook and filter?
    Thanks for info and help.

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

    (@yithemes)

    Hi @stieranka,
    in order to do this you need a tailored solution with the help of a developer. If you don’t know one, you can hire one on one of these sites: https://jobs.wordpress.net/ or https://jetpack.pro/

    Thread Starter stieranka

    (@stieranka)

    Hi @yithemes,
    I thought, you have any hook on it…

    But I solved it by “penalizing” and subtracting the allocated points for the local pickup. In order for the customer to see that he has negative points for the local pickup.

    This is my funkcion ( a piece of yours ?? ) :

    // function remove earned points if is local shipping
    add_action('woocommerce_order_status_changed','ss_order_status_changed_action', 20, 3 );
    function ss_order_status_changed_action( $order_id, $old_status, $new_status ) {
    	if ( ($new_status == "completed") && (class_exists('YITH_WC_Points_Rewards')) ) { // if order completed and active YITH
    		$order = wc_get_order( $order_id );
    		$ship_info = wc_get_my_shipping_info( $order->get_id() ); // my custon function for get shipping info
    		if ( $ship_info['type'] == 'local_pickup' ) { // if type local pickup
    			$point_earned = yit_get_prop( $order, '_ywpar_points_earned', true );
    			if ( $point_earned == '' ) { // return if not earned points for this order
    				return;
    			}
    			$customer_user = $order->get_customer_id();
    			$points = $point_earned;
    			$action = '';
    			$reason = 'Local Shipping'; // custom reason info for customer and admin note
    			$note = sprintf( __( 'Removed for %s', 'ys' ), $reason );
    			if ( $customer_user > 0 ) {
    				yit_save_prop( $order, '_ywpar_points_earned', '' );
    				YITH_WC_Points_Rewards()->add_point_to_customer( $customer_user, - $points, $action, $note, $order_id ); // minus points
    				$order->add_order_note( sprintf( __( 'Removed %d points for %s.', 'ys' ), - $points, $reason ), 0 ); // admin notice
    			}
    		}
    	}
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Disable add points when select specific shipping methods’ is closed to new replies.