-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubscription.html
297 lines (266 loc) · 14.3 KB
/
subscription.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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
{% extends "base.html" %}
{% block content %}
<span class="side-menu-value" data-side-menu="subscriptions-page"></span>
<section id="rc_manage_subscription_container">
<div class="edit_subscription_info--wrapper">
<a href="{{ subscription_list_url }}" class="text-font-14">
<i class="fas fa-angle-double-left"></i> {{ 'Back_To_Subscriptions_List' | t }}
</a>
<h3 class="margin-top-15">
{%
if subscription.status == "ACTIVE" or
subscription.status == "CANCELLED" or
subscription.status == "EXPIRED"
%}
{{ 'cp_your_subscription' | t }}
{%
elif subscription.status == "ONETIME" and
subscription.properties | selectattr("name", "equalto", "add_on") | list | length
%}
{{ 'cp_your_add_on_product' | t }}
{% else %}
{{ 'cp_your_onetime_product' | t }}
{% endif %}
</h3>
<!-- Next shipment -->
<div class="rc_card_container rc-card mb-5 cursor-pointer js-edit-next-charge-date" data-date="{{ subscription.next_charge_scheduled_at }}" data-subscription-id="{{ subscription.id }}" data-status="{{ subscription.status}}">
<div>
{% if subscription.charge_interval_frequency != subscription.order_interval_frequency %}
<p class="title-bold text-uppercase color-dark-green">{{ 'next_charge' | t }}</p>
{% else %}
<p class="title-bold text-uppercase color-dark-green">{{ 'next_charge_date' | t }}</p>
{% endif %}
{% if subscription.next_charge_scheduled_at %}
<h3 class="color-light-green margin-top-17">
{% set next_charge_date = subscription.next_charge_scheduled_at | date('%B %d') | downcase %}
{% include '_translated_month.html' %}
</h3>
{% else %}
<h3 class="color-dark-red margin-top-17">{{ 'cp_no_date' | t }}</h3>
{% endif %}
</div>
<i class="fas fa-chevron-right js-edit-next-charge-date-btn" style="display: none;"></i>
</div>
<!-- Deliver every -->
{% if subscription.status == "ACTIVE" %}
<div
class="rc_card_container rc-card mb-5 cursor-pointer js-edit-frequency"
id="delivery_container"
data-id="{{ subscription.id }}"
style="{{ 'pointer-events: auto;' if (subscription.product and subscription.product.subscription_defaults and subscription.product.subscription_defaults.order_interval_frequency_options | length > 1 and subscription.order_interval_frequency == subscription.charge_interval_frequency) or
(settings.customer_portal.subscription.edit_order_frequency == 'Any' and subscription.order_interval_frequency == subscription.charge_interval_frequency) else 'pointer-events: none;'}}"
>
<div>
<p class="title-bold text-uppercase color-dark-green">{{ 'delivery_schedule_label' | t }}</p>
<h3 class="color-light-green margin-top-17">
{{ subscription.order_interval_frequency }}
{% set order_interval_unit = subscription.order_interval_unit %}
{% set frequency = subscription.order_interval_frequency %}
{% include '_translated_order_interval_unit.html' %}
</h3>
</div>
{% if
(subscription.product and subscription.product.subscription_defaults and subscription.product.subscription_defaults.order_interval_frequency_options | length > 1 and subscription.order_interval_frequency == subscription.charge_interval_frequency) or
(settings.customer_portal.subscription.edit_order_frequency == "Any" and subscription.order_interval_frequency == subscription.charge_interval_frequency)
%}
<i class="fas fa-chevron-right js-edit-frequency-btn" style="display: none;"></i>
{% endif %}
</div>
{% endif %}
<!-- Product details -->
<div class="rc-card mb-5 cursor-pointer" onclick="editProduct(event);">
<p class="title-bold text-uppercase color-dark-green">{{ 'Product' | t }}</p>
<div class="edit_subscription_info-product d-flex justify-space-between align-items-center">
<div class="d-flex align-items-center">
<div class="rc_photo_container">
{% set image_size = '100x100' %}
{% include '_product_image.html' %}
</div>
<div class="ml-5">
<h5>{{ subscription.product_title | replace('Auto renew', '') }}</h5>
{% if subscription.variant_title %}
<p style="display: none;">{{ subscription.variant_title }}</p>
{% endif %}
<p>{{ 'Quantity' | t }}: {{ subscription.quantity }}</p>
<p>{{ subscription.price | money_localized }}</p>
</div>
</div>
<i class="fas fa-chevron-right"></i>
</div>
</div>
<!-- Discount card -->
{% if subscription.address.discount_id and subscription.status == "ACTIVE" %}
{% include '_discount_card.html' %}
{% endif %}
<!-- Action buttons -->
{% if payment_sources[0].status == "active" %}
{% if settings.customer_portal.subscription.edit_scheduled_date %}
<div>
{% if subscription.status == "ACTIVE" and subscription.next_charge_scheduled_at %}
<button
class="rc_btn text-uppercase title-bold"
onclick="shipNowHandler(event, '{{ subscription.id }}', '{{ subscription.next_charge_scheduled_at }}', 'true')"
> {{ 'cp_order_now_button' | t }} </button>
{% elif subscription.status == "ONETIME" and subscription.properties | length > 0 %}
{% for prop in subscription.properties %}
{% if prop.name == "add_on" %}
{% elif loop.index == loop.length %}
<button
class="rc_btn text-uppercase title-bold"
onclick="shipNowHandler(event, '{{ subscription.id }}', '{{ subscription.next_charge_scheduled_at }}', 'true')"
> {{ 'cp_order_now_button' | t }} </button>
{% endif %}
{% endfor %}
{% elif subscription.status == "ONETIME" and subscription.properties | length == 0 %}
<button
class="rc_btn text-uppercase title-bold"
onclick="shipNowHandler(event, '{{ subscription.id }}', '{{ subscription.next_charge_scheduled_at }}', 'true')"
> {{ 'cp_order_now_button' | t }} </button>
{% endif %}
</div>
{% endif %}
{% else %}
{% endif %}
{% if subscription.status == "ACTIVE" and subscription.charge_interval_frequency == subscription.order_interval_frequency %}
<div>
<button
class="rc_btn text-uppercase title-bold js-skip-btn js-skip-handler"
data-id="{{ subscription.id }}"
data-date="{{ subscription.next_charge_scheduled_at }}"
data-current-date="{{ subscription.next_charge_scheduled_at | date('%B %d') }}"
data-unit="{{ subscription.order_interval_unit}}"
data-frequency="{{ subscription.order_interval_frequency}}"
data-type="skip" style="display: none;"
> {{ 'cp_skip_shipment' | t }} </button>
</div>
{% endif %}
{% if settings.customer_portal.view_recharge_payment_methods %}
<div class="subscription-shipping-address rc-card mb-5">
<div class="d-flex justify-space-between align-items-center">
<div class="card-content text-body-2">
<h4 class="rc-subheading">Shipping Address</h4>
<div data-shipping-address></div>
</div>
{% if settings.customer_portal.edit_shipping_address %}<i class="fas fa-chevron-right"></i>{% endif %}
</div>
</div>
<div class="subscription-payment-method rc-card mb-5">
<div class="d-flex justify-space-between align-items-center">
<div class="card-content text-body-2">
<h4 class="rc-subheading">Payment Method</h4>
<div data-payment-method></div>
</div>
<i class="fas fa-chevron-right"></i>
</div>
</div>
<div class="customer-email rc-card mb-5">
<div class="d-flex justify-space-between align-items-center">
<div class="card-content text-body-2">
<h4 class="rc-subheading">Email Address</h4>
<div class="email">{{customer.email}}</div>
</div>
<i class="fas fa-chevron-right"></i>
</div>
</div>
{% else %}
<!-- Address card -->
{% set address = subscription.address %}
{% include '_address_card.html' %}
<!-- Billing information -->
{% include '_payment_method_card.html' %}
{% endif %}
<br>
<!-- Discount button -->
{% if subscription.status not in ["CANCELLED", "EXPIRED"]
and not subscription.address.discount_id
and settings.customer_portal.discount_input
%}
<h6
onclick="addDiscountHandler(event);"
data-title="{{ 'cp_add_discount_label' | t }}"
data-id="{{ subscription.address_id }}"
class="js-add-discount-btn text-uppercase text-center"
> {{ 'Apply_discount' | t }} </h6>
{% endif %}
<!-- Cancel button -->
{% if subscription.status == "ACTIVE" %}
<h6
data-title="{{ 'cp_cancel_cancel_title' | t }}"
data-id="{{ subscription.id }}"
data-address-id="{{ subscription.address_id }}"
data-unit="{{ subscription.order_interval_unit }}"
class="rc_cancel-btn text-uppercase text-center js-cancel-sub-btn"
> {{ 'Cancel_Subscription_btn' | t }} </h6>
{% elif subscription.status == "ONETIME" and subscription.properties | length > 0 %}
{% for prop in subscription.properties %}
{% if prop.name == "add_on" %}
<h6
class="rc_cancel-btn text-uppercase text-center js-cancel-otp-btn"
data-onetime-id="{{ subscription.id }}"
onclick="deleteOnetime(event); return false;"
data-add-on=true
> {{ 'cp_delete_product' | t }} </h6>
{% break %}
{% elif loop.index == loop.length %}
<h6
class="rc_cancel-btn text-uppercase text-center js-cancel-otp-btn"
data-onetime-id="{{ subscription.id }}"
onclick="deleteOnetime(event); return false;"
data-add-on=false
> {{ 'cp_remove_product' | t }} </h6>
{% endif %}
{% endfor %}
{% elif subscription.status == "ONETIME" %}
<h6
class="rc_cancel-btn text-uppercase text-center js-cancel-otp-btn"
data-onetime-id="{{ subscription.id }}"
onclick="deleteOnetime(event); return false;"
data-add-on=false
> {{ 'cp_remove_product' | t }} </h6>
{% endif %}
</div>
<div class="upsells--wrapper">
<h2> {{ 'cp_toss_these_in' | t }} </h2>
<div>{{ 'cp_add_product_to_next_package' | t }} </div>
<div class="rc_loader text-center" id="upsells--loader"> </div>
<ul id="rc__upsells--container"> </ul>
{% include '_pagination.html' %}
</div>
</section>
<script>
(function() {
ReCharge.Novum.payment_sources = {{ payment_sources | json }};
ReCharge.Novum.addresses = [{{subscription.address | json }}];
ReCharge.Novum.subscription = {{ subscription | json }};
ReCharge.Novum.store = {{ store | json }};
ReCharge.Novum.settings = {{ settings | json }};
document.addEventListener("DOMContentLoaded", async () => {
ReCharge.Novum.Helpers.fetchChargesOnetimes();
// Check if store allows subscription cancellation
ReCharge.Utils.checkIfStoreAllowsCancellation();
const upsellWrapper = document.querySelector(".upsells--wrapper") || null;
if (ReCharge.Novum.settings.customer_portal.subscription.add_product) {
const schema = ReCharge.Schemas.products.list(12, `upsell_product`);
const data = await ReCharge.Actions.getProducts(12, schema);
ReCharge.Novum.Pagination.type = 'upsell';
ReCharge.Novum.Pagination.updateBtnProps('container');
ReCharge.Novum.Pagination.updateBtnProps('prev');
ReCharge.Novum.Pagination.updateBtnProps('next');
ReCharge.Novum.Pagination.updateBtnProps('current');
if (data.products && data.products.length) {
ReCharge.Novum.Helpers.renderUpsells(data.products);
} else {
upsellWrapper.innerHTML = ReCharge.Utils.renderErrorFetchingProductsLayout();
}
} else {
upsellWrapper.innerHTML = ReCharge.Utils.renderNoProductsLayout();
}
});
let customer = JSON.parse(`{{ customer | json }}`);
console.log(" -------- customer => ", customer);
})();
{% if settings.customer_portal.view_recharge_payment_methods %}
{% include '_subscription.js' %}
{% endif %}
</script>
{% endblock %}