WC_Shortcode_My_Account::edit_address( string $load_address = 'billing' )
Edit address page.
Description Description
Parameters Parameters
- $load_address
-
(Optional) Type of address to load.
Default value: 'billing'
Source Source
File: includes/shortcodes/class-wc-shortcode-my-account.php
public static function edit_address( $load_address = 'billing' ) { $current_user = wp_get_current_user(); $load_address = sanitize_key( $load_address ); $country = get_user_meta( get_current_user_id(), $load_address . '_country', true ); if ( ! $country ) { $country = WC()->countries->get_base_country(); } if ( 'billing' === $load_address ) { $allowed_countries = WC()->countries->get_allowed_countries(); if ( ! array_key_exists( $country, $allowed_countries ) ) { $country = current( array_keys( $allowed_countries ) ); } } if ( 'shipping' === $load_address ) { $allowed_countries = WC()->countries->get_shipping_countries(); if ( ! array_key_exists( $country, $allowed_countries ) ) { $country = current( array_keys( $allowed_countries ) ); } } $address = WC()->countries->get_address_fields( $country, $load_address . '_' ); // Enqueue scripts. wp_enqueue_script( 'wc-country-select' ); wp_enqueue_script( 'wc-address-i18n' ); // Prepare values. foreach ( $address as $key => $field ) { $value = get_user_meta( get_current_user_id(), $key, true ); if ( ! $value ) { switch ( $key ) { case 'billing_email': case 'shipping_email': $value = $current_user->user_email; break; } } $address[ $key ]['value'] = apply_filters( 'woocommerce_my_account_edit_address_field_value', $value, $key, $load_address ); } wc_get_template( 'myaccount/form-edit-address.php', array( 'load_address' => $load_address, 'address' => apply_filters( 'woocommerce_address_to_edit', $address, $load_address ), ) ); }