Conditional Checkout Fields by Variation
-
Hello,
I am trying to add checkout fields based on what variation of product the customer has in their cart. I have three types of products.
For the first (Personal Use File) I would like to display First Name, Last Name, and Email fields (all required)
For the second (Commercial Use File) I would like to display the same as above, but with a required “Company Name” field.
For the third (Art Print) I would like to display all of the usual billing and shipping details.
I currently have this snippet of code:
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ); function custom_override_checkout_fields( $fields ) { unset($fields['billing']['billing_city']); unset($fields['billing']['billing_country']); unset($fields['billing']['billing_address_1']); unset($fields['billing']['billing_postcode']); unset($fields['billing']['billing_state']); return $fields; }
in my functions.php file to remove most of the fields, but this is clunky and doesn’t change based on the customer’s cart. I was hoping to change this so that it’s more adaptive.
Any help is most appreciated!
The page I need help with: [log in to see the link]
- The topic ‘Conditional Checkout Fields by Variation’ is closed to new replies.