WC_Admin_Profile::add_customer_meta_fields()publicWC 1.0

Show Address Fields on edit user pages.

Метод класса: WC_Admin_Profile{}

Возвращает

null. Ничего (null).

Использование

$WC_Admin_Profile = new WC_Admin_Profile();
$WC_Admin_Profile->add_customer_meta_fields( $user );
$user(WP_User) (обязательный)
-

Код WC_Admin_Profile::add_customer_meta_fields() WC 9.4.2

<?php
public function add_customer_meta_fields( $user ) {
	if ( ! apply_filters( 'woocommerce_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_woocommerce' ), $user->ID ) ) {
		return;
	}

	$show_fields = $this->get_customer_meta_fields();

	foreach ( $show_fields as $fieldset_key => $fieldset ) :
		?>
		<h2><?php echo $fieldset['title']; ?></h2>
		<table class="form-table" id="<?php echo esc_attr( 'fieldset-' . $fieldset_key ); ?>">
			<?php foreach ( $fieldset['fields'] as $key => $field ) : ?>
				<tr>
					<th>
						<label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ); ?></label>
					</th>
					<td>
						<?php if ( ! empty( $field['type'] ) && 'select' === $field['type'] ) : ?>
							<select name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" class="<?php echo isset( $field['class'] ) ? esc_attr( $field['class'] ) : ''; ?>" style="width: 25em;">
								<?php
									$selected = esc_attr( get_user_meta( $user->ID, $key, true ) );
								foreach ( $field['options'] as $option_key => $option_value ) :
									?>
									<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $selected, $option_key, true ); ?>><?php echo esc_html( $option_value ); ?></option>
								<?php endforeach; ?>
							</select>
						<?php elseif ( ! empty( $field['type'] ) && 'checkbox' === $field['type'] ) : ?>
							<input type="checkbox" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="1" class="<?php echo esc_attr( $field['class'] ); ?>" <?php checked( (int) get_user_meta( $user->ID, $key, true ), 1, true ); ?> />
						<?php elseif ( ! empty( $field['type'] ) && 'button' === $field['type'] ) : ?>
							<button type="button" id="<?php echo esc_attr( $key ); ?>" class="button <?php echo esc_attr( $field['class'] ); ?>"><?php echo esc_html( $field['text'] ); ?></button>
						<?php else : ?>
							<input type="text" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $this->get_user_meta( $user->ID, $key ) ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" />
						<?php endif; ?>
						<p class="description"><?php echo wp_kses_post( $field['description'] ); ?></p>
					</td>
				</tr>
			<?php endforeach; ?>
		</table>
		<?php
	endforeach;
}