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.
Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024The Hydrogen Visual Editor is now available to merchants in Shopify Editions | Summer '...
By JasonH Sep 2, 2024Note: Customizing your CSS requires some familiarity with CSS and HTML. Before you cust...
By JasonH Aug 12, 2024