I have two custom fields included in the checkout page and also in the edit address page in myaccounts of woocommerce. The problem is the two custom fields ‘billing_door’ and ‘billing_flatname’ are not getting updated if changed from edit address page.
The code I’m using to display the fields is below. Now how do I update these fields and store it in the database. Thanks in advance
function custom_address_to_edit( $address ) {
global $wp_query;
if ( isset( $wp_query->query_vars['edit-address'] ) && $wp_query->query_vars['edit-address'] != 'billing' ) {
return $address;
}
if ( ! isset( $address['billing_door'] ) ) {
$address['billing_door'] = array(
'label' => __('Door No / Flat No', 'woocommerce'),
'placeholder' => _x('Enter your door number', 'placeholder', 'woocommerce'),
'required' => true,
'class' => array('form-row-first','update_totals_on_change'),
'value' => get_user_meta( get_current_user_id(), 'billing_door', true )
);
}
if ( ! isset( $address['billing_flatname'] ) ) {
$address['billing_flatname'] = array(
'label' => __('Building Name', 'woocommerce'),
'placeholder' => _x('Enter your building name', 'placeholder', 'woocommerce'),
'required' => false,
'class' => array('form-row-last','update_totals_on_change'),
'value' => get_user_meta( get_current_user_id(), 'billing_flatname', true )
);
}
return $address;}