Shopify themes, liquid, logos, and UX
Hi Shopify Gurus,
My website is : https://pawtietime.com/products/canvas
I wish to change the color of the product background for each product. Is there a way to dynamically change the color as per specified color?
For example, if i specify product A to have color blue and product B to have color pink, i wish to have each product page background to reflect that color. So im unsure on how to give that color specification to each product.
Solved! Go to the solution
This is an accepted solution.
Very close!
Would be a lot easier if you edit this directly in your product section...
Not sure what theme you're using but in your product section, find the div with these classes 'product__media media media--transparent customcolorstyle'
And add the logic below.
Basic logic for for metafields:
{% assign assign color-meta-tests = product.metafields.custom.color_meta_tests %}
{% if color-meta-tests != blank %}
{% style %}
.customcolorstyle {
background-color: {{ color-meta-tests }} !important;
}
{% endstyle %}
{% endif %}
Replace this metafield with yours...
Hope it makes sense
I have explore meta tags and used color to define each product. now how do i reference that color to code editor?
Update: My metafield is correctly outputting the right hex code that ive assigned it to the product.
But when i type that in my css , its not picking up the hex code 😞
This is an accepted solution.
Very close!
Would be a lot easier if you edit this directly in your product section...
Not sure what theme you're using but in your product section, find the div with these classes 'product__media media media--transparent customcolorstyle'
And add the logic below.
Basic logic for for metafields:
{% assign assign color-meta-tests = product.metafields.custom.color_meta_tests %}
{% if color-meta-tests != blank %}
{% style %}
.customcolorstyle {
background-color: {{ color-meta-tests }} !important;
}
{% endstyle %}
{% endif %}
Replace this metafield with yours...
Hope it makes sense
thank you so much! youre such an angel. this worked perfectly!
Glad I could help
Hi there:
I am trying to do the same thing that the author of this post was attempting, but it's not working for me. I am working in the Kalles theme and trying to change product background colors based on flavor. My metafield seems to be pulling the correct code, but I'm placing it within the ecomposer template, and it doesn't seem to be applying the background color to the page.
Store URL: https://art-of-sucre.myshopify.com/
PW: ifreul
Color applied to metafield does seem to be pulling correctly if you view https://art-of-sucre.myshopify.com/products/birthday-cake-cotton-candy (under share icons)
Thanks in advance for the help!!
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024