• Resolved hector0371

    (@hector0371)


    The project I am working is to create a woocommerce-based platform,where every items posted can be exchanged for 1 token, instead of paying prices. To do this, I`ve tried YITH /SUMO /Woocommerce reward points plugins, and Dokan as the multi-vendor plugin. Here are the problems I encountered:

    1. Among all the reward points plugins, SUMO reward point is closest to my needs, as it provide payment gateway using award points. However,in each reward points plugins I tried,points-payment is just a converted version of money payment. What I want to is simply to count the cart items, and add/reduce points in two accounts, but I don`t know the location (files) I should insert these codes into.

    Here is the closest part i can get to in SUMO reward points:

    // file name: class_rewardgateway.php

    public function process_payment( $order_id ) {            
    			global $woocommerce ; 
    			$redeemedpoints = gateway_points( $order_id ) ;
    			$order          = new WC_Order( $order_id ) ;
    			$OrderObj       = srp_order_obj( $order ) ;
    			$payment_method = $OrderObj[ 'payment_method' ] ;
    			update_post_meta( $order_id , 'total_redeem_points_for_order_point_price' , $redeemedpoints ) ;
    			update_post_meta( $order_id , 'frontendorder' , 1 ) ;
    			//For SUMOSubscriptions, Automatic Subscription Payment Compatibility.
    			$parent_id      = get_post_parent( $order ) > 0 ? get_post_parent( $order ) : $order_id ;
    
    			if ( is_sumosubscriptions_active() ) {
    				if ( ( isset( $_REQUEST[ 'rs_reward_points_payment_selection' ] ) && '1' == wc_clean(wp_unslash($_REQUEST[ 'rs_reward_points_payment_selection' ] )) ) || $this->is_forced_automatic_subscription_payment ) {
    
    					if ( function_exists( 'sumo_save_subscription_payment_info' ) ) {
    						sumo_save_subscription_payment_info( $order_id , array(
    							'payment_type'         => 'auto' ,
    							'payment_method'       => $payment_method ,
    							'payment_order_amount' => WC()->cart->get_cart_contents_count() , //$cart_items_count,//$order->get_total() ,///Caution
    						) ) ;
    					} else {
    						update_post_meta( $parent_id , 'sumo_parent_order_auto_manual' , 'auto' ) ;
    						update_post_meta( $parent_id , 'sumo_order_payment_method' , $payment_method ) ;
    						update_post_meta( $parent_id , 'sumo_totalamount' , $order->get_total() ) ; ///Caution
    					}
    				} else {
    					if ( function_exists( 'sumo_save_subscription_payment_info' ) ) {
    						sumo_save_subscription_payment_info( $order_id , array(
    							'payment_type'         => 'manual' ,
    							'payment_method'       => $payment_method ,
    							'payment_order_amount' => $order->get_total() ,///
    						) ) ;
    					} else {
    						update_post_meta( $parent_id , 'sumo_parent_order_auto_manual' , 'manual' ) ;
    						update_post_meta( $parent_id , 'sumo_order_payment_method' , $payment_method ) ;
    						update_post_meta( $parent_id , 'sumo_totalamount' , $order->get_total() ) ;
    					}
    				}
    			}
    
    			$order->payment_complete() ;
    			$order_status = get_option( 'rs_order_status_after_gateway_purchase' , 'completed' ) ;
    
    			$order->update_status( $order_status ) ;
    			//Reduce Stock Levels
    			//  $order->reduce_order_stock();
    			//Remove Cart
    			$woocommerce->cart->empty_cart() ;
    
    			//Redirect the User
    			return array(
    				'result'   => 'success' ,
    				'redirect' => $this->get_return_url( $order )
    					) ;
    			wc_add_notice( __( 'Payment error:' , 'woothemes' ) . $error_message , 'error' ) ;
    			return ;
    		}

    2. Another issue is about compatibility with multi-vendor plugins like Dokan. Reward plugins usually work on single-site environment,and i dont know what extra files I should modify if I want to apply the above modification to work in multi-vendor environment.To prevent large-scale malfunctions, I think it would be wise to ask for guidance before blindly experimenting. If anyone have had experience in similar cases that want to share with me, I would be grateful to listen to and learn.

    Thank you for your reading!

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to override payment method with a token-based method’ is closed to new replies.