Shopify themes, liquid, logos, and UX
Hello,
I need to add an image on my products, but only if the tags meet specific names, I already have the CSS code but i do need the way to make it conditional or with statement, below is the CSS code but when i use it the image appeared on all products, I'm using Dawn theme.
Thanks in Advance
.product__media-item modal-opener{
position: relative;
}
.product__media-item modal-opener:after{
content: '';
position: absolute;
top: 5px;
left: 5px;
width: 15%;
height: 15%;
background-image: url('https://cdn.shopify.com/s/files/1/0634/5061/1897/files/free.png');
background-size: contain;
background-repeat: no-repeat;
z-index: 2;
}
Solved! Go to the solution
This is an accepted solution.
I added style to your code and it is working now, thank you Noah
{% for tag in product.tags %}
{% if tag contains 'ROYALFORD' %}
<style>
.product__media-item modal-opener{
position: relative;
}
.product__media-item modal-opener:after{
content: '';
position: absolute;
top: 5px;
left: 5px;
width: 20%;
height: 20%;
background-image: url('https://cdn.shopify.com/s/files/1/0634/5061/1897/files/2ywarranty.png');
background-size: contain;
background-repeat: no-repeat;
z-index: 1;
}
</style>
{% endif %}
{% endfor %}
This is Noah from PageFly - Shopify Page Builder App
Please add this condition with the tags like this
{% for tag in product.tags %}
{% if tag contains 'your-tag' %}
.product__media-item modal-opener{
position: relative;
}
.product__media-item modal-opener:after{
content: '';
position: absolute;
top: 5px;
left: 5px;
width: 15%;
height: 15%;
background-image: url('https://cdn.shopify.com/s/files/1/0634/5061/1897/files/free.png');
background-size: contain;
background-repeat: no-repeat;
z-index: 2;
}
{% endif %}
{% endfor %}
You should put this code in a product page. For that can check all the tags
Hope this can help you solve the issue
Best regards,
Noah | PageFly
Please let me know if it works by giving it a Like or marking it as a solution!
PageFly - #1 Page Builder for Shopify merchants.
All features are available from Free plan. Live Chat Support is available 24/7.
Thank you Noah for your reply,
Unfortunately the code not working properly, please check the image.
This is an accepted solution.
I added style to your code and it is working now, thank you Noah
{% for tag in product.tags %}
{% if tag contains 'ROYALFORD' %}
<style>
.product__media-item modal-opener{
position: relative;
}
.product__media-item modal-opener:after{
content: '';
position: absolute;
top: 5px;
left: 5px;
width: 20%;
height: 20%;
background-image: url('https://cdn.shopify.com/s/files/1/0634/5061/1897/files/2ywarranty.png');
background-size: contain;
background-repeat: no-repeat;
z-index: 1;
}
</style>
{% endif %}
{% endfor %}
Thanks for the solution! It worked for me.
This has worked perfectly on the product pages themselves but is there any way to make the overlay appear on the thumbnails when browsing collections as well?
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