How can I auto-truncate long product titles on my site?

Good morning,

I would like that when the product title is above 56 characters, the name automatically stops and adds 3 small points. (ONLY for featured collection and collections)

EXAMPLE HOW IT IS NOW:

EXAMPLE HOW I WOULD LIKE IT TO AUTOMATICALLY DO ABOVE 56 CHARACTERS IN THE TITLE:

website: jadis-shop.com

password: rj

Do you know how to do it ?

thank you very much in advance

Hi @JADIS

I checked your website and it seems you are using Shopify’s Dawn theme. As required, you want to shorten titles that are too long in some specified positions. But unfortunately it will not be done in position but it will be done in all tabs in all screens.

I will show you how to shorten the title when it has more than 56 characters:

Step 1: Open Online Store → click edit code

Step 2: Enter in the search box “card-product” → Click to card-product.liquid to open file

Step 3: Press the key combination Ctrl + f → Enter into the search box that appears {{ card_product.title | escape }}

→ Enter into the replace box:
{% assign truncated_title = card_product.title | slice: 0, 56 %} {% if card_product.title.size > 56 %} {{ truncated_title | append: ‘…’ | escape }} {% else %} {{ card_product.title | escape }} {% endif %}

→ Click replace all and save.

→ You will get results like this:

Hope it helps @JADIS !