add extra fields to my Account page
-
i wanted to add some extra fields to my account page and i created the code following this article https://support.woothemes.com/hc/en-us/articles/203182373-How-to-add-custom-fields-in-user-registration-on-the-My-Account-page
i added a select country drop down to this is there any way to get an input section for state as a drop down which changes when changed the country.
my current code as follows.function wooc_extra_register_fields_after() { global $woocommerce; $countries_obj = new WC_Countries(); $countries = $countries_obj - > __get('countries'); $default_country = $countries_obj - > get_base_country(); //$default_county_states = $countries_obj->get_states( $default_country ); //echo '<div id="my_custom_countries_field">'; woocommerce_form_field('billing_country', array('type' => 'select', 'class' => array('form-row form-row-wide'), 'label' => __('Country'). ' <span class="required">*</span>', 'id' => 'reg_billing_country', 'placeholder' => __('Select your Country'), 'options' => $countries)); if (!empty($_POST['billing_country'])) $country = esc_attr_e($_POST['billing_country']); ?> < p class = "form-row form-row-wide" > < label for = "reg_billing_state" > <? php _e('State', 'woocommerce'); ?> < /label> < input type = "text" class = "input-text" name = "billing_state" id = "reg_billing_state" value = "<?php if ( ! empty( $_POST['billing_state'] ) ) esc_attr_e( $_POST['billing_state'] ); ?>" / > < /p> < div class = "clear" > < /div> < p class = "form-row form-row-first" > < label for = "reg_billing_city" > <? php _e('City', 'woocommerce'); ?> < span class = "required" > * < /span></label > < input type = "text" class = "input-text" name = "billing_city" id = "reg_billing_city" value = "<?php if ( ! empty( $_POST['billing_city'] ) ) esc_attr_e( $_POST['billing_city'] ); ?>" / > < /p> < p class = "form-row form-row-last" > < label for = "reg_billing_postcode" > <? php _e('Postal Code', 'woocommerce'); ?> < span class = "required" > * < /span></label > < input type = "text" class = "input-text" name = "billing_postcode" id = "reg_billing_postcode" value = "<?php if ( ! empty( $_POST['billing_postcode'] ) ) esc_attr_e( $_POST['billing_postcode'] ); ?>" / > < /p> < div class = "clear" > < /div> < p class = "form-row form-row-wide" > < label for = "reg_billing_phone" > <? php _e('Phone', 'woocommerce'); ?> < span class = "required" > * < /span></label > < input type = "text" class = "input-text" name = "billing_phone" id = "reg_billing_phone" value = "<?php if ( ! empty( $_POST['billing_phone'] ) ) esc_attr_e( $_POST['billing_phone'] ); ?>" / > < /p> <? php } add_action('woocommerce_register_form', 'wooc_extra_register_fields_after');
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘add extra fields to my Account page’ is closed to new replies.