-
-
Save SimonHaasnoot/3c8d0490636a2b171e5f4f57677b5a67 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload = function () { | |
const hasMaakwijze = document.documentElement.innerText.indexOf("Maakwijze") > 0; | |
const hasMultipleBlockWraps = document.querySelectorAll(".block-wrap").length > 1; | |
if (!hasMaakwijze || !hasMultipleBlockWraps) { | |
const blockWrapElements = document.querySelectorAll(".block-wrap"); | |
const cartHasProducts = document.querySelector('.main-cart .products .product'); | |
if (blockWrapElements && blockWrapElements[1]) { | |
blockWrapElements[1].style.display = "none"; | |
} else if (!cartHasProducts && !blockWrapElements[1]) { //If cart has no products there's only 1 blockwrap | |
blockWrapElements[0].style.display = "none"; | |
} | |
} else { | |
// Customization | |
const message = "Deze order bevat een ophangdienst"; | |
// -------------- | |
const contentBlock = document.querySelector(".contentblock"); | |
if (contentBlock) { | |
contentBlock.style = "width: 100%;"; | |
} | |
const buttons = document.querySelectorAll(".product-cluster-slider .addto-cart .button"); | |
if (buttons) { | |
for (let i = 0; i < buttons.length; i++) { | |
const button = buttons[i]; | |
button.addEventListener("click", function () { | |
insertNotification(); | |
}); | |
} | |
} | |
function insertNotification() { | |
const notificationIsInDom = document.querySelector("#hang-service-notification"); | |
const contentBlock = document.querySelector(".contentblock"); | |
if (!notificationIsInDom && !contentBlock) { | |
const container = document.querySelector(".xlarge-8.large-12.columns"); | |
if (container) { | |
const newDiv = document.createElement("div"); | |
newDiv.style = "background: white; padding: 20px; margin-bottom: 20px;"; | |
newDiv.id = "hang-service-notification"; | |
const newContent = document.createTextNode(message); | |
newDiv.appendChild(newContent); | |
container.insertBefore(newDiv, container.firstChild); | |
} | |
} | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment