• Resolved metalsunny

    (@metalsunny)


    Hello,
    Pls can you to me how to change payment email address to Bank Name and Account number. I want to be able to pay affiliate money into their bank account.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Alexis Salazar

    (@asaldel)

    Hello there,

    hope you are doing well ??

    Currently, only is possible to pay the commissions to the affiliates using PayPal.

    Have a nice day!

    Thread Starter metalsunny

    (@metalsunny)

    I know. But i have been able to change the email to bank name, bank account number and name of bank account. But when ever i click the register button. It loops me back to the registration page. Can tou help me pls

    Plugin Support Iván Sosa

    (@ivansosa)

    Hi there,

    please, try to add this custom code in the functions.php of your active theme:

    add_filter('yith_wcaf_payment_email_required', '__return_false');
    
    if ( defined( 'YITH_WCAF' ) ) {
    	if ( ! function_exists( 'yith_wcaf_get_extra_fields' ) ) {
    		function yith_wcaf_get_extra_fields() {
    			return array(
    				'bank_name' => array(
    					'type' => 'text',
    					'label' => __('Bank name', 'yith-woocommerce-affiliates'),
    					'mandatory' => true,
    				),
    				'bank_account_num' => array(
    					'type' => 'text',
    					'label' => __('Bank account number', 'yith-woocommerce-affiliates'),
    					'mandatory' => true,
    				),
    				'bank_account_name' => array(
    					'type' => 'text',
    					'label' => __('Bank account name', 'yith-woocommerce-affiliates'),
    					'mandatory' => true,
    				),
    			);
    		}
    	}
    
    	if ( ! function_exists( 'yith_wcaf_add_custom_fields' ) ) {
    		function yith_wcaf_add_custom_fields( $user = false ) {
    			$yith_wcaf_additional_fields = yith_wcaf_get_extra_fields();
    
    			$user_id = $user instanceof WP_User ? $user->ID : false;
    			$user_id = ( ! $user_id && is_user_logged_in() ) ? get_current_user_id() : $user_id;
    			$fields  = '';
    			$admin   = doing_action( 'show_user_profile' ) || doing_action( 'edit_user_profile' );
    
    			if ( $admin ) {
    				$fields .= "<hr/>
                <h3>Additional Affiliate Fields</h3>
                <table class='form-table'>";
    			}
    
    			foreach ( $yith_wcaf_additional_fields as $field => $opts ) {
    				if ( $user_id ) {
    					$value = get_user_meta( $user_id, 'yith_wcaf_' . $field, true );
    				} else {
    					$value = ! empty( $_POST[ 'yith_wcaf_' . $field ] ) ? $_POST[ 'yith_wcaf_' . $field ] : '';
    				}
    
    				$fields .= $admin ? '<tr><th>' : "<p class='form-row form-row-wide'>";
    				$fields .= "<label for='yith_wcaf_" . $field . "'>" . $opts['label'] . ': ' . ( $opts['mandatory'] ? "<span class='required'>*</span>" : '' ) . '</label>';
    				$fields .= $admin ? '</th><td>' : '';
    				$fields .= "<input type='" . $opts['type'] . "' class='input-text' name='yith_wcaf_" . $field . "' id='yith_wcaf_" . $field . "' value='$value' " . ( $opts['mandatory'] ? 'required' : '' ) . ' />';
    				$fields .= $admin ? '</td></tr>' : '</p>';
    			}
    
    			if ( $admin ) {
    				$fields .= '</table>';
    			}
    
    			echo $fields;
    		}
    
    		add_action( 'yith_wcaf_register_form', 'yith_wcaf_add_custom_fields' );
    		add_action( 'yith_wcaf_settings_form_after_payment_email', 'yith_wcaf_add_custom_fields' );
    		add_action( 'show_user_profile', 'yith_wcaf_add_custom_fields', 21, 1 );
    		add_action( 'edit_user_profile', 'yith_wcaf_add_custom_fields', 21, 1 );
    	}
    
    	if ( ! function_exists( 'yith_wcaf_register_custom_field' ) ) {
    		function yith_wcaf_register_custom_field( $param1, $param2 = false ) {
    			$yith_wcaf_additional_fields = yith_wcaf_get_extra_fields();
    
    			if ( doing_action( 'yith_wcaf_new_affiliate' ) ) {
    				$id = $param1;
    				$affiliate = YITH_WCAF_Affiliate_Handler()::get_instance()->get_affiliate_by_id( $id );
    				$user_id   = $affiliate['user_id'];
    			} elseif ( doing_action( 'yith_wcaf_save_affiliate_settings' ) ) {
    				$user_id = $param2;
    			} elseif ( doing_action( 'personal_options_update' ) || doing_action( 'edit_user_profile_update' ) ) {
    				$user_id = $param1;
    
    				if ( ! current_user_can( 'edit_user', $user_id ) ) {
    					return false;
    				}
    			}
    
    			if ( empty( $user_id ) ) {
    				return false;
    			}
    
    			foreach ( $yith_wcaf_additional_fields as $field => $opts ) {
    				if ( isset( $_REQUEST[ 'yith_wcaf_' . $field ] ) ) {
    					update_user_meta( $user_id, 'yith_wcaf_' . $field, sanitize_text_field( $_REQUEST[ 'yith_wcaf_' . $field ] ) );
    				}
    			}
    
    			if( doing_action( 'yith_wcaf_save_affiliate_settings' ) ) {
    				return true;
    			}
    
    		}
    
    		add_action( 'yith_wcaf_new_affiliate', 'yith_wcaf_register_custom_field', 10, 1 );
    		add_action( 'yith_wcaf_save_affiliate_settings', 'yith_wcaf_register_custom_field', 10, 2 );
    		add_action( 'personal_options_update', 'yith_wcaf_register_custom_field', 10, 1 );
    		add_action( 'edit_user_profile_update', 'yith_wcaf_register_custom_field', 10, 1 );
    	}
    }

    It will remove the payment email field and it will add bank name, bank account number and bank account name fields.

    Hope it helps you.

    Have a great day!

    Thread Starter metalsunny

    (@metalsunny)

    Wow. Thank you it works like charm, i love it. I was also able to submit the reg form successfully. Thanks once again.

    • This reply was modified 3 years, 7 months ago by metalsunny.
    Thread Starter metalsunny

    (@metalsunny)

    Good job

    Thread Starter metalsunny

    (@metalsunny)

    This same snippet doesn’t work on my new theme pls help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to change payment email to’ is closed to new replies.