✏️ 正在编辑: address-form.php
路径:
/home/h359620/public_html/wp-content/themes/datis/woocommerce/myaccount/address-form.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php defined('ABSPATH') || exit; $customer_id = isset($customer_id) ? absint($customer_id) : get_current_user_id(); $load_address = isset($load_address) ? sanitize_key($load_address) : 'billing'; if (! in_array($load_address, array('billing', 'shipping'), true)) { $load_address = 'billing'; } $title = ($load_address === 'shipping') ? esc_html_x('Shipping address', 'Address form title', 'datis') : esc_html_x('Billing address', 'Address form title', 'datis'); // Back URL (to cards list) $back_url = function_exists('wc_get_endpoint_url') ? wc_get_endpoint_url('edit-address', '', wc_get_page_permalink('myaccount')) : '#'; /** * Try Woo default account fields first (if available), * otherwise use a full fallback fields set. */ $address_fields = function_exists('wc_get_account_form_fields') ? (array) wc_get_account_form_fields($load_address) : array(); /** * Fallback fields (full + safe) * NOTE: keys must be billing_* or shipping_* so Woo can save them. */ if (empty($address_fields)) { $prefix = ($load_address === 'shipping') ? 'shipping_' : 'billing_'; $countries_obj = function_exists('WC') ? WC()->countries : null; $allowed_countries = ($countries_obj && method_exists($countries_obj, 'get_allowed_countries')) ? $countries_obj->get_allowed_countries() : array(); $default_country = ($countries_obj && method_exists($countries_obj, 'get_base_country')) ? $countries_obj->get_base_country() : ''; $address_fields = array( $prefix . 'first_name' => array( 'type' => 'text', 'required' => true, 'label' => esc_html_x('First name', 'Address field', 'datis'), 'placeholder' => esc_attr_x('First name', 'Address field placeholder', 'datis'), 'autocomplete' => 'given-name', ), $prefix . 'last_name' => array( 'type' => 'text', 'required' => true, 'label' => esc_html_x('Last name', 'Address field', 'datis'), 'placeholder' => esc_attr_x('Last name', 'Address field placeholder', 'datis'), 'autocomplete' => 'family-name', ), $prefix . 'company' => array( 'type' => 'text', 'required' => false, 'label' => esc_html_x('Company', 'Address field', 'datis'), 'placeholder' => esc_attr_x('Company (optional)', 'Address field placeholder', 'datis'), 'autocomplete' => 'organization', ), $prefix . 'country' => array( 'type' => 'country', 'required' => true, 'label' => esc_html_x('Country / Region', 'Address field', 'datis'), 'placeholder' => esc_attr_x('Country / Region', 'Address field placeholder', 'datis'), 'options' => $allowed_countries, 'default' => $default_country, 'class' => array('form-row-wide', 'address-field', 'update_totals_on_change'), ), $prefix . 'state' => array( 'type' => 'state', 'required' => false, 'label' => esc_html_x('State', 'Address field', 'datis'), 'placeholder' => esc_attr_x('State', 'Address field placeholder', 'datis'), 'class' => array('form-row-wide', 'address-field'), ), $prefix . 'city' => array( 'type' => 'text', 'required' => true, 'label' => esc_html_x('City', 'Address field', 'datis'), 'placeholder' => esc_attr_x('City', 'Address field placeholder', 'datis'), 'autocomplete' => 'address-level2', ), $prefix . 'address_1' => array( 'type' => 'text', 'required' => true, 'label' => esc_html_x('Street address', 'Address field', 'datis'), 'placeholder' => esc_attr_x('Street address', 'Address field placeholder', 'datis'), 'autocomplete' => 'address-line1', ), $prefix . 'address_2' => array( 'type' => 'text', 'required' => false, 'label' => esc_html_x('Apartment, suite, etc.', 'Address field', 'datis'), 'placeholder' => esc_attr_x('Apartment, suite, unit, etc. (optional)', 'Address field placeholder', 'datis'), 'autocomplete' => 'address-line2', ), $prefix . 'postcode' => array( 'type' => 'text', 'required' => false, 'label' => esc_html_x('Postcode / ZIP', 'Address field', 'datis'), 'placeholder' => esc_attr_x('Postcode / ZIP', 'Address field placeholder', 'datis'), 'autocomplete' => 'postal-code', ), ); // Billing only (phone/email) if ($load_address === 'billing') { $address_fields[$prefix . 'phone'] = array( 'type' => 'tel', 'required' => false, 'label' => esc_html_x('Phone', 'Address field', 'datis'), 'placeholder' => esc_attr_x('Phone number', 'Address field placeholder', 'datis'), 'autocomplete' => 'tel', ); $address_fields[$prefix . 'email'] = array( 'type' => 'email', 'required' => false, 'label' => esc_html_x('Email', 'Address field', 'datis'), 'placeholder' => esc_attr_x('Email address', 'Address field placeholder', 'datis'), 'autocomplete' => 'email', ); } } /** * Let dev/theme modify fields. */ $address_fields = apply_filters('datis_myaccount_address_form_fields', $address_fields, $load_address, $customer_id); /** * Normalize fields: address styling + placeholder mode */ foreach ($address_fields as $k => $f) { if (! is_array($f)) { $address_fields[$k] = array(); $f = array(); } // wrapper class $f['class'] = isset($f['class']) ? (array) $f['class'] : array(); $f['class'][] = 'address-field'; // input/select/textarea class $f['input_class'] = isset($f['input_class']) ? (array) $f['input_class'] : array(); $f['input_class'][] = 'address-input'; // placeholder from label if empty if (empty($f['placeholder']) && ! empty($f['label'])) { $f['placeholder'] = $f['label']; } // hide label (your UI is placeholder-based) $f['label'] = ''; $address_fields[$k] = $f; } $demo = get_option('datis_active_demo', ''); ?> <div class="address-settings"> <div class="account-wrapper d-flex flex-column gap-4"> <section class="address-card address-card-account"> <div class="address-card-head d-flex flex-row align-items-center justify-content-between"> <h3 class="address-card-title"><?php echo esc_html($title); ?></h3> <a class="address-card-more d-flex flex-row align-items-center gap-2" href="<?php echo esc_url($back_url); ?>"> <?php echo esc_html_x('Back', 'Address form back link', 'datis'); ?> <svg width="20" height="20" viewBox="0 0 20 20" fill="none" aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg"> <path d="M12.5 5H5M5 5V12.5M5 5L10.4167 10.4167M15 15L12.9167 12.9167" stroke="currentColor" stroke-opacity="0.6" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> </svg> </a> </div> <div class="address-card-body mt-4"> <form class="address-form d-flex flex-column gap-3" method="post"> <?php do_action("woocommerce_before_edit_address_form_{$load_address}"); ?> <div class="address-form-grid"> <?php foreach ($address_fields as $key => $field) : ?> <?php $value = wc_get_post_data_by_key($key, get_user_meta($customer_id, $key, true)); woocommerce_form_field($key, $field, $value); ?> <?php endforeach; ?> </div> <?php do_action("woocommerce_after_edit_address_form_{$load_address}"); ?> <div class="address-actions d-flex align-items-center justify-content-end w-100"> <button class="address-btn address-btn-primary" type="submit" name="save_address" value="1"> <?php if ($demo == 'industry') : ?> <svg width="14" height="13" viewBox="0 0 14 13" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M12.7701 11.8579L10.8921 10.2077M0.750669 1.29699L9.2183 0.750029M0.750669 1.29699L1.29763 9.76463M0.750669 1.29699L8.63844 8.22758" stroke="#F5F5F5" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> </svg> <?php elseif ($demo == 'business'): ?> <svg width="44" height="40" viewBox="0 0 44 40" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M10 40C4.47715 40 -1.95703e-07 35.5228 -4.37114e-07 30L-1.31134e-06 10C-1.55275e-06 4.47715 4.47715 -1.95703e-07 10 -4.37114e-07L33.1922 -1.45088e-06C39.6979 -1.73525e-06 44.4715 6.11389 42.8937 12.4254L37.8937 32.4254C36.7807 36.877 32.7809 40 28.1922 40L10 40Z" fill="#F9E65C" /> <path d="M15.3433 15.3139H22.3286M15.3433 15.3139V22.2992M15.3433 15.3139L21.4554 21.4261M24.657 24.6276L23.2017 23.1724" stroke="#0A2647" stroke-width="1.23483" stroke-linecap="round" stroke-linejoin="round" /> </svg> <?php else : ?> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M6 6H15M6 6V15M6 6L12.5 12.5M18 18L15.5 15.5" stroke="#F7F6FE" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path> </svg> <?php endif; ?> <?php if ($demo == 'industry' || $demo == 'business') : echo esc_html_x('Save', 'Address form save button', 'datis'); else : ?> <span><?php echo esc_html_x('Save', 'Address form save button', 'datis'); ?></span> <?php endif; ?> </button> </div> <?php wp_nonce_field('woocommerce-edit_address', 'woocommerce-edit-address-nonce'); ?> <input type="hidden" name="action" value="edit_address" /> </form> </div> </section> </div> </div>
💾 保存文件
← 返回文件管理器