-
Notifications
You must be signed in to change notification settings - Fork 9
/
detail.html
225 lines (193 loc) · 11.8 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
{% extends '_layouts/cp' %}
{% import '_includes/forms' as forms %}
{% if not subscription %}
{% exit 404 %}
{% endif %}
{% do view.registerAssetBundle('verbb\\snipcart\\assetbundles\\SnipcartAsset') %}
{% set centered = true %}
{% set isTestMode = craft.app.plugins.getPlugin('snipcart').getSettings().testMode %}
{% set title = 'Subscription for ' ~ subscription.user.billingAddress.fullName ~ (isTestMode ? ' 🚧') %}
{% set crumbs = [
{ label: craft.snipcart.getPluginName(), url: url('snipcart') },
{ label: 'Subscriptions' | t('snipcart'), url: url('snipcart/subscriptions') }
] %}
{% set isCancelled = subscription.cancelledOn is not empty %}
{% block content %}
<div>
{% if isCancelled %}
<div class="block p-2 border border-solid border-alert-blue rounded-sm text-alert-blue mb-8">
{{ 'This subscription was cancelled' | t('snipcart') }} {{ subscription.cancelledOn | date('long') }}.
</div>
{% endif %}
<div class="detail-columns block px-3 mb-8">
<div class="md:flex -mx-6">
<div class="w-full md:w-1/2 mx-3">
<div class="inner">
<table class="data fullwidth fixed-layout -mx-3">
<tbody>
<tr>
<th class="light">{{ 'Name' | t('snipcart') }}</th>
<td>{{ subscription.name }}</td>
</tr>
<tr>
<th class="light">{{ 'Status' | t('snipcart') }}</th>
<td>{{ subscription.status }}</td>
</tr>
<tr>
{% set schedule = subscription.schedule %}
<th class="light">{{ 'Schedule' | t('snipcart') }}</th>
<td>
{{ 'Starts' | t('snipcart') }} {{ schedule.startsOn | date('long') }} and
{{ 'renews every ' | t('snipcart') }} {{ schedule.intervalCount > 1 ? schedule.intervalCount : '' }} {{ schedule.interval | lower }}{{ schedule.intervalCount > 1 ? 's' : '' -}}
{% if schedule.trialPeriodInDays %} {{ 'after' | t('snipcart') }} {{ schedule.trialPeriodInDays }} {{ 'day trial' | t('snipcart') }}{% endif %}.
</td>
</tr>
{% if subscription.initialOrderToken %}
{% set initialOrder = craft.snipcart.getOrder(subscription.initialOrderToken) %}
<tr>
<th class="light">{{ 'Initial Order' | t('snipcart') }}</th>
<td>
<a href="{{ url('snipcart/order/' ~ initialOrder.token) }}">
{{- initialOrder.invoiceNumber -}}
</a>
</td>
</tr>
{% endif %}
{% if subscription.user %}
<tr>
<th class="light">{{ 'Customer' | t('snipcart') }}</th>
<td>
<a href="{{ url('snipcart/customers/' ~ subscription.user.id) }}">
{{- subscription.user.billingAddress.fullName -}}
</a>
</td>
</tr>
{% endif %}
<tr>
<th class="light">{{ 'Amount' | t('snipcart') }}</th>
<td>{{ craft.snipcart.formatCurrency(subscription.amount) }}</td>
</tr>
<tr>
<th class="light">{{ 'Quantity' | t('snipcart') }}</th>
<td>{{ subscription.quantity }}</td>
</tr>
<tr>
<th class="light">{{ 'Total Spent' | t('snipcart') }}</th>
<td>{{ craft.snipcart.formatCurrency(subscription.totalSpent) | raw }}</td>
</tr>
{% if subscription.firstInvoiceReceivedOn %}
<tr>
<th class="light">{{ 'First Invoice Received' | t('snipcart') }}</th>
<td>{{ subscription.firstInvoiceReceivedOn | date('long') }}</td>
</tr>
{% endif %}
<tr>
<th class="light">{{ 'Shipping Charged' | t('snipcart') }}</th>
<td>
{% if subscription.shippingCharged %}
<span data-icon="check"
title="{{ 'Yes' | t('snipcart') }}"></span>
{% else %}
<span data-icon="remove"
title="{{ 'No' | t('snipcart') }}"></span>
{% endif %}
</td>
</tr>
<tr>
<th class="light">{{ 'Recurring Shipping' | t('snipcart') }}</th>
<td>
{% if subscription.recurringShipping %}
<span data-icon="check"
title="{{ 'Yes' | t('snipcart') }}"></span>
{% else %}
<span data-icon="remove"
title="{{ 'No' | t('snipcart') }}"></span>
{% endif %}
</td>
</tr>
{% if subscription.cancelledOn %}
<tr>
<th class="light">{{ 'Cancelled On' | t('snipcart') }}</th>
<td>{{ subscription.cancelledOn | date('long') }}</td>
</tr>
{% endif %}
{% if subscription.gatewayId %}
<tr>
<th class="light">{{ 'Gateway Subscription ID' | t('snipcart') }}</th>
<td><code>{{ subscription.gatewayId }}</code></td>
</tr>
{% endif %}
</tbody>
</table>
</div>
</div>
<div class="w-full md:w-1/2 mx-3 mt-6 md:mt-2">
<div class="inner">
{% if subscription.upcomingPayments %}
<h2>{{ 'Upcoming Payments' | t('snipcart') }}</h2>
<table class="fullwidth">
<thead>
<th>{{ 'Date' | t('snipcart') }}</th>
<th>{{ 'Total' | t('snipcart') }}</th>
<th>{{ 'Taxes' | t('snipcart') }}</th>
<th>{{ 'Shipping' | t('snipcart') }}</th>
</thead>
<tbody>
{% for payment in subscription.upcomingPayments %}
<tr>
<td>{{ payment.date | date('short') }}</td>
<td title="{{ 'subtotal' | t('snipcart') }}: {{ craft.snipcart.formatCurrency(payment.subtotal) }}, {{ 'taxable total' | t('snipcart') }}: {{ craft.snipcart.formatCurrency(payment.taxableTotal) }}">{{ craft.snipcart.formatCurrency(payment.total) }}</td>
<td>
{{ payment.taxes | join("\n") | nl2br }}
</td>
<td>{{ payment.shipping ? craft.snipcart.formatCurrency(payment.shipping) : '' }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% set invoices = subscription.getInvoices() %}
{% if invoices|length %}
<div class="mt-8">
<h2>{{ 'Invoices' | t('snipcart') }}</h2>
<table class="fullwidth">
<thead>
<th>{{ 'Number' | t('snipcart') }}</th>
<th>{{ 'Date' | t('snipcart') }}</th>
<th>{{ 'Amount' | t('snipcart') }}</th>
<th>{{ 'Status' | t('snipcart') }}</th>
</thead>
<tbody>
{% for invoice in subscription.getInvoices() %}
<tr>
<td><a href="{{ cpUrl('snipcart/order/' ~ invoice.id) }}">{{ invoice.number }}</a></td>
<td>{{ invoice.creationDate | date('short') }}</td>
<td>{{ craft.snipcart.formatCurrency(invoice.amount) }}</td>
<td>{{ invoice.paid ? 'Paid' | t('snipcart') : 'Unpaid' | t('snipcart') }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% hook 'cp.snipcart.subscription.detail' %}
<p class="text-muted mt-8">
{{ 'Created' | t('snipcart') }} {{ subscription.creationDate | date('long') }}, {{ 'last updated' | t('snipcart') }} {{ subscription.modificationDate | datetime('short') }}
</p>
<a href="{{ subscription.dashboardUrl() }}" class="btn" target="_blank">
{{- 'View in Snipcart Dashboard' | t('snipcart') -}}
</a>
{% if not isCancelled %}
<form action="" method="post" class="inline-block ml-1">
<input type="hidden" name="action" value="snipcart/subscriptions/cancel">
<input type="hidden" name="subscriptionId" value="{{ subscription.id }}">
{{ csrfInput() }}
<input type="submit" class="btn" value="{{ 'Cancel Subscription' | t('snipcart') }}">
</form>
{% endif %}
</div>
{% endblock %}