-
Notifications
You must be signed in to change notification settings - Fork 9
/
detail.html
275 lines (234 loc) · 14.1 KB
/
detail.html
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
{% extends '_layouts/cp' %}
{% if not discount %}
{% exit 404 %}
{% endif %}
{% do view.registerAssetBundle('verbb\\snipcart\\assetbundles\\SnipcartAsset') %}
{% set crumbs = [
{ label: craft.snipcart.getPluginName(), url: url('snipcart') },
{ label: 'Discounts' | t('snipcart'), url: url('snipcart/discounts') }
] %}
{% set isTestMode = craft.app.plugins.getPlugin('snipcart').getSettings().testMode %}
{% set title = discount.name ~ (isTestMode ? ' 🚧') %}
{% block content %}
<div>
{% if discount.expires and discount.expires < now %}
<div class="block p-2 border border-solid border-alert-blue rounded-sm text-alert-blue mb-6">
{{ 'This discount expired' | t('snipcart') }} {{ discount.expires | date('long') }}.
</div>
{% endif %}
<div class="detail-columns block px-3 mb-8">
<div class="md:flex -mx-6">
<div class="md:w-1/2 mx-3">
<div class="inner">
<h2>{{ 'Details' | t('snipcart') }}</h2>
<table class="data fullwidth fixed-layout -mx-3">
<tbody>
<tr>
<th class="light">{{ 'Type' | t('snipcart') }}</th>
<td>{{ discount.type }}</td>
</tr>
<tr>
<th class="light">{{ 'Created' | t('snipcart') }}</th>
<td>
{{ discount.creationDate | date('long') }}
{%- if discount.expires %}, {{ 'expires' | t('snipcart') }} {{ discount.expires | date('long') }}{% endif %}
</td>
</tr>
{% if 'amount' in discount.typeOptionFields() %}
<tr>
<th class="light">{{ 'Amount' | t('snipcart') }}</th>
<td>{{ discount.amount }}</td>
</tr>
{% endif %}
{% if 'productIds' in discount.typeOptionFields() %}
<tr>
<th class="light">{{ 'Product IDs' | t('snipcart') }}</th>
<td>{{ discount.productIds }}</td>
</tr>
{% endif %}
{% if 'rate' in discount.typeOptionFields() %}
<tr>
<th class="light">{{ 'Rate' | t('snipcart') }}</th>
<td>{{ discount.rate }}</td>
</tr>
{% endif %}
{% if 'alternatePrice' in discount.typeOptionFields() %}
<tr>
<th class="light">{{ 'Alternate Price' | t('snipcart') }}</th>
<td>{{ discount.alternatePrice }}</td>
</tr>
{% endif %}
{% if 'shippingDescription' in discount.typeOptionFields() %}
<tr>
<th class="light">{{ 'Shipping Description' | t('snipcart') }}</th>
<td>{{ discount.shippingDescription }}</td>
</tr>
{% endif %}
{% if 'shippingCost' in discount.typeOptionFields() %}
<tr>
<th class="light">{{ 'Shipping Cost' | t('snipcart') }}</th>
<td>{{ discount.shippingCost }}</td>
</tr>
{% endif %}
{% if 'shippingGuaranteedDaysToDelivery' in discount.typeOptionFields() %}
<tr>
<th class="light">{{ 'Shipping Guaranteed Days to Delivery' | t('snipcart') }}</th>
<td>{{ discount.shippingGuaranteedDaysToDelivery }}</td>
</tr>
{% endif %}
<tr>
<th class="light">{{ 'Trigger' | t('snipcart') }}</th>
<td>{{ discount.trigger }}</td>
</tr>
{% if 'code' in discount.triggerOptionFields() %}
<tr>
<th class="light">{{ 'Code' | t('snipcart') }}</th>
<td><code>{{ discount.code }}</code></td>
</tr>
{% endif %}
{% if 'totalToReach' in discount.triggerOptionFields() %}
<tr>
<th class="light">{{ 'Total to Reach' | t('snipcart') }}</th>
<td>{{ discount.totalToReach }}</td>
</tr>
{% endif %}
{% if 'itemId' in discount.triggerOptionFields() %}
<tr>
<th class="light">{{ 'Item ID' | t('snipcart') }}</th>
<td>{{ discount.itemId }}</td>
</tr>
{% endif %}
<tr>
<th class="light">{{ 'Combinable' | t('snipcart') }}</th>
<td>{{ discount.combinable ? 'yes' | t('snipcart') : 'no' | t('snipcart') }}</td>
</tr>
<tr>
<th class="light">{{ 'Applies on All Recurring Orders' | t('snipcart') }}</th>
<td>{{ discount.appliesOnAllRecurringOrders ? 'yes' | t('snipcart') : 'no' | t('snipcart') }}</td>
</tr>
<tr>
<th class="light">{{ 'Only on Same Products' | t('snipcart') }}</th>
<td>{{ discount.onlyOnSameProducts ? 'yes' | t('snipcart') : 'no' | t('snipcart') }}</td>
</tr>
{% if discount.maxAmountToReach %}
<tr>
<th class="light">{{ 'Max Amount to Reach' | t('snipcart') }}</th>
<td>{{ discount.maxAmountToReach }}</td>
</tr>
{% endif %}
{% if discount.quantityOfAProduct %}
<tr>
<th class="light">{{ 'Quantity of a Product' | t('snipcart') }}</th>
<td>{{ discount.quantityOfAProduct }}</td>
</tr>
{% endif %}
{% if discount.maxQuantityOfAProduct %}
<tr>
<th class="light">{{ 'Max Quantity of a Product' | t('snipcart') }}</th>
<td>{{ discount.maxQuantityOfAProduct }}</td>
</tr>
{% endif %}
{% if discount.quantityOfProductIds %}
<tr>
<th class="light">{{ 'Quantity of Product IDs' | t('snipcart') }}</th>
<td>{{ discount.quantityOfProductIds }}</td>
</tr>
{% endif %}
{% if discount.numberOfItemsRequired %}
<tr>
<th class="light">{{ 'Number of Items Required' | t('snipcart') }}</th>
<td>{{ discount.numberOfItemsRequired }}</td>
</tr>
{% endif %}
{% if discount.numberOfFreeItems %}
<tr>
<th class="light">{{ 'Number of Free Items' | t('snipcart') }}</th>
<td>{{ discount.numberOfFreeItems }}</td>
</tr>
{% endif %}
{% if discount.hasSavedAmount %}
<tr>
<th class="light">{{ 'Has Saved Amount' | t('snipcart') }}</th>
<td>{{ discount.hasSavedAmount ? 'yes' | t('snipcart') : 'no' | t('snipcart') }}</td>
</tr>
{% endif %}
{% if discount.quantityInterval %}
<tr>
<th class="light">{{ 'Quantity Interval' | t('snipcart') }}</th>
<td>{{ discount.quantityInterval }}</td>
</tr>
{% endif %}
{% if discount.affectedItems | length %}
<tr>
<th class="light">{{ 'Affected Items' | t('snipcart') }}</th>
<td>
<ul>
{% for item in discount.affectedItems %}
<li>{{ item }}</li>
{% endfor %}
</ul>
</td>
</tr>
{% endif %}
{% if discount.products | length %}
<tr>
<th class="light">{{ 'Affected Items' | t('snipcart') }}</th>
<td>
<ul>
{% for product in discount.products %}
<li>{{ product }}</li>
{% endfor %}
</ul>
</td>
</tr>
{% endif %}
</tbody>
</table>
</div>
</div>
<div class="mt-8 md:w-1/2 md:mt-0 mx-3">
<div class="inner">
<h2>{{ 'Usage' | t('snipcart') }}</h2>
{% set hasUsage = discount.maxNumberOfUsages ? true : false %}
{% if hasUsage %}
<div class="block border h-2 border-solid border-grey rounded-full w-full relative overflow-hidden mb-5">
{% set usage = discount.numberOfUsages > 0 ? discount.numberOfUsages / discount.maxNumberOfUsages : 0 %}
<div class="bg-grey h-full absolute" style="width: {{ usage * 100 }}%;"></div>
</div>
{% endif %}
<table class="data fullwidth -mx-3 fixed-layout">
<tbody>
<tr>
<th class="light">{{ 'Number of Usages / Max' | t('snipcart') }}</th>
<td>{{ discount.numberOfUsages }} / {{ discount.maxNumberOfUsages ?? '∞' }}</td>
</tr>
<tr>
<th class="light">{{ 'Number of Usages Uncompleted' | t('snipcart') }}</th>
<td>{{ discount.numberOfUsagesUncompleted }}</td>
</tr>
<tr>
<th class="light">{{ 'Is For a Recovery Campaign' | t('snipcart') }}</th>
<td>{{ discount.isForARecoveryCampaign ? 'yes' | t('snipcart') : 'no' | t('snipcart') }}</td>
</tr>
<tr>
<th class="light">{{ 'Archived' | t('snipcart') }}</th>
<td>{{ discount.archived ? 'yes' | t('snipcart') : 'no' | t('snipcart') }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
{% hook 'cp.snipcart.discount.detail' %}
<a href="{{ discount.dashboardUrl() }}" class="btn mt-8" target="_blank">
{{- 'View in Snipcart Dashboard' | t('snipcart') -}}
</a>
<form action="" method="post" class="inline-block ml-1">
<input type="hidden" name="action" value="snipcart/discounts/delete-discount">
<input type="hidden" name="discountId" value="{{ discount.id }}">
{{ csrfInput() }}
<input type="submit" class="btn" value="{{ 'Delete' | t('snipcart') }}">
</form>
</div>
{% endblock %}