Custom field not being saved in the Address book
-
Hi,
I have added a custom billing field to my checkout page called Alternate Phone Number. I use the following code in my functions.php to add it to the checkout page:
/* Additional Phone number field to Checkout page */ add_filter( 'woocommerce_checkout_fields' , 'woocommerce_checkout_field_editor' ); // Our hooked in function - $fields is passed via the filter! function woocommerce_checkout_field_editor( $fields ) { $fields['billing']['billing_field_value'] = array( 'label' => __('Alternate Phone Number', 'woocommerce'), 'placeholder' => _x('Alternate Phone Number', 'placeholder', 'woocommerce'), 'required' => false ); return $fields; } /* Display Additional Phone number field in Orders page*/ add_action( 'woocommerce_admin_order_data_after_billing_address', 'edit_woocommerce_checkout_page', 10, 1 ); function edit_woocommerce_checkout_page($order){ global $post_id; $order = new WC_Order( $post_id ); echo '<p><strong>'.__('Alternate Phone Number').':</strong> ' . get_post_meta($order->get_id(), '_billing_field_value', true ) . '</p>'; }
But the field is not getting saved in the address book.
How can I get the Address book plugin to save this additional field data?Thanks!
- The topic ‘Custom field not being saved in the Address book’ is closed to new replies.