Automattic\WooCommerce\Blocks\Domain\Services
CheckoutFieldsFrontend::edit_account_form_fields()
Adds additional contact fields to the My Account edit account form.
Method of the class: CheckoutFieldsFrontend{}
No Hooks.
Return
null
. Nothing (null).
Usage
$CheckoutFieldsFrontend = new CheckoutFieldsFrontend(); $CheckoutFieldsFrontend->edit_account_form_fields();
CheckoutFieldsFrontend::edit_account_form_fields() CheckoutFieldsFrontend::edit account form fields code WC 9.2.3
public function edit_account_form_fields() { $customer = new WC_Customer( get_current_user_id() ); $fields = $this->checkout_fields_controller->get_fields_for_location( 'contact' ); foreach ( $fields as $key => $field ) { $field_key = CheckoutFields::get_group_key( 'other' ) . $key; $form_field = $field; $form_field['id'] = $field_key; $form_field['value'] = $this->checkout_fields_controller->get_field_from_object( $key, $customer, 'contact' ); if ( 'select' === $field['type'] ) { $form_field['options'] = array_column( $field['options'], 'label', 'value' ); } if ( 'checkbox' === $field['type'] ) { $form_field['checked_value'] = '1'; $form_field['unchecked_value'] = '0'; } woocommerce_form_field( $key, $form_field, wc_get_post_data_by_key( $key, $form_field['value'] ) ); } }