How can I limit a card product description in code?

How can I limit a card product description in code?

Ritikaaaa
Shopify Partner
39 0 3

Hello,

How can i limit  card product description ?? {{ card_product.description }}
I tried to use this code  {{ card_product.description | truncate:30 }} but this isn't working Please help!

 

Replies 2 (2)

Asad-Mahmood
Shopify Partner
331 55 63

What's your store url ?

If my solution has been helpful, you can consider supporting me via Buy Me a Coffee.
Hire me: asadmahmood8470@gmail.com
WhatsApp
Fiver




Ritikaaaa
Shopify Partner
39 0 3

I can share the code


{% for block in section.blocks %}
<div>
{% assign product = all_products[block.settings.produit] %}
<div>
<a href="{{ product.url }}">
<h2>{{ product.title }}</h2>
<p>{{ product.description }}</p>
<img src="{{ product.featured_image.src | img_url: '1024x' }}" alt="">
</a>
{% if product.variants.size > 1 %}
<ul>
{% for variant in product.variants %}
<li><a href="{{ variant.url }}">{{ variant.title }}</a></li>
{% endfor %}
</ul>
{% else %}
<div>
<a href="{{ product.url }}">Buy Now</a>
</div>
{% endif %}
</div>
</div>
{% endfor %}