All things Shopify and commerce
Hi!
I'm trying to add a unique class to a product card based on tags. I'm 90% of the way there. I updated line 43 of card-product.liquid to have an "if" in the class, looking like this:
<div class="card-wrapper product-card-wrapper underline-links-hover {%- if card_product.tags contains 'non-interactive' -%} non-interactive{%- endif -%}">
My only hangup is that in the final outcome, the last two classes get stuck together like so:
class="card-wrapper product-card-wrapper underline-links-hovernon-interactive"
Any thoughts on how to fix this?
Solved! Go to the solution
This is an accepted solution.
https://shopify.dev/api/liquid/basics/whitespace -- just remove dashes:
{% if card_product.tags contains 'non-interactive' %}
This is an accepted solution.
https://shopify.dev/api/liquid/basics/whitespace -- just remove dashes:
{% if card_product.tags contains 'non-interactive' %}
@blessing2 wrote:add a space before {%- if to prevent the classes from merging
This is wrong -- adding a dash will eat up all whitespace to the closest non-space character.
Thank you @tim !! Worked like a charm. Hoping this will be a good reference for others, too.
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