• Hello, is there an opportunity to link the payment method for pickup – “Payment on the spot” or remove the need for payment for pickup.

Viewing 1 replies (of 1 total)
  • Plugin Author rajeshsingh520

    (@rajeshsingh520)

    Hi,

    Activate cash on delivery payment method in the Woocommerce

    After that You can add this code in your them functions.php file

    Below code will hide all payment method for Pickup side and only cash on delivery will be allowed

    
    add_filter('woocommerce_available_payment_gateways',function($gateways){
    	if(is_admin()) return $gateways;
            
    	if(!class_exists('pi_dtt_delivery_type')) return $gateways;
    
        $type =  pi_dtt_delivery_type::getType();
    	if($type == 'pickup'){
    		foreach($gateways as $key => $val){
                if($key != 'cod'){
                    unset($gateways[$key]);
                }
            }
    	}
    
    	return $gateways;
    }, 1);
    

    You can change the title of the payment method using the below code

    
    
    add_filter( 'woocommerce_gateway_title', function ( $title, $payment_id ){
    	if(is_admin()) return $gateways;
            
    	if(!class_exists('pi_dtt_delivery_type')) return $gateways;
    
        $type =  pi_dtt_delivery_type::getType();
    	if($type == 'pickup'){
    		if( $payment_id === 'cod' ) {
    			$title = "Payment on the spot";
    		}
    	}
        
        return $title;
    }, 100, 2 );
    
    
Viewing 1 replies (of 1 total)
  • The topic ‘How to link a payment method for pickup?’ is closed to new replies.