Background
If users have the item called Get All X
in their cart, then I want to hide the upsell section called wcf-bump-order-content
.
What I have tried
window.addEventListener("load", function () {
var you1 = document.getElementsByClassName("product-name");
var you5 = "";
for (var i = 0; i < you1.length; i++) {
var you2 = you1[i].textContent;
var you3 = you2.replace(/\s/g, "");
var you4 = you3.replace("Xs", "");
you5 += you4;
}
var you6 = you5.includes("GetAllX");
if (you6 = "true") {
document.getElementsByClassName("wcf-bump-order-content")[0]
.setAttribute("style", "display:none !important");
}
console.log(you6);
console.log("finish");
});
Full code + HTML: https://jsfiddle.net/lindychen/14vLfcy5/
Results
As you can see from the JS fiddle, my code works and hides the relevant section. However, when I test this on my live website, it doesn't work (ie. the upsell section still shows). I can't figure out what's wrong especially since console log shows you6
to be true
and finish
is also shown.
Thanks.