Jump to content


New Members
  • Posts

  • Joined

  • Last visited

JayX's Achievements


Newbie (1/5)



  1. For anyone that may want to know, the following snippet did the job. The only last thing I need to do is somehow make it show "Guest" if no role is found. I think I need an if else statement or something. Anyone have any ideas? function onboarding_update_fields( $fields = array() ) { $user = wp_get_current_user(); $roles = (array)$user->roles; $fields['billing']['customer_type']['default'] = $roles[0]; return $fields; } add_filter( 'woocommerce_checkout_fields', 'onboarding_update_fields' );
  2. Ok, I got it to pass data. Because I am using the Checkout Field Editor plugin I assume this is the reason I had to do it this way. Now I just need to figure out how to get the default to be the user role. Belo w is what I had to do to get it to even pass data. function custom_override_checkout_fields ( $fields ) { $fields['billing']['customer_type']['label'] = 'Customer Type'; $fields['billing']['customer_type']['default'] = 'one'; return $fields; } // End custom_override_checkout_fields() add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
  3. Oh, and I did try the customer name snippet that you suggested just to see if it would pass that info, but it does not either.
  4. Unfortunately no, first name would not work for me. I sell products to end users, and through distributors, all of which order through the website. I use Shipstation plugin and I need to pass to shipstation whether it is a Customer, a Guest, or Distributor Tier1, Distributor Tier2, or Distributor Tier3 so that my automation in shipstation is correct. I have a custom field in the checkout that I created with the plugin Checkout Field Editor and I have successfully created code that makes that field pass to shipstation, now I just need to figure out how to automatically populate that field with the current user role. Just banging my head here, as it feels like I am so close.
  5. Thank you, I was hopeful that would do it because I know you are right but still does not work. Any other ideas? Thank you so much for responding
  6. I am trying to populate a custom field called "Customer Type" current user role. The custom field is displayed on my checkout page. I tried the below in my functions.php of my child theme and thought it would work but it does nothing. Can anyone tell me what I might be doing wrong? $user = wp_get_current_user(); function onboarding_update_fields( $fields = array() ) { $fields['customertype'] = $user; return $fields; } add_filter( 'woocommerce_checkout_fields', 'onboarding_update_fields' );
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.