-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathutils.inc.twig
96 lines (90 loc) · 3.85 KB
/
utils.inc.twig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
{% macro get_info_string(context, info) %}
{# don't indent as it will return a non-empty string #}
{# even if there's no error #}
{% for info_entry in info if info_entry.context == context %}
<p>{{ info_entry.message|raw }}</p>
{% endfor %}
{% endmacro %}
{% macro get_error_string(field_name, errors) %}
{# don't indent as it will return a non-empty string #}
{# even if there's no error #}
{% for error in errors if error.context == field_name %}
<p>{{ error.message|raw }}</p>
{% endfor %}
{% endmacro %}
{% macro get_warning_string(context, warnings) %}
{# don't indent as it will return a non-empty string #}
{# even if there's no error #}
{% for warning in warnings if warning.context == context %}
<p>{{ warning.message|raw }}</p>
{% endfor %}
{% endmacro %}
{% macro shipping_results(address, context_class, errors, lang) %}
{% set field_name = 'shipping_service_id' %}
{% if address.prefix != 'shipping' %}
{% set field_name = address.prefix~'_'~field_name %}
{% endif %}
{% set error_string = _self.get_error_string(field_name, errors) %}
{% if address.shipping_results|length > 0 %}
<div class="fc-form-group fc-shipping-rates{% if error_string %} fc-alert-container--error{% endif %}">
<div class="fc-input-group-container--radios {{ context_class }}">
{% for rate in address.shipping_results %}
{# <div class="shipping-rate radio active"> #}
<div class="fc-shipping-rates__rate fc-input-group-container--radio {% if rate.service_id == address.shipping_service_id %}fc-input-group-container--active{% endif %}">
<label for="{{ field_name }}_{{ rate.service_id }}" class="fc-form-label fc-form-label--shipping-rate">
<input
id="{{ field_name }}_{{ rate.service_id }}"
type="radio"
name="{{ field_name }}"
value="{{ rate.service_id }}"
class="fc-form-control--shipping-rate"
{{ checked(rate.service_id, address.shipping_service_id) }}
/><div class="fc-shipping-rates__rate__name">{{ rate.method|raw }} {{ rate.service_name|raw }}</div>
<div class="fc-shipping-rates__rate__value">{{ rate.price|money_format }}</div>
</label>
</div>
{% endfor %}
{% if error_string %}
<div class="fc-alert fc-alert--danger">
{{ lang.checkout_select_shipping_option|raw }}
</div>
{% endif %}
</div>
</div>
{% endif %}
{% endmacro %}
{% macro use_different_addresses(use_different_addresses, lang) %}
<div class="fc-form-group fc-checkout__section--customer-billing-address__use-different-address">
<div class="fc-container__grid--use-different-address">
<div class="fc-input-group-container--checkbox">
<label for="use_different_addresses" class="fc-form-label fc-form-label--different-address">
<input type="hidden" name="use_different_addresses" value="0" />
<input type="checkbox"
id="use_different_addresses"
name="use_different_addresses"
value="1"
{{ checked(use_different_addresses) }} />
{{ lang.checkout_use_billing_address|raw }}
</label>
</div>
</div>
</div>
{% endmacro %}
{% macro address_changed(original, suggested) %}
{% set address_validation_changed = '' %}{% if original != suggested %}fc-address-validation--changed{% endif %}
{% endmacro %}
{% macro taxes(tax, config) %}
{% if tax.rate is null %}
{% set tax_rate = '' %}
{% else %}
{% set tax_rate = ' (<span class="fc_cart_foot_tax_rate">' ~ tax.rate|round(2) ~ '</span>%)' %}
{% endif %}
<tr class="fc-subtotal--row">
<td class="fc-subtotal__label">
{{ tax.name }}{{ tax_rate|raw }}:
</td>
<td class="fc-subtotal__value">
{{ tax.amount|money_format }}
</td>
</tr>
{% endmacro %}