In order to integrate with Slide Cart by AMP for Intelligems, you will need to make these changes in the theme.liquid file of your store. Once you have that file open, locate where your <body>
tag closes (i.e. </body>
) and insert this script just above that closing tag.
<!-- Slide Cart By AMP Modifications to hide Intelligems Discount -->
<script>
// This SLIDECART_OPENED function is called when the slidecart is opened, this is provided by the Slide Cart by AMP app
window.SLIDECART_OPENED = function(cart) {
const slidecart = document.querySelector('#slidecarthq');
if (slidecart) {
// Hide the strikethrough compare prices
let comparePrices = slidecart.querySelectorAll('.slidecarthq .items .main .main-bottom .price.strike-through')
comparePrices.forEach(function(element){
element.style.display="none";
})
// Hide the discount badges
let discountBadges = slidecart.querySelectorAll('.slidecarthq .items .main .discount-allocations')
discountBadges.forEach(function(element){
let discountAllocation = element.querySelector('.discount-allocations-flex-1')
// If the text is "Discount" then hide the whole badge -- Change the value to compare if you change the discount title
if (discountAllocation && discountAllocation.innerText === "Discount") {
element.style.display="none";
}
})
// Hide the discounts footer row if exists
let discountsFooterRow = slidecart.querySelectorAll('#slidecarthq .slidecarthq .footer .footer-row')
if (discountsFooterRow.length > 2) {
discountsFooterRow[1].style.display="none";
}
}
}
// This SLIDECART_UPDATED function is called when the slidecart is updated, for example, if you change the quantity for a product
// or if you delete a product from the cart
window.SLIDECART_UPDATED = function(cart) {
const slidecart = document.querySelector('#slidecarthq');
if (slidecart) {
// Hide the strikethrough compare prices
let comparePrices = slidecart.querySelectorAll('.slidecarthq .items .main .main-bottom .price.strike-through')
comparePrices.forEach(function(element){
element.style.display="none";
})
// Hide the discount badges
let discountBadges = slidecart.querySelectorAll('.slidecarthq .items .main .discount-allocations')
discountBadges.forEach(function(element){
let discountAllocation = element.querySelector('.discount-allocations-flex-1')
// If the text is "Discount" then hide the whole badge -- Change the value to compare if you change the discount title
if (discountAllocation && discountAllocation.innerText === "Discount") {
element.style.display="none";
}
})
// Hide the discounts footer row if exists
let discountsFooterRow = slidecart.querySelectorAll('#slidecarthq .slidecarthq .footer .footer-row')
if (discountsFooterRow.length > 2) {
element.style.display="none";
}
}
}
</script>
This a function called SLIDECART_OPENED
, which is a function powered by Slide Cart by AMP where you can execute code when your drawer cart is opened. You can add whatever you want inside this function, but for the Intelligems integration, this function can be divided into three parts:
There’s another function called SLIDECART_UPDATED
, which is similar to the previous one, but this is triggered when the cart is updated instead (for example, if you update a product quantity or delete a product), it has the same procedure as the SLIDECART_OPENED
function:
Your theme.liquid
file should have this structure now:
<!-- Slide Cart By AMP Modifications to hide Intelligems Discount -->
<script>
// This SLIDECART_OPENED function is called when the slidecart is opened, this is provided by the Slide Cart by AMP app
window.SLIDECART_OPENED = function(cart) {
const slidecart = document.querySelector('#slidecarthq');
...
.
.
.
...
}
// This SLIDECART_UPDATED function is called when the slidecart is updated, for example, if you change the quantity for a product
// or if you delete a product from the cart
window.SLIDECART_UPDATED = function(cart) {
const slidecart = document.querySelector('#slidecarthq');
...
.
.
.
...
}
</script>
</body>
Now, you can preview your theme and test and check if the three elements are now removed. If they are, you're good to go!