I am working on a woocommerce shop website and need to display the age field within user profile page. I found this in reference to gender and asked if there is something similar for age
Update 2
First look at this official documentation to understand how you can override Woocommerce templates via your active child theme (or active them).
To add an Age field to "My Account" > "Edit Account" section, open/edit myaccount/form-edit-account.php
template file.
Replace from line 36 to 40 the following bloc of code (that includes the "age" field):
<p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
<label for="account_display_name"><?php esc_html_e( 'Display name', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="text" class="woocommerce-Input woocommerce-Input--text input-text" name="account_display_name" id="account_display_name" value="<?php echo esc_attr( $user->display_name ); ?>" /> <span><em><?php esc_html_e( 'This will be how your name will be displayed in the account section and in reviews', 'woocommerce' ); ?></em></span>
</p>
<div class="clear"></div>
By this bloc of code:
<p class="woocommerce-form-row woocommerce-form-row--first form-row form-row-first">
<label for="account_age"><?php esc_html_e( 'Age', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="text" class="woocommerce-Input woocommerce-Input--text input-text" name="account_age" id="account_age" value="<?php echo isset($user->age) ? esc_attr( $user->age ) : ''; ?>" />
</p>
<p class="woocommerce-form-row woocommerce-form-row--last form-row form-row-last">
<label for="account_display_name"><?php esc_html_e( 'Display name', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="text" class="woocommerce-Input woocommerce-Input--text input-text" name="account_display_name" id="account_display_name" value="<?php echo esc_attr( $user->display_name ); ?>" /> <span><em><?php esc_html_e( 'This will be how your name will be displayed in the account section and in reviews', 'woocommerce' ); ?></em></span>
</p>
<div class="clear"></div>
To save the age field value in database:
add_action('woocommerce_save_account_details', 'save_account_details_age', 20, 1 );
function save_account_details_age( $user_id ) {
if ( isset($_POST['account_age']) ) {
update_user_meta($user_id, 'age', sanitize_text_field($_POST['account_age'] ) );
}
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.