Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello,
I managed to make sku appear on the product cards. But I need help filtering that a bit.
My goal is to only show the sku on products without variants.
I've been trying to work this out with the following code. But It's not working.
<div class="skuproductcard">
{% if product.has_only_default_variant %}
<p234> ID nr. {{ card_product.variants[0].sku }} </p234>
{% endif %}
</div>
I would appreciate any help 🙂
Some things I notice here:
First of all, <p234></p234> is no valid HTML element and should be <p></p>
Second, did you declare card_product as a variable before? If not, this is not an object you have access to and should be changed to product.
Third, if has_only_default_variant is true, then I think product.variants is empty. That means product.variants[0] won't return anything. (But not 100% sure)
Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025