my-address.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * My Addresses
  4. *
  5. * This template can be overridden by copying it to yourtheme/woocommerce/myaccount/my-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. * @author WooThemes
  15. * @package WooCommerce/Templates
  16. * @version 2.6.0
  17. */
  18. if ( ! defined( 'ABSPATH' ) ) {
  19. exit; // Exit if accessed directly
  20. }
  21. $customer_id = get_current_user_id();
  22. if ( ! wc_ship_to_billing_address_only() && wc_shipping_enabled() ) {
  23. $get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array(
  24. 'billing' => __( 'Billing address', 'woocommerce' ),
  25. 'shipping' => __( 'Shipping address', 'woocommerce' ),
  26. ), $customer_id );
  27. } else {
  28. $get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array(
  29. 'billing' => __( 'Billing address', 'woocommerce' ),
  30. ), $customer_id );
  31. }
  32. $oldcol = 1;
  33. $col = 1;
  34. ?>
  35. <p>
  36. <?php echo apply_filters( 'woocommerce_my_account_my_address_description', __( 'The following addresses will be used on the checkout page by default.', 'woocommerce' ) ); ?>
  37. </p>
  38. <?php if ( ! wc_ship_to_billing_address_only() && wc_shipping_enabled() ) : ?>
  39. <div class="u-columns woocommerce-Addresses col2-set addresses">
  40. <?php endif; ?>
  41. <?php foreach ( $get_addresses as $name => $title ) : ?>
  42. <div class="u-column<?php echo ( ( $col = $col * -1 ) < 0 ) ? 1 : 2; ?> col-<?php echo ( ( $oldcol = $oldcol * -1 ) < 0 ) ? 1 : 2; ?> woocommerce-Address">
  43. <header class="woocommerce-Address-title title">
  44. <h3><?php echo $title; ?></h3>
  45. <a href="<?php echo esc_url( wc_get_endpoint_url( 'edit-address', $name ) ); ?>" class="edit"><?php _e( 'Edit', 'woocommerce' ); ?></a>
  46. </header>
  47. <address><?php
  48. $address = wc_get_account_formatted_address( $name );
  49. echo $address ? wp_kses_post( $address ) : esc_html_e( 'You have not set up this type of address yet.', 'woocommerce' );
  50. ?></address>
  51. </div>
  52. <?php endforeach; ?>
  53. <?php if ( ! wc_ship_to_billing_address_only() && wc_shipping_enabled() ) : ?>
  54. </div>
  55. <?php endif;