I am on Debut theme and am looking for some guidance on how to add a ‘read more’ button collapsing and expanding text on the description of my products.
Having taken a look at some of the guidance on here for other themes, I’m at a loss about how and where to add the necessary code, so thanks in advance for any help you may have on this.
As an update, I now have this working perfectly on my site (which you can see on the products at https://vengersdecks.com). I highly recommend oscprofessional, who worked with me at a very reasonable price, with great communication until it was resolved. Here’s their profile:
Here’s an example of the liquid code to add to the product or collection template in place of the existing {{ product.description }} code. This example is for the product. For collection, just replace ‘product.description’ with ‘collection.description’.
Here’s the JavaScript that is watching for the links to be clicked and taking action when they are. You can add these to an existing JS file in the theme, create a new JS file or add it onto the liquid template for the products and collections. In the syntax below, this is added to the product.liquid and collection.liquid templates.
<script>
$('.readmore').click(function (event) {
event.preventDefault();
var descriptionFull = document.querySelector('.product-description-full');
descriptionFull.style.display = 'block';
var descriptionShort = document.querySelector('.product-description-short');
descriptionShort.style.display = 'none';
});
$('.readless').click(function (event) {
event.preventDefault();
var descriptionFull = document.querySelector('.product-description-full');
descriptionFull.style.display = 'none';
var descriptionShort = document.querySelector('.product-description-short');
descriptionShort.style.display = 'block';
});
</script>
If you are not comfortable implementing in your theme file then just send me mail with your store details. I will help you to make it working.
I used your solution but I have one problem: the ‘read more’ button is very close to where the size of the product is displayed, so I would like a bit more space there.
Hello @Tejas_Nadpara I have followed your advice and pasted in the code for a read more button on my collections pages. But no button has appeared unfortunately.
Thanks for your help.
nicole