You've already forked wc-bootstrap
110 lines
4.6 KiB
Twig
110 lines
4.6 KiB
Twig
|
|
{#
|
||
|
|
# Shipping Calculator (Bootstrap 5 Override)
|
||
|
|
#
|
||
|
|
# Collapsible form to estimate shipping costs.
|
||
|
|
#
|
||
|
|
# Expected context:
|
||
|
|
# button_text - Submit button text
|
||
|
|
# customer_country - Selected country code
|
||
|
|
# customer_state - Selected state code
|
||
|
|
# customer_city - City value
|
||
|
|
# customer_postcode - Postcode value
|
||
|
|
# countries - Array of country options
|
||
|
|
# states - Array of state options for selected country
|
||
|
|
# show_country - Whether to show country field
|
||
|
|
# show_state - Whether to show state field
|
||
|
|
# show_city - Whether to show city field
|
||
|
|
# show_postcode - Whether to show postcode field
|
||
|
|
#
|
||
|
|
# WooCommerce PHP equivalent: cart/shipping-calculator.php
|
||
|
|
#
|
||
|
|
# @package WcBootstrap
|
||
|
|
# @since 0.1.0
|
||
|
|
#}
|
||
|
|
|
||
|
|
{{ do_action('woocommerce_before_shipping_calculator') }}
|
||
|
|
|
||
|
|
<form class="woocommerce-shipping-calculator mt-3" action="{{ wc_get_cart_url()|esc_url }}" method="post">
|
||
|
|
<a href="#shippingCalcForm"
|
||
|
|
class="btn btn-sm btn-outline-secondary"
|
||
|
|
data-bs-toggle="collapse"
|
||
|
|
role="button"
|
||
|
|
aria-expanded="false"
|
||
|
|
aria-controls="shippingCalcForm">
|
||
|
|
{{ __('Calculate shipping') }}
|
||
|
|
</a>
|
||
|
|
|
||
|
|
<div class="collapse mt-3" id="shippingCalcForm">
|
||
|
|
{% if show_country|default(true) %}
|
||
|
|
<div class="mb-3">
|
||
|
|
<label for="calc_shipping_country" class="form-label">{{ __('Country / region') }}</label>
|
||
|
|
<select name="calc_shipping_country" id="calc_shipping_country" class="form-select country_to_state">
|
||
|
|
<option value="default">{{ __('Select a country / region…') }}</option>
|
||
|
|
{% if countries is defined %}
|
||
|
|
{% for code, name in countries %}
|
||
|
|
<option value="{{ code|esc_attr }}"{% if code == customer_country %} selected{% endif %}>
|
||
|
|
{{ name|esc_html }}
|
||
|
|
</option>
|
||
|
|
{% endfor %}
|
||
|
|
{% endif %}
|
||
|
|
</select>
|
||
|
|
</div>
|
||
|
|
{% endif %}
|
||
|
|
|
||
|
|
{% if show_state|default(true) %}
|
||
|
|
<div class="mb-3">
|
||
|
|
<label for="calc_shipping_state" class="form-label">{{ __('State / county') }}</label>
|
||
|
|
{% if states is defined and states|length > 0 %}
|
||
|
|
<select name="calc_shipping_state" id="calc_shipping_state" class="form-select">
|
||
|
|
<option value="">{{ __('Select an option…') }}</option>
|
||
|
|
{% for code, name in states %}
|
||
|
|
<option value="{{ code|esc_attr }}"{% if code == customer_state %} selected{% endif %}>
|
||
|
|
{{ name|esc_html }}
|
||
|
|
</option>
|
||
|
|
{% endfor %}
|
||
|
|
</select>
|
||
|
|
{% else %}
|
||
|
|
<input type="text"
|
||
|
|
class="form-control"
|
||
|
|
name="calc_shipping_state"
|
||
|
|
id="calc_shipping_state"
|
||
|
|
placeholder="{{ __('State / county') }}"
|
||
|
|
value="{{ customer_state|default('')|esc_attr }}" />
|
||
|
|
{% endif %}
|
||
|
|
</div>
|
||
|
|
{% endif %}
|
||
|
|
|
||
|
|
{% if show_city|default(false) %}
|
||
|
|
<div class="mb-3">
|
||
|
|
<label for="calc_shipping_city" class="form-label">{{ __('City') }}</label>
|
||
|
|
<input type="text"
|
||
|
|
class="form-control"
|
||
|
|
name="calc_shipping_city"
|
||
|
|
id="calc_shipping_city"
|
||
|
|
placeholder="{{ __('City') }}"
|
||
|
|
value="{{ customer_city|default('')|esc_attr }}" />
|
||
|
|
</div>
|
||
|
|
{% endif %}
|
||
|
|
|
||
|
|
{% if show_postcode|default(true) %}
|
||
|
|
<div class="mb-3">
|
||
|
|
<label for="calc_shipping_postcode" class="form-label">{{ __('Postcode / ZIP') }}</label>
|
||
|
|
<input type="text"
|
||
|
|
class="form-control"
|
||
|
|
name="calc_shipping_postcode"
|
||
|
|
id="calc_shipping_postcode"
|
||
|
|
placeholder="{{ __('Postcode / ZIP') }}"
|
||
|
|
value="{{ customer_postcode|default('')|esc_attr }}" />
|
||
|
|
</div>
|
||
|
|
{% endif %}
|
||
|
|
|
||
|
|
<button type="submit" name="calc_shipping" value="1" class="btn btn-outline-primary">
|
||
|
|
{{ button_text|default(__('Update')) }}
|
||
|
|
</button>
|
||
|
|
|
||
|
|
{{ wp_nonce_field('woocommerce-shipping-calculator', 'woocommerce-shipping-calculator-nonce') }}
|
||
|
|
</div>
|
||
|
|
</form>
|
||
|
|
|
||
|
|
{{ do_action('woocommerce_after_shipping_calculator') }}
|