Files
wc-bootstrap/templates/myaccount/my-address.html.twig

58 lines
2.3 KiB
Twig
Raw Permalink Normal View History

{#
# My Addresses (Bootstrap 5 Override)
#
# Shows billing and shipping addresses as Bootstrap cards.
#
# WooCommerce PHP equivalent: myaccount/my-address.php
#
# @package WcBootstrap
# @since 0.1.0
#}
{% set customer_id = get_current_user_id() %}
{% if not wc_ship_to_billing_address_only() and wc_shipping_enabled() %}
{% set get_addresses = apply_filters('woocommerce_my_account_get_addresses', {
billing: __('Billing address'),
shipping: __('Shipping address')
}, customer_id) %}
{% else %}
{% set get_addresses = apply_filters('woocommerce_my_account_get_addresses', {
billing: __('Billing address')
}, customer_id) %}
{% endif %}
<p class="text-body-secondary mb-4">
{{ apply_filters('woocommerce_my_account_my_address_description', __('The following addresses will be used on the checkout page by default.')) }}
</p>
<div class="row g-4">
{% for name, address_title in get_addresses %}
{% set address = wc_get_account_formatted_address(name) %}
<div class="col-md-6">
<div class="card h-100">
<div class="card-header d-flex justify-content-between align-items-center">
<h3 class="h6 mb-0">{{ address_title|esc_html }}</h3>
<a href="{{ wc_get_endpoint_url('edit-address', name)|esc_url }}" class="btn btn-sm btn-outline-primary">
{% if address %}
<i class="bi bi-pencil me-1" aria-hidden="true"></i>{{ __('Edit') }}
{% else %}
<i class="bi bi-plus me-1" aria-hidden="true"></i>{{ __('Add') }}
{% endif %}
</a>
</div>
<div class="card-body">
<address class="mb-0">
{% if address %}
{{ address|wp_kses_post }}
{% else %}
<span class="text-body-secondary">{{ __('You have not set up this type of address yet.') }}</span>
{% endif %}
</address>
{{ do_action('woocommerce_my_account_after_my_address', name) }}
</div>
</div>
</div>
{% endfor %}
</div>