JSFiddle - React, Tailwind, and code Playground
by mtenschert
JavaScript
if (featureIsActive) {
// ajax call
$.ajax({
url: "https://www.alpinresorts.com/de/service/cart/current",
}).done(function(data) {
console.log(data);
if (data.personCount === 0 && data.itemCount === 0) {
console.log("A/B test - id:xpz");
// add if user has no active search
$("app-shop a.ski-hire-shop-detail__detail-button span:nth-child(2) div.text-wrapper").html(translations[O360G_lang].translation1);
$(document).on('DOMNodeInserted', function(e) {
if ($(e.target).find('.product__content')) { // new shop lazy loaded
$("app-shop a.ski-hire-shop-detail__detail-button span:nth-child(2) div.text-wrapper").html(translations[O360G_lang].translation1);
}
});
} else {
console.log("A/B test - id:xpz");
// add if user has already an active search
$("app-shop a.ski-hire-shop-detail__detail-button span:nth-child(2) div.text-wrapper").html(translations[O360G_lang].translation2);
}
});
// addEventListener for changes in user settings (person count, basket)
window.addEventListener('alpiPostOfferUpdate', function(e) {
// add if user has already an active search
$("app-shop a.ski-hire-shop-detail__detail-button span:nth-child(2) div.text-wrapper").html(translations[O360G_lang].translation2);
}, false);
}