Support » Plugin: YITH WooCommerce Affiliates » Custom fields

  • Good day, is it possible to set manual payments and add bank details fields in the registration form?
    Thanks

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

    (@yithemes)

    Hello there,

    hope you are doing well 🙂

    To set manual payments, you only have to follow these simple steps:
    YITH -> Affiliates -> Commissions -> Bulk actions -> Create a payment manually, and the commission payment will be processed.

    If you want to add a bank details field in the registration form, please add the following code to the functions.php file of your active theme:

    if ( defined( 'YITH_WCAF' ) ) {
    	if ( ! function_exists( 'yith_wcaf_add_custom_fields' ) ) {
    		function yith_wcaf_add_custom_fields() {
    			$fields = "<p class='form-row form-row-wide'>
                               <label for='bank_details'>Bank details<span class='required'>*</span></label>
                               <input type='text' class='input-text' name='bank_details' id='bank_details' value='' />
                           </p>
                           ";
    
    			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' );
    	}
    
    	if ( ! function_exists( 'yith_wcaf_register_custom_field' ) ) {
    		function yith_wcaf_register_custom_field( $id ) {
    			$affiliate = YITH_WCAF_Affiliate_Handler()::get_instance()->get_affiliate_by_id( $id );
    
    			if ( isset( $_REQUEST['bank_details'] ) ) {
    				update_user_meta( $affiliate['user_id'], 'bank_details', sanitize_text_field( $_REQUEST['bank_details'] ) );
    			}
    		}
    		add_action( 'yith_wcaf_new_affiliate', 'yith_wcaf_register_custom_field' );
    	}
    
    	if ( ! function_exists( 'yith_wcaf_register_custom_field_settings' ) ) {
    		function yith_wcaf_register_custom_field_settings( $change, $id ) {
    			if ( isset( $_REQUEST['bank_details'] ) ) {
    				update_user_meta( $id, 'bank_details', sanitize_text_field( $_REQUEST['bank_details'] ) );
    			}
    		}
    		add_action( 'yith_wcaf_save_affiliate_settings', 'yith_wcaf_register_custom_field_settings', 10, 2 );
    	}
    
    	if ( ! function_exists( 'yith_wcaf_show_custom_field' ) ) {
    		function yith_wcaf_show_custom_field( $user ) {
    			?>
    			<hr />
    			<h3>Additional Affiliate Fields</h3>
    			<table class="form-table">
    				<tr>
    					<th><label for="bank_details">Bank details</label></th>
    					<td>
    						<input type="text" name="bank_details" id="bank_details" value="<?php echo get_user_meta( $user->ID, 'bank_details', true ) ?>">
    					</td>
    				</tr>
    			</table>
    			<?php
    
    		}
    		add_action( 'show_user_profile', 'yith_wcaf_show_custom_field', 21, 1 );
    		add_action( 'edit_user_profile', 'yith_wcaf_show_custom_field', 21, 1 );
    	}
    
    	if ( ! function_exists( 'yith_wcaf_update_custom_field' ) ) {
    		function yith_wcaf_update_custom_field( $user_id ) {
    			if ( ! current_user_can( 'edit_user', $user_id ) ) {
    				return;
    			}
    
    			if ( isset( $_POST['bank_details'] ) ) {
    				update_user_meta( $user_id, 'bank_details', sanitize_text_field( $_POST['bank_details'] ) );
    			}
    		}
    
    		add_action( 'personal_options_update', 'yith_wcaf_update_custom_field', 10, 1 );
    		add_action( 'edit_user_profile_update', 'yith_wcaf_update_custom_field', 10, 1 );
    	}
    }

    Let us know any news, please.

    Have a nice day!

    fiona92

    (@fiona92)

    Thank you so much.

    Can you please tell me how to update the above code to include these banking details fields?

    Bank
    Bank Account Name
    Account Number
    Sort Code

    Thank you

    I need the same

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.