How can I change the variant table to show that the variants are also unavailable? is there a way to show the variants and prices crossed out?
Topic summary
Issue: A user wanted to display out-of-stock product variants as unavailable on Shopify collection pages, specifically showing crossed-out prices and titles in a variant table.
Solution Provided:
- Replace code in
snippets/card-product.liquidto create a table displaying all variants with their titles and prices - Add CSS to strike through sold-out variant titles and prices using
.variant-available--falseclass - For products without variants, modify the product title display logic in
card-product.liquid(lines 123 and 160 in Dawn theme) - Apply CSS rule
.price--sold-out *to cross out prices of unavailable items
Key Technical Details:
- Original implementation followed a Klinkode tutorial for displaying variants on collection pages
- CSS targeting required careful scoping to avoid crossing out all products instead of only sold-out ones
Outcome: User successfully implemented both the variant table strikethrough and the single-product strikethrough by combining the liquid code changes with custom CSS additions. Issue resolved.
Hi @asmenu - is the table a custom code that you made?
Then replace lines 12 ad 13 with this:
{% if variant.available %}
{{ variant.title }}
{{ variant.price | money }}
{% else %}
~~{{ variant.title }}~~
~~{{ variant.price | money }}~~
{% endif %}
Hey @asmenu ,
Thanks for sharing the doc you used. To display the prices and variant titles of the variants that are sold out please make the below code changes:
- Replace the code that you added to the snippets/card-product.liquid with the below code:
{% if template.name == 'collection' and card_product.variants.size > 1 %}
{% for variant in card_product.variants %}
{% endfor %}
| Variant | Price |
| - | - |
| {{ variant.title }} | {{ variant.price | money }} |
{% endif %}
- Add the below CSS to cross out the titles and prices of the sold-out variants in addition to the CSS you added for the design of the variant table.
.variant-available--false {
text-decoration: line-through;
}
- Once you have made these changes, save the files and try previewing the collection pages. The title and price of the variants that are sold out will be crossed out on the variants table as shown in the screenshot below:
I hope this helps!
If my response helped you, please consider giving it a like (
) and marking it as an accepted solution if it resolved your issue. Your feedback helps other community members with similar questions.
Regards,
Abhishek from Swym
this seemed to work! thank you so much!
couldn’t figure out how to make this one work ![]()
To cross the title you need to do similar edits.
For Dawn, these lines:
https://github.com/Shopify/dawn/blob/main/snippets/card-product.liquid#L123 and
https://github.com/Shopify/dawn/blob/main/snippets/card-product.liquid#L160
{{ card_product.title | escape }}
change to
{% if product.available %}
{{ card_product.title | escape }}
{% else %}
~~{{ card_product.title | escape }}~~
{% endif %}
To cross out the price it’s better to use CSS. You can add this to “Custom CSS” under theme settings:
.price--sold-out * {
text-decoration: line-through;
}
Also, you can use CSS for product title too instead of liquid edit above:
.card__content:has(.price--sold-out) a {
text-decoration: line-through;
}
sorry don’t understand where to add the
.price–sold-out * {
text-decoration: line-through;
}
the CSS works but the cross out is crossing all titles out instead of just the sold out ones.
got what I wanted by adding both the CSS codes to Custom CSS. thanks so much!


