PageSourceSearch

https://westcozcafe.com/Scripts/v2/home/_discount.js?v=111.20260916-129

js westcozcafe.com collected 2026-09-30 10:40:33 UTC 70,879 bytes, 1,714 lines download raw bytes

1var listAppliedVouchers = null;
2var eligibleStackableVouchers = null;
3
4//var voucherIdApplied = 0;
5var promoCodeIdApplied = 0;
6
7const confirmRemoveDiscountRewardsId = "#confirmRemoveDiscountRewards";
8
9const apllyVoucherPopupId = "#aplly-voucher-popup";
10const apllyPromoCodePopupId = "#aplly-promo-code-popup";
11const detailDiscountPopupId = "#detail-discount-popup";
12const containMyCartId = "#containmycart";
13const memberPointPopupId = "#member-point-popup";
14const memberPointNumberId = "#member-point-number";
15const redeemRewardsId = "#redeem-rewards-popup";
16
17const apllyVoucherBody = `${apllyVoucherPopupId} .popup-body`;
18const apllyPromoCodeBody = `${apllyPromoCodePopupId} .popup-body`;
19const detailDiscountBody = `${detailDiscountPopupId} .popup-body`;
20const memberPointBody = `${memberPointPopupId} .popup-body`;
21
22if (typeof openVoucherTermsIframe !== 'function') {
23    function openVoucherTermsIframe(e, voucherId, isIssued, prePopupSelector, headerTitle, isDisabled, itemId, discountType) {
24        if (typeof waitingForAction === 'function') {
25            waitingForAction(e, true);
26        }
27
28        $(detailDiscountPopupId).off('click', '#btn-pcv-back');
29        $(detailDiscountPopupId).on('click.openVoucherTermsIframe', '#btn-pcv-back', function (ev) {
30            if (ev && typeof ev.preventDefault === 'function') ev.preventDefault();
31            if (ev && typeof ev.stopPropagation === 'function') ev.stopPropagation();
32            $(detailDiscountPopupId).find('.popup-close').trigger('click');
33        });
34
35        var loadingHtml = ''
36            + '<div style="height:50vh;display:flex;align-items:center;justify-content:center;">'
37            + '  <i class="fa fa-spinner fa-spin" style="font-size:24px;"></i>'
38            + '</div>';
39
40        $(detailDiscountBody).html(loadingHtml);
41
42        if (prePopupSelector) {
43            $(detailDiscountPopupId).attr('data-pre-id', prePopupSelector);
44            $(prePopupSelector).removeClass('popup-show');
45        }
46
47        if (typeof showPopup === 'function') {
48            showPopup(detailDiscountPopupId);
49        }
50
51        if (typeof UpdateDetailDiscountPopup === 'function' && typeof discountType !== 'undefined') {
52            UpdateDetailDiscountPopup(headerTitle || 'Detail Voucher', !!isDisabled, itemId || voucherId, discountType);
53        } else {
54            $(detailDiscountPopupId).find('.popup-title').text(headerTitle || 'Detail Voucher');
55            $(detailDiscountPopupId).find('#btn-pcv-apply').hide();
56            $(detailDiscountPopupId).find('#btn-pcv-back').hide();
57        }
58
59        $.ajax({
60            type: "GET",
61            cache: false,
62            data: {
63                voucherId: voucherId,
64                isIssued: isIssued
65            },
66            url: discountURl.getVoucherTermsIframe
67        }).done(function (response) {
68            if (!response || !response.success || !response.iframeUrl) {
69                $(detailDiscountBody).html('<div style="padding:16px;">Unable to load voucher terms. Please try again.</div>');
70                return;
71            }
72
73            var iframeHtml = '<iframe src="' + response.iframeUrl + '" style="width:100%;height:50vh;border:0;" allowfullscreen></iframe>';
74            $(detailDiscountBody).html(iframeHtml);
75        }).fail(function (jqXHR, textStatus) {
76            console.log(jqXHR, textStatus);
77            $(detailDiscountBody).html('<div style="padding:16px;">Unable to load voucher terms. Please try again.</div>');
78        }).always(function () {
79            if (typeof waitingForAction === 'function') {
80                waitingForAction(e, false);
81            }
82        });
83    }
84}
85
86$(() => {
87    /*Common*/
88
89    $(document).on('click', '.js-voucher-blocked-dates', function (e) {
90        if (e && typeof e.preventDefault === 'function') e.preventDefault();
91        if (e && typeof e.stopPropagation === 'function') e.stopPropagation();
92
93        var $link = $(this);
94        var blockoutTime = $link.attr('data-blockout-time') || '';
95        var applicableDate = $link.attr('data-applicable-date') || '';
96
97        var details = blockoutTime || applicableDate;
98        if (!details) return;
99
100        $link.replaceWith('(between ' + details + ')');
101    });
102
103    $(containMyCartId).on('click', '.btn-remove-rewards', (e) => {
104        let discountType = $(e.currentTarget).attr('data-type');
105
106        $(confirmRemoveDiscountRewardsId).attr('data-type', discountType);
107        $(confirmRemoveDiscountRewardsId).find('.confirm-remove-msg').hide();
108
109        if (discountType == 0) {
110            $(confirmRemoveDiscountRewardsId).find('.confirm-remove-voucher').show();
111        }
112        else if (discountType == 1) {
113            $(confirmRemoveDiscountRewardsId).find('.confirm-remove-promo-code').show();
114        }
115        else if (discountType == 2) {
116            $(confirmRemoveDiscountRewardsId).find('.confirm-remove-member-points').show();
117        }
118
119        $(confirmRemoveDiscountRewardsId).modal('show');
120    });
121
122    $(confirmRemoveDiscountRewardsId).on('click', '#confirm-remove-discount-rewards-confirm-btn', (e) => {
123        let discountType = $(confirmRemoveDiscountRewardsId).attr('data-type');
124
125        if (discountType == 0) {
126            removeVoucher(e.currentTarget);
127        }
128        else if (discountType == 1) {
129            removePromoCode(e.currentTarget);
130        }
131        else if (discountType == 2) {
132            removePoint(e.currentTarget);
133        }
134    });
135
136    $(containMyCartId).on('click', '#btnAddVoucher', (e) => {
137        waitingForAction(e.currentTarget, true);
138
139        $(apllyVoucherPopupId).find('.count-voucher-selected').css('display', 'none');
140        $(apllyVoucherPopupId).find('.btn-apply-discount').attr('disabled', 'disabled');
141
142        showPopup(apllyVoucherPopupId, () => {
143            $(apllyVoucherPopupId).find('.aplly-voucher-group-input-error').text('').hide();
144            $(apllyVoucherPopupId).find('#aplly-voucher-text').removeClass('input-error');
145
146            let checkText = $(apllyVoucherPopupId).find('#aplly-voucher-text').val();
147
148            if (checkText == null || checkText == '') {
149                checkText = getSessionStorage("aplly-voucher-text");
150            }
151
152            if (checkText != null && checkText.length > 0) {
153                loadSeletonVouchers();
154            }
155            else {
156                let domainKey = removeDomainSpecificCharacters(window.location.origin);
157                let memberTocken = sessionStorage.getItem(`${domainKey}_member_token`);
158                if (memberTocken != null && memberTocken.length > 0) {
159                    loadSeletonVouchers();
160                }
161            }
162
163            resizeBodyPopup(apllyVoucherPopupId);
164            $(apllyVoucherBody).scrollTop(0);
165
166            waitingForAction(e.currentTarget, false);
167        });
168
169        getVoucherSection(e.currentTarget);
170    });
171
172    $(containMyCartId).on('click', '#btnShowVoucherPopupLogin', (e) => {
173        showPopup("#member-voucher-login-popup");
174    });
175
176    $(apllyVoucherBody).on('click', '.pcv-item_select-service', (e) => {
177        hidePopup(apllyVoucherPopupId, () => {
178            selectService();
179        });
180    });
181
182    $(apllyVoucherBody).on('click', '.pcv-item_add-item-to-cart', (e) => {
183        let skus = $(e.currentTarget).attr('data-sku');
184        let voucherId = $(e.currentTarget).attr('data-id');
185        let phoneNumber = $(apllyVoucherPopupId).find('#aplly-voucher-text').val();
186
187        addItemToCartVoucher(e.currentTarget, skus, voucherId, phoneNumber);
188    });
189
190    $(apllyPromoCodeBody).on('click', '.pcv-item_select-service', (e) => {
191        hidePopup(apllyVoucherPopupId, () => {
192            selectService();
193        });
194    });
195
196    $(apllyPromoCodeBody).on('click', '.pcv-item_add-item-to-cart', (e) => {
197        let skus = $(e.currentTarget).attr('data-sku');
198        let promoCodeId = $(e.currentTarget).attr('data-id');
199        let promoCodeValue = $(apllyPromoCodePopupId).find('#promo-code-text').val();
200
201
202        addItemToCartPromoCode(e.currentTarget, skus, promoCodeId, promoCodeValue);
203    });
204
205    $(containMyCartId).on('click', '#btnAddPromoCode', (e) => {
206        let promoCodeValue = $(apllyPromoCodePopupId).find('#promo-code-text').val();
207        let promoCodeId = $(e.currentTarget).attr('data-id');
208
209        //if (promoCodeValue == null || promoCodeValue == '') {
210        //    promoCodeValue = getSessionStorage("promo-code-text");
211
212        //    if (promoCodeValue == null) {
213        //        promoCodeValue = '';
214        //    }
215        //    else {
216        //        $(apllyPromoCodePopupId).find('#promo-code-text').val(promoCodeValue);
217        //    }
218        //}
219
220        getPromoCodeSection(e.currentTarget, promoCodeValue, promoCodeId);
221    });
222
223    //$(containMyCartId).on('click', '#btnRemovePromoCode', (e) => {
224    //    removePromoCode(e.currentTarget, 0);
225    //});
226
227    $(containMyCartId).on('click', '#btnAddMemberPoint', (e) => {
228        getMemberPointSection(e.currentTarget);
229    });
230
231    //$(containMyCartId).on('click', '#btnRemovePoints', (e) => {
232    //    removePoint(e.currentTarget);
233    //});
234
235    $(containMyCartId).on('click', '.discount-item__message--action', (e) => {
236        $(e.currentTarget).parents('.discount-item__message').remove();
237    });
238
239    $(apllyPromoCodePopupId).on('click', '#btnApplyPromoCodeText', (e) => {
240        $(apllyPromoCodePopupId).find('.promo-code-group-input-error').hide();
241        $(apllyPromoCodePopupId).find('#promo-code-text').removeClass('input-error');
242
243        let promoCodeValue = $(apllyPromoCodePopupId).find('#promo-code-text').val();
244
245        //setSessionStorage("promo-code-text", promoCodeValue);
246
247        getPromoCodeSection(e.currentTarget, promoCodeValue, '', true);
248        //findPromoCodeByText(e.currentTarget, promoCodeValue);
249
250        //if (promoCodeValue != null && promoCodeValue.length > 0) {
251        //    findPromoCodeByText(e.currentTarget, promoCodeValue);
252        //}
253        //else {
254        //    $(apllyPromoCodePopupId).find('.promo-code-group-input-error').show();
255        //    $(apllyPromoCodePopupId).find('#promo-code-text').addClass('input-error');
256        //}
257    });
258
259    $(apllyPromoCodePopupId).on('click', '.promo-code-group-input-clear', () => {
260        $(apllyPromoCodePopupId).find('#promo-code-text').val('').focus();
261        getPromoCodeSection('', '', '', false, true);
262    });
263
264    $(apllyVoucherPopupId).on('click', '.aplly-voucher-group-input-clear', (e) => {
265        $(apllyVoucherPopupId).find('#aplly-voucher-text').val('').focus();
266
267        $(apllyVoucherPopupId).find('.aplly-voucher-group-input-error').text('').hide();
268        $(apllyVoucherPopupId).find('.aplly-voucher-input').removeClass("input-error");
269
270        if ($(apllyVoucherPopupId).find('.required-login-vouchers').length > 0) {
271            $(apllyVoucherPopupId).find('.required-login-vouchers').show();
272            $(apllyVoucherPopupId).find('.member-point__btn-sign-up').show();
273        }
274        else if ($(e.currentTarget).hasClass('is-logined')) {
275            removeSessionStorage("aplly-voucher-text");
276        }
277    });
278
279    $(apllyVoucherPopupId).on('click', '#btn-voucher-apply', (e) => {
280
281        let phoneNumber = $(apllyVoucherPopupId).find('#aplly-voucher-text').val();
282
283        if (phoneNumber == null || phoneNumber == '') {
284            phoneNumber = getSessionStorage("aplly-voucher-text");
285        }
286
287        //let vouchers = $(apllyVoucherPopupId).find('.pcv-section.item-selected').map(function (index, element) { return { Id: $(element).attr('data-id'), ShareCode: $(element).attr('data-code') } }).get();
288        //console.log('vouchers', vouchers);
289
290        //applyVoucher(e.currentTarget, vouchers, phoneNumber);
291        applyVoucher(e.currentTarget, phoneNumber);
292    });
293
294    $(apllyVoucherPopupId).on('click', '#btn-voucher-return-to-cart', (e) => {
295        $(apllyVoucherPopupId).find('.popup-close').trigger('click');
296    });
297
298    $(apllyVoucherPopupId).on('input', '#aplly-voucher-text', function (e) {
299        //$(this).val($(this).val().replace(/[^0-9]/g, ''));
300    });
301
302    //$(apllyVoucherPopupId).on('keypress', '#aplly-voucher-text', function (event) {
303    //    var key = event.keyCode;
304    //    console.log($(this).val());
305    //    console.log($(this).val().replace(/[^0-9]/g, ''));
306    //    if (key < 48 || key > 57) {
307    //        event.preventDefault();
308    //    }
309    //});
310
311    $(apllyPromoCodePopupId).on('click', '#btn-pc-apply', (e) => {
312        let promoCodeId = $(apllyPromoCodePopupId).find('.pcv-section.item-selected').attr('data-id');
313        let promoCodeValue = $(apllyPromoCodePopupId).find('#promo-code-text').val();
314
315        applyPromoCode(e.currentTarget, promoCodeId, promoCodeValue);
316    });
317
318    $(memberPointPopupId).on('click', '#btn-member-point-apply', (e) => {
319        let pointApply = $(memberPointPopupId).find(memberPointNumberId).val();
320
321        pointApply = checkMemberPointNumber(pointApply);
322
323        if (pointApply != null) {
324            applyMemberPoint(e.currentTarget, pointApply);
325        }
326    });
327
328    $(memberPointPopupId).on("input", "#choose-points-range", (e) => {
329        const currentValue = e.target.value;
330        onChangePointsRangeSlider(currentValue);
331    });
332
333    $(memberPointPopupId).on("keypress", memberPointNumberId, function (e) {
334        //if the letter is not digit then display error and don't type anything
335        if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
336            return false;
337        }
338    });
339
340    $(apllyVoucherPopupId).on('click', '#btnApplyPhoneNumberText', (e) => {
341        let voucherText = $(apllyVoucherPopupId).find('#aplly-voucher-text').val();
342
343        if (voucherText == null || voucherText == '') {
344            voucherText = '';
345            let textvoucherCodeMessageEmpty = $('#voucher-code-message-empty').val();
346
347            $(apllyVoucherPopupId).find('.aplly-voucher-group-input-error').html(textvoucherCodeMessageEmpty).show();
348            $(apllyVoucherPopupId).find('#aplly-voucher-text').addClass('input-error');
349        }
350        else {
351            $(apllyVoucherPopupId).find('.aplly-voucher-group-input-error').text('').hide();
352            $(apllyVoucherPopupId).find('#aplly-voucher-text').removeClass('input-error');
353
354            let currentVoucherCodes = $(apllyVoucherPopupId).find('.eligible-voucher-info .pcv-section.item-selected').map((i, e) => $(e).attr('data-code'));
355            if (currentVoucherCodes != null && currentVoucherCodes.length > 0) {
356                for (var x = 0; x < currentVoucherCodes.length; x++) {
357                    if (currentVoucherCodes[x] == voucherText) {
358                        let msgVoucherText = $(apllyVoucherPopupId).find('.aplly-voucher-group-input-error').attr("data-text");
359                        $(apllyVoucherPopupId).find('.aplly-voucher-group-input-error').html(msgVoucherText).show();
360                        return false;
361                    }
362                }
363            }
364
365            $(apllyVoucherPopupId).find('.btn-apply-discount').attr('disabled', 'disabled');
366            loadSeletonVouchers();
367
368            setSessionStorage("aplly-voucher-text", voucherText);
369            getVoucherSectionByText(e.currentTarget, voucherText);
370        }
371    });
372
373    //$(apllyPromoCodePopupId).on('click', '#btn-pc-apply', () => {
374    //    hidePopup(null, () => {
375    //        $('.aplly-pc-section').find('.aplly-pc__title').removeClass('sticky-top').removeAttr('style');
376    //    });
377    //});
378
379    $(apllyPromoCodePopupId).on('click', '#btn-pc-return-to-cart', (e) => {
380        $(apllyPromoCodePopupId).find('.popup-close').trigger('click');
381    });
382
383    $(apllyVoucherPopupId).on('click', '.eligible-voucher-info .pcv-section', (e) => {
384        if (e.target !== e.currentTarget && $(e.target).hasClass('btn-view-tc')) {
385            return false;
386        }
387        else {
388            let voucherId = parseFloat($(e.currentTarget).attr('data-id'));
389            let shareCode = $(e.currentTarget).attr('data-code');
390
391            if ($(e.currentTarget).hasClass('item-disabled')) {
392                if ($(e.currentTarget).hasClass('item-selected')) {
393                    $(e.currentTarget).removeClass('item-selected');
394
395                    if (listAppliedVouchers != null && listAppliedVouchers.length > 0) {
396                        for (let i = 0; i < listAppliedVouchers.length; i++) {
397                            let appliedVoucher = listAppliedVouchers[i];
398
399                            if (appliedVoucher.Id == voucherId) {
400                                appliedVoucher.IsRemove = true;
401                                break;
402                            }
403                        }
404                    }
405
406                    if ($(apllyVoucherPopupId).find('.eligible-voucher-info .pcv-section.item-selected') == null || $(apllyVoucherPopupId).find('.eligible-voucher-info .pcv-section.item-selected').length == 0) {
407                        $(apllyVoucherPopupId).find('#voucher-clear-selection').css('display', 'none');
408                    }
409
410                    checkEligibleStackableVouchers();
411                    checkItemChooseEnalbleVoucherApplyButton(apllyVoucherPopupId);
412                }
413                else {
414                    $(apllyVoucherPopupId).find(`.eligible-voucher-info .pcv-item_action.voucher-not-combined-${voucherId}`).css('display', 'flex');
415                }
416            }
417            else {
418                $(apllyVoucherPopupId).find('.popup-footer-available').show();
419
420                if ($(e.currentTarget).hasClass('item-selected')) {
421                    $(e.currentTarget).removeClass('item-selected');
422
423                    if (listAppliedVouchers != null && listAppliedVouchers.length > 0) {
424                        for (let i = 0; i < listAppliedVouchers.length; i++) {
425                            let appliedVoucher = listAppliedVouchers[i];
426                            if (appliedVoucher.Id == voucherId) {
427                                appliedVoucher.IsRemove = true;
428                                break;
429                            }
430                        }
431                    }
432
433                    if ($(apllyVoucherPopupId).find('.eligible-voucher-info .pcv-section.item-selected') == null || $(apllyVoucherPopupId).find('.eligible-voucher-info .pcv-section.item-selected').length == 0) {
434                        $(apllyVoucherPopupId).find('#voucher-clear-selection').css('display', 'none');
435                    }
436                }
437                else {
438                    $(e.currentTarget).addClass('item-selected');
439                    $(apllyVoucherPopupId).find('#voucher-clear-selection').css('display', 'block');
440
441                    if (listAppliedVouchers != null && listAppliedVouchers.length > 0 && listAppliedVouchers.some(v => v.Id == voucherId)) {
442                        for (let i = 0; i < listAppliedVouchers.length; i++) {
443                            let appliedVoucher = listAppliedVouchers[i];
444
445                            if (appliedVoucher.Id == voucherId) {
446                                appliedVoucher.IsRemove = false;
447                                break;
448                            }
449                        }
450                    }
451                    else {
452                        listAppliedVouchers.push({
453                            Id: voucherId,
454                            ShareCode: shareCode,
455                        });
456                    }
457
458                }
459
460                checkEligibleStackableVouchers();
461                checkItemChooseEnalbleVoucherApplyButton(apllyVoucherPopupId);
462            }
463        }
464    });
465
466    $(apllyVoucherPopupId).on('click', '#non-eligible-voucher-available .pcv-section', (e) => {
467        if (e.target !== e.currentTarget && $(e.target).hasClass('btn-view-tc')) {
468            return false;
469        }
470        else if ($(e.currentTarget).hasClass('item-selected')) {
471            $(e.currentTarget).removeClass('item-selected');
472
473            let voucherId = parseFloat($(e.currentTarget).attr('data-id'));
474
475            if (listAppliedVouchers != null && listAppliedVouchers.length > 0) {
476                for (let i = 0; i < listAppliedVouchers.length; i++) {
477                    let appliedVoucher = listAppliedVouchers[i];
478
479                    if (appliedVoucher.Id == voucherId) {
480                        appliedVoucher.IsRemove = true;
481                        break;
482                    }
483                }
484            }
485
486            checkEligibleStackableVouchers();
487            checkItemChooseEnalbleVoucherApplyButton(apllyVoucherPopupId);
488        }
489    });
490
491    $(apllyVoucherPopupId).on('click', '#voucher-clear-selection', (e) => {
492        $(apllyVoucherPopupId).find('.eligible-voucher-info .pcv-section.item-selected').removeClass('item-selected');
493        $(e.currentTarget).css('display', 'none');
494
495        if (listAppliedVouchers != null && listAppliedVouchers.length > 0) {
496            for (let i = 0; i < listAppliedVouchers.length; i++) {
497                listAppliedVouchers[i].IsRemove = true;
498            }
499        }
500
501        //voucherClearSelection();
502
503        checkEligibleStackableVouchers();
504        checkItemChooseEnalbleVoucherApplyButton(apllyVoucherPopupId);
505    });
506
507    $(apllyPromoCodePopupId).on('click', '.eligible-pc-info .pcv-section', (e) => {
508        if (!$(e.currentTarget).hasClass('item-disabled')) {
509            $(apllyPromoCodePopupId).find('.popup-footer-available').show();
510
511            if (promoCodeIdApplied == $(e.currentTarget).attr('data-id')) {
512                $(apllyPromoCodePopupId).find('.apply-pc__btn-apply').hide();
513                $(apllyPromoCodePopupId).find('.promo-code-selected').show();
514                $(apllyPromoCodePopupId).find('.popup-footer-past-rewards').show();
515            }
516            else {
517                $(apllyPromoCodePopupId).find('.apply-pc__btn-apply').show();
518                $(apllyPromoCodePopupId).find('.promo-code-selected').hide();
519                $(apllyPromoCodePopupId).find('.popup-footer-past-rewards').hide();
520            }
521
522            $(apllyPromoCodePopupId).find('.pcv-section').removeClass('item-selected');
523            $(e.currentTarget).addClass('item-selected');
524
525            checkItemChooseEnalbleApplyButton(apllyPromoCodePopupId);
526        }
527    });
528
529    $(detailDiscountPopupId).on('click', '#btn-pcv-apply', (e) => {
530        let itemId = parseFloat($(e.currentTarget).attr('data-id'));
531        let shareCode = $(e.currentTarget).attr('data-code');
532        let discountType = $(e.currentTarget).attr('data-type');
533
534        if (itemId != null && itemId > 0) {
535            if (discountType == 0) {
536                let phoneNumber = $(apllyVoucherPopupId).find('#aplly-voucher-text').val();
537
538                if (phoneNumber == null) {
539                    phoneNumber = '';
540                }
541
542                $(apllyVoucherPopupId).find(`.eligible-voucher-info .pcv-section.voucher-stackable-${itemId}`).addClass('item-selected');
543                $(apllyVoucherPopupId).find('#voucher-clear-selection').css('display', 'block');
544
545                if (listAppliedVouchers != null && listAppliedVouchers.length > 0 && listAppliedVouchers.some(v => v.Id == itemId)) {
546                    for (let i = 0; i < listAppliedVouchers.length; i++) {
547                        let appliedVoucher = listAppliedVouchers[i];
548
549                        if (appliedVoucher.Id == itemId) {
550                            appliedVoucher.IsRemove = false;
551                            break;
552                        }
553                    }
554                }
555                else {
556                    listAppliedVouchers.push({
557                        Id: itemId,
558                        ShareCode: shareCode,
559                    });
560                }
561
562                checkEligibleStackableVouchers();
563                checkItemChooseEnalbleVoucherApplyButton(apllyVoucherPopupId);
564
565                $(detailDiscountPopupId).find('.popup-close').trigger('click');
566            }
567            else if (discountType == 1) {
568                let promoCodeValue = $(apllyPromoCodePopupId).find('#promo-code-text').val();
569
570                if (promoCodeValue == null) {
571                    promoCodeValue = '';
572                }
573
574                applyPromoCode(e.currentTarget, itemId, promoCodeValue);
575            }
576
577            $(detailDiscountPopupId).removeAttr('data-pre-id');
578        }
579    });
580
581    $(detailDiscountPopupId).on('click', '#btn-pcv-back', (e) => {
582        const preId = $(detailDiscountPopupId).attr('data-pre-id');
583        if (preId) {
584            $(preId).addClass('popup-show');
585            $(detailDiscountPopupId).removeAttr('data-pre-id');
586        }
587
588        $(detailDiscountPopupId).find('.popup-close').trigger('click');
589    });
590
591    /*Common*/
592    /*---*/
593    /*Voucher*/
594    $(apllyVoucherBody).scroll(function () {
595        stickyTitleVoucher(apllyVoucherBody);
596    });
597
598    $(apllyVoucherBody).on('click', '.aplly-voucher__title.sticky-top', function (e) {
599        if (e.target !== e.currentTarget && $(e.target).attr('id') == 'voucher-clear-selection') {
600            ///
601        }
602        else {
603            let id = $(this).parents('.aplly-voucher-section').attr('id');
604            let top = 50;
605
606            if (id == 'eligible-voucher-available' || id == 'expired-voucher-past') {
607                top *= 1;
608            }
609            else if (id == 'non-eligible-voucher-available' || id == 'redeemed-voucher-past') {
610                top *= 2;
611            }
612
613            scrollToElement('#' + id, apllyVoucherBody, top);
614        }
615    });
616
617    $(apllyVoucherPopupId).on('click', '.aplly-voucher-nav-tabs a', function () {
618        $(apllyVoucherBody).scrollTop(0);
619        $(apllyVoucherBody).find('.aplly-voucher__title').removeClass('sticky-top').removeAttr('style');
620
621        const hrefTab = $(this).attr("href");
622
623        if (hrefTab == "#voucher-available" && $('#eligible-voucher-available').find('.pcv-section').length > 0) {
624            $(apllyVoucherPopupId).find('.popup-footer-available').show();
625            $(apllyVoucherPopupId).find("#voucher-past-rewards").removeClass("in show");
626        }
627        else if (hrefTab == "#voucher-past-rewards") {
628            $(apllyVoucherPopupId).find('.popup-footer-available').hide();
629            $(apllyVoucherPopupId).find('.popup-footer-past-rewards').show();
630
631            $(apllyVoucherPopupId).find("#voucher-available").removeClass("in show");
632        }
633
634        //$('.aplly-voucher-section').find('.aplly-voucher__title').removeClass('sticky-top').removeAttr('style');
635
636        resizeBodyPopup(apllyVoucherPopupId);
637        setTimeout(() => {
638            $(apllyVoucherBody).scroll();
639        }, 500);
640        //stickyTitleVoucher(apllyVoucherBody);
641    });
642
643    $(apllyVoucherPopupId).on('click', '.btn-view-tc', (e) => {
644        let voucherId = $(e.currentTarget).attr('data-id');
645        let isIssuedAttr = $(e.currentTarget).attr('data-issued');
646        let isIssued = isIssuedAttr === 'true';
647        let isDisabled = $(e.currentTarget).parents('.pcv-section').hasClass('item-disabled');
648        openVoucherTermsIframe(e.currentTarget, voucherId, isIssued, apllyVoucherPopupId, 'Detail Voucher', isDisabled, voucherId, 0);
649    });
650
651    /*end Voucher*/
652    /*---*/
653    /*Promo-Code*/
654
655    $(apllyPromoCodeBody).scroll(function () {
656        stickyTitlePromoCode(apllyPromoCodeBody);
657    });
658
659    $(apllyPromoCodeBody).on('click', '.aplly-pc__title.sticky-top', function () {
660        let id = $(this).parents('.aplly-pc-section').attr('id');
661        let top = 50;
662
663        if (id == 'eligible-promo-code') {
664            top *= 1;
665        }
666        else if (id == 'non-eligible-promo-code') {
667            top *= 2;
668        }
669
670        scrollToElement('#' + id, apllyPromoCodeBody, top);
671    });
672
673    $(apllyPromoCodePopupId).on('click', '.btn-view-tc', (e) => {
674        let promoCodeId = $(e.currentTarget).attr('data-id');
675        getPromoCode(e.currentTarget, promoCodeId);
676    });
677
678    /*Promo-Code*/
679})
680
681const resizeBodyPopup = (id) => {
682    $(`${id} .popup-body`).removeAttr("style");
683
684    setTimeout(() => {
685        let newBodyHeight = $(`${id} .popup-body`).outerHeight();
686        //const $stickyTop = $(id).find('.aplly-voucher__title.sticky-top');
687
688        //newBodyHeight -= $stickyTop.height() * $stickyTop.length;
689
690        //console.log(newBodyHeight);
691
692        $(`${id} .popup-body`).css('height', newBodyHeight);
693    }, 500);
694};
695
696const getVoucherSection = (e) => {
697    $(apllyVoucherPopupId).find('.aplly-voucher-nav-tabs a[href="#voucher-available"]').trigger('click');
698
699    $.ajax({
700        type: "GET",
701        cache: false,
702        timeout: 150000,
703        url: discountURl.getVoucherSection
704    }).done(function (response) {
705        $(apllyVoucherBody).html(response);
706
707        if ($(apllyVoucherPopupId).find('.required-login-vouchers').length > 0) {
708            $(apllyVoucherPopupId).find('.aplly-voucher-nav-tabs').hide();
709            $(apllyVoucherPopupId).find('.member-point__btn-sign-up').show();
710        }
711        else {
712            if ($('#aplly-voucher-body').find('.pcv-section').length == 0) {
713                removeSessionStorage("aplly-voucher-text");
714                $(apllyVoucherPopupId).find('.aplly-voucher-nav-tabs').hide();
715            }
716            else {
717                $(apllyVoucherPopupId).find('.aplly-voucher-nav-tabs').show();
718            }
719
720            $(apllyVoucherPopupId).find('.member-point__btn-sign-up').hide();
721        }
722
723        hidePopup(redeemRewardsId);
724
725        checkEligibleStackableVouchers();
726        checkItemChooseEnalbleVoucherApplyButton(apllyVoucherPopupId);
727    }).fail(function (jqXHR, textStatus) {
728        console.log(jqXHR, textStatus);
729
730    }).always(function () {
731    });
732}
733
734const getVoucherSectionByText = (e, voucherText) => {
735    waitingForAction(e, true);
736    $(apllyVoucherPopupId).find('.aplly-voucher-nav-tabs a[href="#voucher-available"]').trigger('click');
737
738    let model = {
739        Vouchers: listAppliedVouchers,
740        PhoneNumber: voucherText,
741    };
742
743    $.ajax({
744        type: "POST",
745        cache: false,
746        timeout: 150000,
747        data: JSON.stringify(model),
748        contentType: "application/json; charset=utf-8",
749        url: discountURl.getVoucherSectionByText
750    }).done(function (response) {
751        $(apllyVoucherBody).html(response);
752
753        if ($(apllyVoucherPopupId).find('.required-login-vouchers').length > 0) {
754            $(apllyVoucherPopupId).find('.aplly-voucher-nav-tabs').hide();
755            $(apllyVoucherPopupId).find('.member-point__btn-sign-up').show();
756        }
757        else {
758            if ($('#aplly-voucher-body').find('.pcv-section').length == 0) {
759                removeSessionStorage("aplly-voucher-text");
760                $(apllyVoucherPopupId).find('.aplly-voucher-nav-tabs').hide();
761            }
762            else {
763                $(apllyVoucherPopupId).find('.aplly-voucher-nav-tabs').show();
764            }
765
766            $(apllyVoucherPopupId).find('.member-point__btn-sign-up').hide();
767        }
768
769        resizeBodyPopup(apllyVoucherPopupId);
770        $(apllyVoucherBody).scrollTop(0);
771
772        checkEligibleStackableVouchers();
773        checkItemChooseEnalbleVoucherApplyButton(apllyVoucherPopupId);
774    }).fail(function (jqXHR, textStatus) {
775        console.log(jqXHR, textStatus);
776    }).always(function () {
777        waitingForAction(e, false);
778    });
779}
780
781const clearSelectionVouchers = (voucherText) => {
782    $(apllyVoucherPopupId).find('.aplly-voucher-nav-tabs a[href="#voucher-available"]').trigger('click');
783
784    let model = {
785        Vouchers: [],
786        PhoneNumber: voucherText,
787    };
788
789    $.ajax({
790        type: "POST",
791        cache: false,
792        data: JSON.stringify(model),
793        contentType: "application/json; charset=utf-8",
794        url: discountURl.clearSelectionVouchers
795    }).done(function (response) {
796        $(apllyVoucherBody).html(response);
797
798        if ($(apllyVoucherPopupId).find('.required-login-vouchers').length > 0) {
799            $(apllyVoucherPopupId).find('.aplly-voucher-nav-tabs').hide();
800            $(apllyVoucherPopupId).find('.member-point__btn-sign-up').show();
801        }
802        else {
803            if ($('#aplly-voucher-body').find('.pcv-section').length == 0) {
804                removeSessionStorage("aplly-voucher-text");
805                $(apllyVoucherPopupId).find('.aplly-voucher-nav-tabs').hide();
806            }
807            else {
808                $(apllyVoucherPopupId).find('.aplly-voucher-nav-tabs').show();
809            }
810
811            $(apllyVoucherPopupId).find('.member-point__btn-sign-up').hide();
812        }
813
814        resizeBodyPopup(apllyVoucherPopupId);
815        $(apllyVoucherBody).scrollTop(0);
816
817        checkEligibleStackableVouchers();
818        checkItemChooseEnalbleVoucherApplyButton(apllyVoucherPopupId);
819    }).fail(function (jqXHR, textStatus) {
820        console.log(jqXHR, textStatus);
821    }).always(function () {
822    });
823}
824const getPromoCodeSection = (e, promoCodeValue = '', promoCodeId = '', isCheck = false, isClear = false) => {
825    waitingForAction(e, true);
826
827    let isChange = false;
828    if (promoCodeId != null && promoCodeId.length > 0) {
829        isChange = true;
830    }
831
832    $.ajax({
833        type: "GET",
834        cache: false,
835        data: {
836            promoCodeValue: promoCodeValue,
837            isChange: isChange,
838            isClear: isClear,
839        },
840        url: discountURl.getPromoCodeSection,
841    }).done(function (response) {
842
843        promoCodeIdApplied = 0;
844        $(apllyPromoCodeBody).html(response);
845
846        if (isCheck) {
847            resizeBodyPopup(apllyPromoCodePopupId);
848            $(apllyPromoCodeBody).scrollTop(0);
849        }
850        else {
851            hidePopup(redeemRewardsId);
852
853            showPopup(apllyPromoCodePopupId, () => {
854                resizeBodyPopup(apllyPromoCodePopupId);
855                $(apllyPromoCodeBody).scrollTop(0);
856            });
857        }
858
859        checkItemChooseEnalbleApplyButton(apllyPromoCodePopupId);
860    }).fail(function (jqXHR, textStatus) {
861        console.log(jqXHR, textStatus);
862    }).always(function () {
863        waitingForAction(e, false);
864    });
865}
866
867const getVoucher = (e, voucherId, voucherCode) => {
868    waitingForAction(e, true);
869    $.ajax({
870        type: "GET",
871        cache: false,
872        data: {
873            voucherId: voucherId,
874            voucherCode: voucherCode
875        },
876        url: discountURl.getVoucher
877    }).done(function (response) {
878        $(detailDiscountBody).html(response);
879
880        hidePopup(null, () => {
881            $(apllyVoucherPopupId).find('.aplly-voucher__title').removeClass('sticky-top').removeAttr('style');
882        });
883
884        showPopup(detailDiscountPopupId, () => {
885            $(detailDiscountPopupId).attr('data-pre-id', apllyVoucherPopupId);
886        });
887        //showPopup(detailDiscountPopupId);
888
889        let isDisabled = $(e).parents('.pcv-section').hasClass('item-disabled');
890        UpdateDetailDiscountPopup('Detail Voucher', isDisabled, voucherId, 0, voucherCode);
891    }).fail(function (jqXHR, textStatus) {
892        console.log(jqXHR, textStatus);
893    }).always(function () {
894        waitingForAction(e, false);
895    });
896}
897
898const applyVoucher = (e, phoneNumber) => {
899    waitingForAction(e, true);
900
901    //var model = {
902    //    VoucherIds: voucherIds,
903    //    PhoneNumber: phoneNumber
904    //};
905
906    //if (listAppliedVouchers != null && listAppliedVouchers.length > 0) {
907    //    for (let i = 0; i < listAppliedVouchers.length; i++) {
908    //        let appliedVoucher = listAppliedVouchers[i];
909
910    //        if (appliedVoucher.IsRemove == true) {
911    //            vouchers.push(appliedVoucher);
912    //        }
913    //    }
914    //}
915
916    let model = {
917        Vouchers: listAppliedVouchers,
918        PhoneNumber: phoneNumber
919    };
920
921    $.ajax({
922        type: "POST",
923        //cache: false,
924        data: JSON.stringify(model),
925        contentType: "application/json; charset=utf-8",
926        //dataType: "json",
927        url: discountURl.applyVoucher
928    }).done(function (response) {
929        $(apllyVoucherPopupId).find('.popup-footer-available').show();
930        if (response.status == true) {
931            //voucherIdApplied = 0;// voucherId;
932
933            if (response.hasCustomerSender == false && response.isPhoneNumber == true) {
934                triggerProvidePhoneNumber(response.contactNumber, response.contactIdd);
935
936                if (response.isPhoneNumberChanged) {
937                    $(apllyPromoCodePopupId).find('#promo-code-text').val('');
938                }
939            }
940
941            if (response.isShareCode == true) {
942                removeSessionStorage("aplly-voucher-text");
943                $(apllyVoucherPopupId).find('#aplly-voucher-text').val('');
944            }
945        }
946        else {
947            //voucherIdApplied = 0;
948        };
949
950        LoadContainMyCart();
951        hideDetailDiscountPopup(apllyVoucherPopupId);
952
953        $(apllyVoucherPopupId).find('.count-voucher-selected').css('display', 'none');
954    }).fail(function (jqXHR, textStatus) {
955        console.log(jqXHR, textStatus);
956    }).always(function () {
957        waitingForAction(e, false);
958    });
959}
960
961const removeVoucher = (e, voucherId) => {
962    waitingForAction(e, true);
963
964    var accessTokenCookie = getCookieByKey('AccessToken');
965
966    if (accessTokenCookie == null || accessTokenCookie.length == 0) {
967        $('#select-payment-options-popup').find('.provide-phone-number .dropdown-customize').removeAttr("disabled");
968        $('#select-payment-options-popup').find('.provide-phone-number__phone-section #phoneNumberInput').removeAttr("disabled");
969
970        $('#select-payment-options-popup').find('.provide-phone-number__phone-section #phoneNumberInput').val('');
971    }
972
973    $.ajax({
974        type: "GET",
975        cache: false,
976        url: discountURl.removeVoucher
977    }).done(function (response) {
978        ////Re-build the new content of cart
979        //$(containMyCartId).html(response);
980        ////Re-set up the height of cart
981        //ResetCartHeight();
982
983        LoadContainMyCart();
984        $(apllyVoucherPopupId).find('.count-voucher-selected').css('display', 'none');
985
986        if (response.status == true) {
987            //voucherIdApplied = 0;
988
989            if (response.hasCustomerSender == false) {
990                triggerProvidePhoneNumber(response.contactNumber, response.contactIdd);
991            }
992        }
993
994    }).fail(function (jqXHR, textStatus) {
995        console.log(jqXHR, textStatus);
996    }).always(function () {
997        waitingForAction(e, false);
998        $(confirmRemoveDiscountRewardsId).modal('hide');
999    });
1000}
1001
1002// --- Promo Code ---
1003
1004const removePromoCode = (e, promoCodeId) => {
1005    waitingForAction(e, true);
1006    $.ajax({
1007        type: "GET",
1008        cache: false,
1009        url: discountURl.removePromoCode
1010    }).done(function (response) {
1011        ////Re-build the new content of cart
1012        //$(containMyCartId).html(response);
1013        ////Re-set up the height of cart
1014        //ResetCartHeight();
1015
1016        LoadContainMyCart();
1017
1018        if (response.status == true) {
1019            promoCodeIdApplied = 0;
1020
1021            if (response.hasCustomerSender == false) {
1022                setSessionStorage("aplly-voucher-text", response.contactNumber);
1023                triggerProvidePhoneNumber(response.contactNumber, response.contactIdd);
1024            }
1025        }
1026
1027    }).fail(function (jqXHR, textStatus) {
1028        console.log(jqXHR, textStatus);
1029    }).always(function () {
1030        waitingForAction(e, false);
1031        $(confirmRemoveDiscountRewardsId).modal('hide');
1032    });;
1033}
1034
1035const getPromoCode = (e, promoCodeId) => {
1036    waitingForAction(e, true);
1037    $.ajax({
1038        type: "GET",
1039        cache: false,
1040        data: {
1041            promoCodeId: promoCodeId
1042        },
1043        url: discountURl.getPromoCode
1044    }).done(function (response) {
1045        $(detailDiscountBody).html(response);
1046
1047        hidePopup(null, () => {
1048            $(apllyPromoCodePopupId).find('.aplly-pc__title').removeClass('sticky-top').removeAttr('style');
1049        });
1050
1051        showPopup(detailDiscountPopupId, () => {
1052            $(detailDiscountPopupId).attr('data-pre-id', apllyPromoCodePopupId);
1053        });
1054        //showPopup(detailDiscountPopupId);
1055
1056        let isDisabled = $(e).parents('.pcv-section').hasClass('item-disabled');
1057        UpdateDetailDiscountPopup('Detail Promo code', isDisabled, promoCodeId, 1);
1058    }).fail(function (jqXHR, textStatus) {
1059        console.log(jqXHR, textStatus);
1060    }).always(function () {
1061        waitingForAction(e, false);
1062    });
1063}
1064
1065const UpdateDetailDiscountPopup = (headerTitle, isDisabled, itemId, discountType, shareCode) => {
1066    $(detailDiscountPopupId).find('.popup-title').text(headerTitle);
1067
1068    if (isDisabled) {
1069        $(detailDiscountPopupId).find('#btn-pcv-apply').hide();
1070        $(detailDiscountPopupId).find('#btn-pcv-back').show();
1071    }
1072    else {
1073
1074        $(detailDiscountPopupId).find('#btn-pcv-apply').attr('data-id', itemId);
1075        $(detailDiscountPopupId).find('#btn-pcv-apply').attr('data-code', shareCode);
1076        $(detailDiscountPopupId).find('#btn-pcv-apply').attr('data-type', discountType);
1077
1078        if (discountType == 0) {
1079            $(detailDiscountPopupId).find('#btn-pcv-apply').text('Use Now');
1080        }
1081        else if (discountType == 1) {
1082            $(detailDiscountPopupId).find('#btn-pcv-apply').text('Apply');
1083        }
1084
1085        $(detailDiscountPopupId).find('#btn-pcv-apply').show();
1086        $(detailDiscountPopupId).find('#btn-pcv-back').hide();
1087    }
1088}
1089
1090const applyPromoCode = (e, promoCodeId, promoCodeValue) => {
1091    waitingForAction(e, true);
1092    $.ajax({
1093        type: "GET",
1094        cache: false,
1095        data: {
1096            promoCodeId: promoCodeId,
1097            promoCodeValue: promoCodeValue
1098        },
1099        url: discountURl.applyPromoCode
1100    }).done(function (response) {
1101        $(apllyPromoCodePopupId).find('.popup-footer-available').show();
1102        if (response.status == true) {
1103            //$(apllyPromoCodePopupId).find('.apply-pc__btn-apply').hide();
1104
1105            //$(apllyPromoCodePopupId).find('.promo-code-selected').show();
1106            //$(apllyPromoCodePopupId).find('#aplly-promo-code-save').html(response.data);
1107
1108            //$(apllyPromoCodePopupId).find('.popup-footer-past-rewards').show();
1109
1110            promoCodeIdApplied = promoCodeId;
1111
1112            if (response.hasCustomerSender == false && response.isPhoneNumber) {
1113                setSessionStorage("aplly-voucher-text", response.contactNumber);
1114                triggerProvidePhoneNumber(response.contactNumber, response.contactIdd);
1115
1116                if (response.isPhoneNumberChanged) {
1117                    $(apllyVoucherPopupId).find('#aplly-voucher-text').val('');
1118                    removeSessionStorage("aplly-voucher-text");
1119                }
1120            }
1121        }
1122        else {
1123            //$(apllyPromoCodePopupId).find('.apply-pc__btn-apply').show();
1124
1125            //$(apllyPromoCodePopupId).find('.promo-code-selected').hide();
1126            //$(apllyPromoCodePopupId).find('#aplly-promo-code-save').html('0');
1127
1128            //$(apllyPromoCodePopupId).find('.popup-footer-past-rewards').hide();
1129
1130            promoCodeIdApplied = 0;
1131        };
1132
1133        LoadContainMyCart();
1134        hideDetailDiscountPopup(apllyPromoCodePopupId);
1135    }).fail(function (jqXHR, textStatus) {
1136        console.log(jqXHR, textStatus);
1137    }).always(function () {
1138        waitingForAction(e, false);
1139    });
1140}
1141
1142const findPromoCodeByText = (e, promoCodeValue) => {
1143    waitingForAction(e, true);
1144
1145    $.ajax({
1146        type: "POST",
1147        cache: false,
1148        url: discountURl.findPromoCodeByText,
1149        data: { promoCodeValue: promoCodeValue },
1150    }).done(function (response) {
1151        $(apllyPromoCodeBody).html(response);
1152
1153        resizeBodyPopup(apllyPromoCodePopupId);
1154        $(apllyPromoCodeBody).scrollTop(0);
1155
1156        checkItemChooseEnalbleApplyButton(apllyPromoCodePopupId);
1157    }).fail(function (jqXHR, textStatus) {
1158        console.log(jqXHR, textStatus);
1159    }).always(function () {
1160        waitingForAction(e, false);
1161    });
1162}
1163
1164// --- end Promo Code ---
1165// --- Member Points ---
1166const getMemberPointSection = (e) => {
1167    waitingForAction(e, true);
1168    $.ajax({
1169        type: "GET",
1170        cache: false,
1171        url: discountURl.getMemberPoint
1172    }).done(function (response) {
1173        hidePopup(redeemRewardsId);
1174
1175        $(memberPointBody).html(response);
1176
1177        showPopup(memberPointPopupId, () => {
1178            if ($(memberPointPopupId).find(memberPointNumberId) != null) {
1179                onChangePointsRangeSlider($(memberPointPopupId).find(memberPointNumberId).val());
1180            }
1181        });
1182
1183    }).fail(function (jqXHR, textStatus) {
1184        console.log(jqXHR, textStatus);
1185    }).always(function () {
1186        waitingForAction(e, false);
1187    });
1188}
1189
1190const applyMemberPoint = (e, pointNumber) => {
1191    waitingForAction(e, true);
1192    $.ajax({
1193        type: "GET",
1194        cache: false,
1195        data: {
1196            pointNumber: pointNumber
1197        },
1198        url: discountURl.applyMemberPoint
1199    }).done(function (response) {
1200        //Re-build the new content of cart
1201        $(containMyCartId).html(response);
1202
1203        //Re-set up the height of cart
1204        ResetCartHeight();
1205
1206        hidePopup(memberPointPopupId);
1207    }).fail(function (jqXHR, textStatus) {
1208        console.log(jqXHR, textStatus);
1209    }).always(function () {
1210        waitingForAction(e, false);
1211    });
1212}
1213
1214const removePoint = (e) => {
1215    waitingForAction(e, true);
1216    $.ajax({
1217        type: "GET",
1218        cache: false,
1219        url: discountURl.removePoint
1220    }).done(function (response) {
1221        //Re-build the new content of cart
1222        $(containMyCartId).html(response);
1223        //Re-set up the height of cart
1224        ResetCartHeight();
1225
1226    }).fail(function (jqXHR, textStatus) {
1227        console.log(jqXHR, textStatus);
1228    }).always(function () {
1229        waitingForAction(e, false);
1230        $(confirmRemoveDiscountRewardsId).modal('hide');
1231    });
1232}
1233
1234const addItemToCartVoucher = (e, skus, voucherId, phoneNumber) => {
1235    waitingForAction(e, true);
1236    $.ajax({
1237        type: "GET",
1238        cache: false,
1239        url: discountURl.addItemToCartVoucher,
1240        data: {
1241            skus: skus,
1242            voucherId: voucherId,
1243            phoneNumber: phoneNumber,
1244        },
1245    }).done(function (response) {
1246        if (response.status == true) {
1247            isShowAnimate = true;
1248            ShowAnimate(response.docId, response.productId);
1249
1250            if (response.variantId) {
1251                $(`.box-add-product-${response.productId}`).find(".btn-quantity-product").attr("data-variantid", response.variantId);
1252            }
1253
1254            LoadContainMyCart(true);
1255            $(apllyVoucherPopupId).find('.count-voucher-selected').css('display', 'none');
1256
1257            //$(apllyVoucherPopupId).find(`#non-eligible-voucher-available .pcv-section.voucher-stackable-${voucherId}`).removeClass('item-disabled').addClass('item-selected');
1258            //$(apllyVoucherPopupId).find(`#non-eligible-voucher-available .pcv-item_action.voucher-action-${voucherId}`).remove();
1259
1260            //checkEligibleStackableVouchers();
1261            //checkItemChooseEnalbleVoucherApplyButton(apllyVoucherPopupId);
1262        }
1263    }).fail(function (jqXHR, textStatus) {
1264        console.log(jqXHR, textStatus);
1265    }).always(function () {
1266        waitingForAction(e, false);
1267        hidePopup(apllyVoucherPopupId);
1268    });
1269}
1270
1271const addItemToCartPromoCode = (e, skus, promoCodeId, promoCodeValue) => {
1272    waitingForAction(e, true);
1273    $.ajax({
1274        type: "GET",
1275        cache: false,
1276        url: discountURl.addItemToCartPromoCode,
1277        data: {
1278            skus: skus,
1279            promoCodeId: promoCodeId,
1280            promoCodeValue: promoCodeValue
1281        },
1282    }).done(function (response) {
1283        //Re-build the new content of cart
1284        $(containMyCartId).html(response);
1285        //Re-set up the height of cart
1286        ResetCartHeight();
1287
1288    }).fail(function (jqXHR, textStatus) {
1289        console.log(jqXHR, textStatus);
1290    }).always(function () {
1291        waitingForAction(e, false);
1292        hidePopup(apllyPromoCodePopupId);
1293
1294    });
1295}
1296
1297const checkItemChooseEnalbleVoucherApplyButton = (popupId) => {
1298    let itemSelected = $(popupId).find('#eligible-voucher-available .pcv-section.item-selected');
1299
1300    if (itemSelected != null && itemSelected.length > 0) {
1301        $(popupId).find('.btn-apply-discount').removeAttr('disabled');
1302    }
1303    else {
1304        $(popupId).find('.btn-apply-discount').attr('disabled', 'disabled');
1305    }
1306}
1307
1308const checkItemChooseEnalbleApplyButton = (popupId) => {
1309    let itemSelected = $(popupId).find('.pcv-section.item-selected');
1310
1311    if (itemSelected != null && itemSelected.length > 0) {
1312        $(popupId).find('.btn-apply-discount').removeAttr('disabled');
1313    }
1314    else {
1315        $(popupId).find('.btn-apply-discount').attr('disabled', 'disabled');
1316    }
1317}
1318
1319const checkEligibleStackableVouchers = () => {
1320    $(apllyVoucherPopupId).find('.eligible-voucher-info .pcv-section').removeClass('item-disabled');
1321
1322    if (eligibleStackableVouchers != null && eligibleStackableVouchers.length > 0) {
1323        let currentVoucherApplyIds = $(apllyVoucherPopupId).find('#eligible-voucher-available .pcv-section.item-selected').map((i, e) => $(e).attr('data-id'));
1324
1325        if (currentVoucherApplyIds != null && currentVoucherApplyIds.length > 0) {
1326            $(apllyVoucherPopupId).find('.count-voucher-selected').css('display', 'flex');
1327            $(apllyVoucherPopupId).find('#count-voucher-selected').text(`${currentVoucherApplyIds.length} Voucher(s)`);
1328        }
1329        else {
1330            $(apllyVoucherPopupId).find('.count-voucher-selected').css('display', 'none');
1331        }
1332
1333        let currentVoucherIds = $(apllyVoucherPopupId).find('.eligible-voucher-info .pcv-section.item-selected').map((i, e) => $(e).attr('data-id'));
1334        if (currentVoucherIds != null && currentVoucherIds.length > 0) {
1335            for (var x = 0; x < currentVoucherIds.length; x++) {
1336                let currentStackableVoucher = eligibleStackableVouchers.find(v => v.Id == currentVoucherIds[x]);
1337
1338                if (currentStackableVoucher != null) {
1339                    for (var i = 0; i < eligibleStackableVouchers.length; i++) {
1340                        let eligibleStackableVoucher = eligibleStackableVouchers[i];
1341
1342                        if (eligibleStackableVoucher.Id != currentStackableVoucher.Id) {
1343                            let disableVoucher = false;
1344
1345                            if (currentStackableVoucher.IsSaleVoucher == true && eligibleStackableVoucher.IsSaleVoucher == true) {
1346                                if (currentStackableVoucher.AllowStackingEVoucher == false || eligibleStackableVoucher.AllowStackingEVoucher == false) {
1347                                    disableVoucher = true;
1348                                }
1349                            }
1350                            else if (currentStackableVoucher.IsSaleVoucher == false && eligibleStackableVoucher.IsSaleVoucher == false) {
1351                                if (currentStackableVoucher.AllowStackingVoucher == false || eligibleStackableVoucher.AllowStackingVoucher == false) {
1352                                    disableVoucher = true;
1353                                }
1354                            }
1355                            else if (currentStackableVoucher.IsSaleVoucher == true) {
1356                                if (currentStackableVoucher.AllowStackingVoucher == false || eligibleStackableVoucher.AllowStackingEVoucher == false) {
1357                                    disableVoucher = true;
1358                                }
1359                            }
1360                            else {
1361                                if (currentStackableVoucher.AllowStackingEVoucher == false || eligibleStackableVoucher.AllowStackingVoucher == false) {
1362                                    disableVoucher = true;
1363                                }
1364                            }
1365
1366                            if (disableVoucher == true) {
1367                                $(apllyVoucherPopupId).find(`.eligible-voucher-info .pcv-section.voucher-stackable-${eligibleStackableVoucher.Id}`).addClass('item-disabled');
1368                                $(apllyVoucherPopupId).find(`.eligible-voucher-info .pcv-item_action.voucher-not-combined-${eligibleStackableVoucher.Id}`).css('display', 'flex');
1369                            }
1370                            else {
1371                                $(apllyVoucherPopupId).find(`.eligible-voucher-info .pcv-item_action.voucher-not-combined-${eligibleStackableVoucher.Id}`).css('display', 'none');
1372                            }
1373                        }
1374                    }
1375                }
1376
1377            }
1378        }
1379        else {
1380            $(apllyVoucherPopupId).find(`.eligible-voucher-info .pcv-item_action.voucher-msg-combined`).css('display', 'none');
1381        }
1382    }
1383}
1384
1385// --- end Member Points ---
1386const stickyTitleVoucher = (apllyVoucherBodyElement) => {
1387    let countElement = 0;
1388    let desktopView = 0;
1389    if ($(window).outerWidth() > 991) {
1390        desktopView = 50;
1391    }
1392
1393    $(apllyVoucherBodyElement).find('.in .aplly-voucher-section').each((i, e) => {
1394        let element = $(e).position();
1395
1396        if (element.top != 0 && $(e).outerHeight() > 0) {
1397            //let top = 50 * countElement + $('.aplly-voucher-nav-tabs').outerHeight() + $('.aplly-voucher-enter').outerHeight() - 1;
1398            let top = 58 + 40 * countElement + $('.aplly-voucher-navs').outerHeight() + desktopView;// - 1;
1399
1400            if (element.top + desktopView + 1 <= top) {
1401                let widthTitle = $(e).outerWidth() - 1;
1402                $(e).find('.aplly-voucher__title').addClass('sticky-top').css({
1403                    "top": top,
1404                    "width": widthTitle
1405                });
1406            }
1407            else {
1408                $(e).find('.aplly-voucher__title').removeClass('sticky-top').removeAttr('style');
1409            }
1410
1411            countElement++;
1412        }
1413    })
1414}
1415
1416const scrollToElement = (id, bodyElement, top) => {
1417    let scrollTime = 250;
1418    top = $(bodyElement).scrollTop() + $(id).position().top - top - $('.aplly-voucher-navs').outerHeight();
1419
1420    $(bodyElement).animate({
1421        scrollTop: top
1422    }, scrollTime);
1423}
1424
1425const stickyTitlePromoCode = (bodyElement) => {
1426    let desktopView = 0;
1427    if ($(window).outerWidth() > 991) {
1428        desktopView = 50;
1429    }
1430
1431    $(bodyElement).find('.aplly-pc-section').each((i, e) => {
1432        let element = $(e).position();
1433        if (element.top != 0) {
1434            let top = 50 + 40 * i + desktopView;
1435
1436            if (element.top + desktopView + 1 <= top) {
1437                //$(e).find('.aplly-pc__title').addClass('sticky-top').css('top', top);
1438                let widthTitle = $(e).outerWidth() - 1;
1439                $(e).find('.aplly-pc__title').addClass('sticky-top').css({
1440                    "top": top,
1441                    "width": widthTitle
1442                });
1443            }
1444            else {
1445                $(e).find('.aplly-pc__title').removeClass('sticky-top').removeAttr('style');
1446            }
1447        }
1448    })
1449}
1450
1451const onCollapseReward = () => {
1452    let collapseControl = $(containMyCartId).find('.discount-title__action');
1453    let collapseClass = $(containMyCartId).find('.discount-content');
1454    if (collapseClass.hasClass("collapsed")) {
1455        collapseClass.removeClass("collapsed");
1456        collapseControl.css("transform", "rotate(180deg)")
1457    }
1458    else {
1459        collapseClass.addClass("collapsed");
1460        collapseControl.css("transform", "rotate(0deg)")
1461    }
1462}
1463var textAction = '';
1464const waitingIcon = '<i class="fa fa-spinner fa-spin" style="font-size:14px"></i>';
1465
1466const waitingForAction = (e, status) => {
1467    if (status == true) {
1468        textAction = $(e).html();
1469        $(e).html(waitingIcon).attr('disabled', 'disabled');
1470    }
1471    else {
1472        $(e).html(textAction).removeAttr('disabled');
1473    }
1474}
1475
1476const validatePhoneNumberDiscount = (p) => {
1477    var phoneRe = /^((3|6|8|9)\d{7})$/;
1478    var digits = p.replace(/\D/g, "");
1479    return phoneRe.test(digits);
1480}
1481
1482const hideDetailDiscountPopup = (apllyPopupId) => {
1483    setTimeout(() => {
1484        if ($(detailDiscountPopupId).hasClass('popup-show')) {
1485            $(detailDiscountPopupId).find('.popup-close').trigger('click');
1486        }
1487        else {
1488            $(apllyPopupId).find('.popup-close').trigger('click');
1489        }
1490    }, 250);
1491}
1492
1493function changePoint(smallestRedeemableValue) {
1494    let currentValue = +($(memberPointPopupId).find(memberPointNumberId).val());
1495    currentValue += smallestRedeemableValue;
1496
1497    onChangePointsRangeSlider(currentValue);
1498}
1499
1500//function updateRedeemValue(currentValue) {
1501//    $(memberPointPopupId).find('#member-points-selected').html(currentValue);
1502
1503
1504//    let redeemValue = +($(memberPointPopupId).find('#member-points-ratio').text()) * +currentValue;
1505//    $(memberPointPopupId).find('#member-points-amount-burned').html(redeemValue.toFixed(2));
1506//}
1507
1508function onChangePointsRangeSlider(currentValue) {
1509
1510    if (currentValue == null || currentValue == '') {
1511        currentValue = 0;
1512    }
1513
1514    currentValue = checkMemberPointNumber(currentValue);
1515
1516    $(memberPointPopupId).find("#choose-points-range").val(currentValue);
1517    $(memberPointPopupId).find(memberPointNumberId).val(currentValue);
1518
1519    const progress = (+currentValue / + $(memberPointPopupId).find('#choose-points-range').attr('max')) * 100;
1520    $(memberPointPopupId).find('#choose-points-range').css('background', `linear-gradient(to right, #f50 ${progress}%, #d9d9d9 ${progress}%)`);
1521
1522    //updateRedeemValue(currentValue);
1523
1524    $(memberPointPopupId).find('#member-points-selected').html(currentValue);
1525    let redeemValue = +($(memberPointPopupId).find('#member-points-ratio').text()) * +currentValue;
1526
1527    var isUpPoint = $('#hdRoundUpPoint').val();
1528    var maxValuePoint = $('#hdMaxValuePoint').val();
1529    if (isUpPoint == 'True' && maxValuePoint < redeemValue) {
1530        redeemValue = parseFloat(maxValuePoint);
1531    }
1532    $(memberPointPopupId).find('#member-points-amount-burned').html(redeemValue.toFixed(2));
1533}
1534
1535function onChangePointNumber(currentValue) {
1536    delayTimer(function () {
1537        onChangePointsRangeSlider(currentValue);
1538    }, 1500);
1539}
1540
1541function checkMemberPointNumber(newValue) {
1542    let currentValue = +newValue;
1543
1544    const smallestKey = +$(memberPointPopupId).find(memberPointNumberId).attr('key');
1545    const minPoint = +$(memberPointPopupId).find(memberPointNumberId).attr('min');
1546    const maxPoint = +$(memberPointPopupId).find(memberPointNumberId).attr('max');
1547
1548    let checkApplyMemberPointsButton = true;
1549
1550    if (currentValue <= +minPoint) {
1551        currentValue = +minPoint;
1552        checkApplyMemberPointsButton = false;
1553    }
1554
1555    if (currentValue > +maxPoint) {
1556        currentValue = +maxPoint;
1557    }
1558
1559    if (smallestKey > 1 && currentValue > 0 && currentValue < +maxPoint) {
1560        let maxRedeemableValue = currentValue / smallestKey;
1561        let maxRedeemableValueFloor = Math.floor(maxRedeemableValue);
1562
1563        if (maxRedeemableValueFloor < maxRedeemableValue) {
1564            maxRedeemableValueFloor++;
1565        }
1566
1567        currentValue = Math.floor(maxRedeemableValueFloor * smallestKey);
1568    }
1569
1570    if (checkApplyMemberPointsButton) {
1571        $(memberPointPopupId).find('#btn-member-point-apply').removeAttr('disabled');
1572        $(memberPointPopupId).find('.btn-decrease-point').removeAttr('disabled');
1573    }
1574    else {
1575        $(memberPointPopupId).find('#btn-member-point-apply').attr('disabled', 'disabled');
1576        $(memberPointPopupId).find('.btn-decrease-point').attr('disabled', 'disabled');
1577    }
1578
1579    if (currentValue == +maxPoint) {
1580        $(memberPointPopupId).find('.btn-increase-point').attr('disabled', 'disabled');
1581    }
1582    else {
1583        $(memberPointPopupId).find('.btn-increase-point').removeAttr('disabled');
1584    }
1585
1586    return currentValue;
1587}
1588
1589const setSessionStorage = (key, value) => {
1590    sessionStorage.setItem(key, value);
1591}
1592
1593const getSessionStorage = (key) => {
1594    return sessionStorage.getItem(key);
1595}
1596
1597const removeSessionStorage = (key) => {
1598    sessionStorage.removeItem(key);
1599}
1600
1601function getVoucherInfoOfOutlet(e, voucherId, callback = null) {
1602    waitingForAction(e, true);
1603    $.ajax({
1604        type: "GET",
1605        cache: false,
1606        data: {
1607            voucherId: voucherId
1608        },
1609        url: discountURl.getVoucherInfoOfOutlet
1610    }).done(function (response) {
1611        $(detailDiscountBody).html(response);
1612
1613        if (callback == null) {
1614            showPopup(detailDiscountPopupId);
1615        }
1616        else {
1617
1618            showPopup(detailDiscountPopupId, callback());
1619        }
1620        //hidePopup(null, () => {
1621        //    $('#select-payment-options-popup').find('.aplly-pc__title').removeClass('sticky-top').removeAttr('style');
1622        //});
1623
1624        //showPopup(detailDiscountPopupId, () => {
1625        //    $(detailDiscountPopupId).attr('data-pre-id', '#select-payment-options-popup');
1626        //});
1627
1628        $(detailDiscountPopupId).find('.popup-title').text('Detail Voucher');
1629        $(detailDiscountPopupId).find('#btn-pcv-apply').hide();
1630        $(detailDiscountPopupId).find('#btn-pcv-back').hide();
1631
1632    }).fail(function (jqXHR, textStatus) {
1633        console.log(jqXHR, textStatus);
1634    }).always(function () {
1635        waitingForAction(e, false);
1636    });
1637}
1638function getCookieByKey(name) {
1639    const value = `; ${document.cookie}`;
1640    const parts = value.split(`; ${name}=`);
1641    if (parts.length == 2) return parts.pop().split(';').shift();
1642}
1643
1644function loadSeletonVouchers() {
1645    $(apllyVoucherPopupId).find('.aplly-voucher-nav-tabs').show();
1646    let skeletonVouchers = '<div class="tab-content">' +
1647        '<div id="voucher-available" class="tab-pane fade in show active">' +
1648        '<div class="aplly-voucher-section" id="eligible-voucher-available">' +
1649        '<div class="aplly-voucher__content collapse-box">' +
1650        '<div class="aplly-voucher__header collapse-header">' +
1651        '<div class="aplly-voucher__title">' +
1652        '<div>Eligible Voucher</div>' +
1653        '</div>' +
1654        '</div>' +
1655        '<div class="aplly-voucher__collapse collapse-body">' +
1656        '<div class="aplly-voucher__info eligible-voucher-info collapse-card">';
1657    for (var i = 0; i < 5; i++) {
1658        skeletonVouchers +=
1659            '<div class="voucher-item-skeleton voucher-type">';
1660
1661        if (i % 2 == 0) {
1662            skeletonVouchers +=
1663                '<div class="pcv-item pcv-icon skeleton-image">' +
1664                '<svg width="80" height="81" viewBox="0 0 80 81" fill="none">' +
1665                '<path fill-rule="evenodd" clip-rule="evenodd" d="M42.9215 43.108C38.0424 39.2817 34.8957 33.2537 34.8957 26.4729C34.8957 23.6475 35.442 20.9528 36.4324 18.4936C36.1254 18.1015 35.7535 17.7915 35.3353 17.6015C34.0041 16.9969 32.637 17.7051 31.8426 19.4109C31.5397 20.0616 31.4968 20.3013 31.4957 21.3495L31.4944 22.5456L30.8415 22.6272C29.8021 22.7571 27.473 23.3811 26.2161 23.8666C19.0763 26.624 13.8476 32.7024 12.211 40.1479C12.0401 40.9251 11.8626 41.9093 11.8166 42.3346C11.7719 42.7476 12.0955 43.108 12.5109 43.108H34.4046H42.9215ZM45.9694 45.0879H34.5139C15.7502 45.0879 8.46782 45.126 8.24991 45.2252C7.85393 45.4057 7.67363 45.8274 7.67363 46.5728C7.67363 47.642 7.93547 47.9279 9.09062 48.1205C9.75377 48.2311 10.4701 48.9475 10.5808 49.6106C10.7099 50.3855 10.8845 50.7374 11.2146 50.8878C11.4251 50.9837 13.0633 51.0302 16.4344 51.036C19.9115 51.042 21.2702 51.0818 21.0831 51.1724C20.5786 51.4167 20.5432 51.7271 20.539 55.9523C20.5353 59.7134 20.5172 60.0471 20.2828 60.6797C20.1441 61.054 20.0206 61.4485 20.0083 61.5563C19.9949 61.6755 21.9769 63.4597 25.0597 66.1038C26.5246 67.3602 27.867 68.4966 28.8118 69.2929C29.5964 69.9542 30.7523 69.9074 31.482 69.1859C33.0756 67.6105 35.9849 64.7279 39.2605 61.4511C47.5193 53.1894 48.2618 52.4132 48.2618 52.0408C48.2618 51.775 48.1571 51.5304 47.958 51.3314L47.6543 51.0276H52.5803H57.5065L57.8339 50.7242C58.0518 50.5222 58.1613 50.2928 58.1613 50.0387C58.1613 49.5131 58.573 48.7526 59.0361 48.4229C59.2479 48.2721 59.6666 48.1209 59.9662 48.0872C60.2992 48.0496 60.6314 47.9141 60.8211 47.7382C61.0959 47.4836 61.1312 47.351 61.1312 46.5728C61.1312 46.5672 61.1312 46.5617 61.1312 46.5562C59.2935 47.1119 57.348 47.4102 55.3345 47.4102C51.9592 47.4102 48.775 46.5721 45.9694 45.0879ZM27.2475 52.7421C26.5716 51.9905 26.0055 51.6166 25.0392 51.2843L24.3173 51.0359L34.0312 51.0462C40.1127 51.0527 43.499 51.0975 43.087 51.1661C42.3519 51.2883 41.3971 51.6632 40.6515 52.1223C40.3793 52.2899 37.8838 54.1783 35.1063 56.3188C32.3286 58.4592 30.0303 60.1848 29.9989 60.1534C29.9674 60.122 29.581 58.8772 29.1399 57.3872C28.1314 53.979 27.9422 53.5148 27.2475 52.7421ZM30.1636 73.1612C29.9333 72.8908 17.9982 62.6296 16.4003 61.3281C15.8194 60.8548 15.5179 60.8284 15.0003 
166561.2056C14.5058 61.5658 2.09572 74.9594 1.87818 75.3675C1.67623 75.7465 1.77164 76.1818 2.13 76.5155C2.39692 76.7642 2.51237 76.7665 15.1404 76.7665H26.0703C27.2299 76.7665 28.342 76.3058 29.162 75.4858C30.5703 74.0775 30.6959 73.7861 30.1636 73.1612Z" fill="#636a79"></path>' +
1666                '<circle cx="57.993" cy="23.9793" r="19.9402" fill="#636a79"></circle>' +
1667                '</svg>' +
1668                '</div>';
1669        }
1670        else {
1671            skeletonVouchers +=
1672                '<div class="pcv-item pcv-icon skeleton-image">' +
1673                '<svg width="80" height="80" viewBox="0 0 80 80" fill="none">' +
1674                '<path fill-rule="evenodd" clip-rule="evenodd" d="M36.5541 19.4489C35.3799 19.4483 34.1674 19.4479 32.9279 19.4479H14.1656L13.4793 19.7387C12.2929 20.2156 11.4437 21.2509 11.2227 22.4722C11.1413 22.8677 11.0715 27.2181 11.0366 33.6389C11.0071 38.545 10.9525 45.2367 10.9153 49.799L10.9152 49.8007L10.9152 49.8025L10.897 52.0406L10.8156 59.9271H23.8085L25.6181 59.927C36.3574 59.9258 37.3278 59.9256 37.6808 60.3924C37.7159 60.4388 37.7448 60.4898 37.7767 60.5458L37.7767 60.5458C37.7951 60.5783 37.8145 60.6124 37.8366 60.6483C38.0576 61.0089 38.0693 61.2299 38.0693 64.5217C38.0693 66.441 38.1274 68.3486 38.1856 68.7674C38.4298 70.3028 39.4767 71.9313 40.826 72.8618C42.2568 73.8389 44.2458 74.153 45.8743 73.6528C47.8634 73.0596 49.1661 71.8033 50.0385 69.6514C50.213 69.221 50.2246 67.1273 50.2828 45.8524C50.2832 45.7048 50.2836 45.5582 50.284 45.4124C47.7721 44.6824 45.4597 43.4834 43.448 41.9165C43.2864 42.0665 43.0869 42.1816 42.8616 42.2465C42.2684 42.4094 17.5854 42.4094 16.9922 42.2465C16.3873 42.0721 15.9686 41.537 15.9686 40.9321C15.9802 40.3971 16.143 40.1063 16.6316 39.7806C16.9456 39.5828 17.5738 39.5712 29.9269 39.5712C35.926 39.5712 39.1599 39.5739 40.9355 39.5994C37.5948 35.9603 35.5556 31.1071 35.5556 25.7778C35.5556 23.5688 35.9059 21.4417 36.5541 19.4489ZM31.4274 29.4979C32.3929 29.9981 32.4161 31.2427 31.4739 31.8592C31.1831 32.057 30.6248 32.0686 24.4599 32.1035C20.7842 32.1268 17.5389 32.1035 17.2597 32.0686C16.5036 31.9523 15.9686 31.3939 15.9686 30.7077C15.9802 30.161 16.143 29.8702 16.6316 29.5445C16.934 29.3467 17.376 29.3351 24.0295 29.3351C29.9734 29.3351 31.1482 29.3584 31.4274 29.4979ZM43.1757 49.9702C43.6293 50.2144 43.8852 50.6448 43.8852 51.2148C43.8852 51.5986 43.8154 51.7615 43.4897 52.0872L43.0943 52.4827H16.7595L16.364 52.0872C16.0384 51.7615 15.9686 51.5986 15.9686 51.2148C15.9686 50.6564 16.2128 50.2261 16.6548 49.9818C17.1201 49.7259 42.6871 49.7259 43.1757 49.9702ZM2.44085 70.7797C1.83599 69.5816 1.77783 69.1861 1.77783 65.8361V62.7187H35.2429L35.3127 65.8826C35.3593 68.5812 35.4058 69.1977 35.6035 69.9422C35.8943 71.0239 36.4643 72.1755 37.1855 73.1642L37.7205 73.8854H22.378C12.677 73.8854 6.81446 73.8389 6.43061 73.7691C4.95335 73.4899 3.11551 72.1173 2.44085 70.7797Z" fill="#636a79"></path>' +
1675                '<circle cx="59.4443" cy="23.4999" r="19.9999" fill="#636a79"></circle>' +
1676                '</svg>' +
1677                '<div class="pcv-item pcv-status-paid-voucher border-bl-radius"></div>' +
1678                '</div>';
1679        }
1680
1681        skeletonVouchers += '<div class="pcv-item pcv-info">' +
1682            '<div class="pcv-title__info-name">' +
1683            '<div class="pcv-title skeleton-text"></div>' +
1684            '<div class="pcv-title skeleton-text" style="margin-top: 5px; width: 150px;"></div>' +
1685            '</div>' +
1686            '<div class="pcv-time skeleton-text short">' +
1687            '<span class="pcv-time__date"></span>' +
1688            '</div>' +
1689            '<button type="button" class="btn btn-view-tc" style="opacity: 0.4;"></button>' +
1690            '</div>' +
1691            '</div>';
1692    }
1693
1694    skeletonVouchers += '</div></div></div></div></div></div>';
1695    $(apllyVoucherBody).html(skeletonVouchers);
1696
1697}
1698
1699function removeDomainSpecificCharacters(str) {
1700    if (!str) {
1701        return '';
1702    }
1703
1704    return str.replace(/[^a-zA-Z0-9]/g, '');
1705}
1706
1707function voucherClearSelection() {
1708    console.log('voucherClearSelection');
1709    $(apllyVoucherPopupId).find('.btn-apply-discount').attr('disabled', 'disabled');
1710    loadSeletonVouchers();
1711
1712    let voucherText = $(apllyVoucherPopupId).find('#aplly-voucher-text').val();
1713    clearSelectionVouchers(voucherText);
1714}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.