This script is based on (this)[https://github.com/programmerhabib/load-more-button-on-shopify-collection-page/blob/main/load%20more%20product%20button.txt]
I’m using the Dawn Theme with Tailwind. To get this visually work you will need to install tailwind. Otherwise you have to write your own CSS for the Button + Spinner.
- Add Next page as data attribute to product grid on your collection page:
data-next-url="{{paginate.next.url}}"
Looks like this in Dawn:
<ul id="product-grid" data-id="{{ section.id }}" class="flex-grid product-grid ..." data-next-url="{{paginate.next.url}}">
- Add
main-collection-product-grid.liquid
content to the end of the grid on your collection page. - Include the script on the collection page
{% if template contains 'collection' %} <script src="{{ 'collection-load-more.js' | asset_url }}" defer="defer"></script> {%endif%}
- Check the class name of your product items / card (default is
.grid__item
if different change Line 26 in the javascript file.
Hi,
I have used your documentation and it seems to work.
The only thing I notice is that when I click on the "load more" button not all the products of collection are shown, the last 3 are missing.
In fact, doing some console.log () it seems that not all products are present in the variable "productgrid".
If I use the standard pagination of the theme "Dawn" instead I see all the products of collection (file pagination.liquid).
Are you also experiencing this error?
Thanks