Shopify themes, liquid, logos, and UX
Hello,
I would need help, i'm trying to hide the Sale badge from the products thumbnail images. I'm using the Spotlight theme. Can someone please help? Please see the screenshot below. Thanks!
Solved! Go to the solution
This is an accepted solution.
Hey @ADT77,
In the same theme.liquid file, add this at the bottom of the file ABOVE the </body> tag. You can delete the old code.
<script>
document.addEventListener('DOMContentLoaded', function () {
try{
let badges = document.querySelectorAll('.badge');
badges.forEach(function(key, value){
if(key.innerHTML === 'Sale') {
key.style.display = 'None';
}
})
} catch{}
});
</script>
Screenshot for reference.
This is an accepted solution.
Hey @ADT77,
Adding 'En vente' worked fine for me. Maybe give it about 5 minutes to apply (Maybe cached, etc...)
<script>
document.addEventListener('DOMContentLoaded', function () {
try{
let badges = document.querySelectorAll('.badge');
badges.forEach(function(key, value){
if(key.innerHTML === 'Sale' || key.innerHTML === 'En vente') {
key.style.display = 'None';
}
})
} catch{}
});
</script>
This is an accepted solution.
You can try to add this code as well.
Go to your theme's "Edit Code" Option, then in the search bar type "theme.liquid"
Below the tag "<head>" tag paste the following. Screenshot attached for reference.
<style>
product-recommendations .card__badge {
display: none !important;
}
</style>
Screenshot is for reference only, the correct code to paste is the one shown above.
Hi @ADT77
If you share your store URL and password with me, I will check and provide you with the solution.
Hey @ADT77,
Go to your theme's "Edit Code" Option, then in the search bar type "theme.liquid"
Below the tag "<head>" tag paste the following. Screenshot attached for reference.
<style>
.card.card--standard.card--media:has(.price.price--on-sale) .card__badge {
display: none !important;
}
</style>
Screenshot is for reference only, the correct code to paste is the one shown above.
Hello @ThePrimeWeb ,
The code above removed both badges (Sale and Sold out). I just need to hide the "Sale badge".
Thanks
Oh I guess your sold out product also had a sale price. Let me give you another code.
This is an accepted solution.
Hey @ADT77,
In the same theme.liquid file, add this at the bottom of the file ABOVE the </body> tag. You can delete the old code.
<script>
document.addEventListener('DOMContentLoaded', function () {
try{
let badges = document.querySelectorAll('.badge');
badges.forEach(function(key, value){
if(key.innerHTML === 'Sale') {
key.style.display = 'None';
}
})
} catch{}
});
</script>
Screenshot for reference.
I just noticed that when switching the website's language from english to french, the Sale badge appears in the French version of the website. The English version which is the default language works perfectly fine. How can we fix it for the French version please?
Thank you!
Hey @ADT77,
<script>
document.addEventListener('DOMContentLoaded', function () {
try{
let badges = document.querySelectorAll('.badge');
badges.forEach(function(key, value){
if(key.innerHTML === 'Sale' || key.innerHTML === 'French') {
key.style.display = 'None';
}
})
} catch{}
});
</script>
Can you replace the word French with the word displayed in your site for Sale in french, I don't know what it is haha. Screenshot below highlighting what you need to replace. Don't remove the quotes. After that replace the code that I gave you previously.
Hi there, i replaced it with the word En vente as displayed on the website but it's not working. I tried "En-vente, en-vente, envente" and none works. Please see below
The code i changed below
Hey @ADT77,
Can I have the link to your store to test this?
This is an accepted solution.
Hey @ADT77,
Adding 'En vente' worked fine for me. Maybe give it about 5 minutes to apply (Maybe cached, etc...)
<script>
document.addEventListener('DOMContentLoaded', function () {
try{
let badges = document.querySelectorAll('.badge');
badges.forEach(function(key, value){
if(key.innerHTML === 'Sale' || key.innerHTML === 'En vente') {
key.style.display = 'None';
}
})
} catch{}
});
</script>
Thanks a lot for your help and patience! I did not try this combination whithout the dash between both words, it does work now!
Hello @ThePrimeWeb
Was wondering if you could help a little. I just noticed that the SALE badge also appears in the ''Related Products'' section in the product page. Can you please help by hiding the badge in that section too? Please see below the 2 screenshots for the Related products section (English and french wordings)
I don't see it @ADT77
Hi, sorry here is the screenshot. It's the "Related products" section in the product page. On the homepage everything is fine.
Thank you!
This is an accepted solution.
You can try to add this code as well.
Go to your theme's "Edit Code" Option, then in the search bar type "theme.liquid"
Below the tag "<head>" tag paste the following. Screenshot attached for reference.
<style>
product-recommendations .card__badge {
display: none !important;
}
</style>
Screenshot is for reference only, the correct code to paste is the one shown above.
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024