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.
Hej @ellenventu,
thanks for the feedback. I will take a look into it, but as far as i know i didn’t came up with this kind of error. You can debug this maybe further, if you look at the XHR requests (should be something with
collections/COLLECTIONAME?page=2
in the url) and open this url and look what kind of products are their. Since this script only opens the{{paginate.next_url}}
and get all the items from the#product_grid
.When i find the time, i will look into this.