form-edit-address.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Edit address form
  4. *
  5. * This template can be overridden by copying it to yourtheme/woocommerce/myaccount/form-edit-address.php.
  6. *
  7. * HOWEVER, on occasion WooCommerce will need to update template files and you
  8. * (the theme developer) will need to copy the new files to your theme to
  9. * maintain compatibility. We try to do this as little as possible, but it does
  10. * happen. When this occurs the version of the template file will be bumped and
  11. * the readme will list any important changes.
  12. *
  13. * @see https://docs.woocommerce.com/document/template-structure/
  14. * @package WooCommerce/Templates
  15. * @version 3.4.0
  16. */
  17. defined( 'ABSPATH' ) || exit;
  18. $page_title = ( 'billing' === $load_address ) ? __( 'Billing address', 'woocommerce' ) : __( 'Shipping address', 'woocommerce' );
  19. do_action( 'woocommerce_before_edit_account_address_form' ); ?>
  20. <?php if ( ! $load_address ) : ?>
  21. <?php wc_get_template( 'myaccount/my-address.php' ); ?>
  22. <?php else : ?>
  23. <form method="post">
  24. <h3><?php echo apply_filters( 'woocommerce_my_account_edit_address_title', $page_title, $load_address ); ?></h3><?php // @codingStandardsIgnoreLine ?>
  25. <div class="woocommerce-address-fields">
  26. <?php do_action( "woocommerce_before_edit_address_form_{$load_address}" ); ?>
  27. <div class="woocommerce-address-fields__field-wrapper">
  28. <?php
  29. foreach ( $address as $key => $field ) {
  30. if ( isset( $field['country_field'], $address[ $field['country_field'] ] ) ) {
  31. $field['country'] = wc_get_post_data_by_key( $field['country_field'], $address[ $field['country_field'] ]['value'] );
  32. }
  33. woocommerce_form_field( $key, $field, wc_get_post_data_by_key( $key, $field['value'] ) );
  34. }
  35. ?>
  36. </div>
  37. <?php do_action( "woocommerce_after_edit_address_form_{$load_address}" ); ?>
  38. <p>
  39. <button type="submit" class="button" name="save_address" value="<?php esc_attr_e( 'Save address', 'woocommerce' ); ?>"><?php esc_html_e( 'Save address', 'woocommerce' ); ?></button>
  40. <?php wp_nonce_field( 'woocommerce-edit_address', 'woocommerce-edit-address-nonce' ); ?>
  41. <input type="hidden" name="action" value="edit_address" />
  42. </p>
  43. </div>
  44. </form>
  45. <?php endif; ?>
  46. <?php do_action( 'woocommerce_after_edit_account_address_form' ); ?>