Populate fields from CourePress Pro to WooCommerce

Hi

Is it possible for WooCommerce to auto populate the CheckOut page using the fields that are part of the Registration process when a student signs up for a course.

At the moment when a student signs up for a course they complete the 'SIGN UP' page. With the following:

first name
last name
Username
email (and confirmation)
password (and confirmation)

They then click CREATE ACCOUNT which take them to the WooCommerce Cart and then to the Checkout page. On the Checkout page the EMAIL ADDRESS field is pre-populated, how can I make the FIRST NAME and LAST NAME fields pre-populate/

Thanks
Tony

  • Vinod Dalvi

    Hi Tony,

    I hope you are well today and thank you for your question.

    You can achieve this using the attached small plugin specially developed for you which contains the following code.

    add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
    
    // Our hooked in function - $fields is passed via the filter!
    function custom_override_checkout_fields( $fields ) {
    	  $user_info = get_userdata(get_current_user_id());
    	  if( $user_info ) {
    
    	      if( $user_info->first_name ){
    	     	$fields['billing']['billing_first_name']['default'] = $user_info->first_name;
    	     }
    	     if( $user_info->first_name ){
    	    	 $fields['billing']['billing_last_name']['default'] = $user_info->last_name;
    	 	}
     	}
         return $fields;
    }

    The first and last name fields should be set in the user profile screen so that they will be populated.

    Best Regards,
    Vinod Dalvi

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.