Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.9 kB
1
Indexable
Never
function dataLayerListener(callback) {
    if (Insider.fns.isArray(window.dataLayer)) {
        var originalDataLayerPush = window.dataLayer.push;

        window.dataLayer.push = function () {
            callback(arguments[0]);

            originalDataLayerPush.apply(this, arguments);
        };
    }
}

if (!(Insider.__external.isApiInitedSrtr20347 || false)) {
    Insider.__external.isApiInitedSrtr20347 = true;

    dataLayerListener(function (newData) {
        if (newData.event === 'gtm.click' && Insider.fns.hasParameter('/checkout') &&
            (newData['gtm.elementClasses'] === 'plus-product' || newData['gtm.elementClasses'] ===
                'minus-product' || newData['gtm.elementClasses'] === 'plus-baby' ||
                newData['gtm.elementClasses'] === 'minus-baby' ||
                newData['gtm.elementClasses'] === 'minus-traveler' ||
                newData['gtm.elementClasses'] === 'plus-traveler')) {
            if (Insider.systemRules.call('isOnCartPage')) {
                setTimeout(function () {
                    if (!(Insider.__external.isCartUpdatedSrtr20347 || false)) {
                        Insider.__external.isCartUpdatedSrtr20347 = true;
                        Insider.fns.onElementLoaded('flt-platform-view h1:not(:first,:last)', function () {
                            updateOnCart();
                        }).listen();
                    }
                }, 1000);
                /* SRTR-20623 START */
                setTimeout(function () {
                    Insider.storage.localStorage.set({
                        name: 'total-cart-amount',
                        value: Insider.systemRules.call('getTotalCartAmount')
                    });
                }, 500);
                /* SRTR-20623 END */
            }
        }
    });
}