Shopify themes, liquid, logos, and UX
Hi community, can you help me with this.
I want to load product without going to next page.
Thank you
Solved! Go to the solution
This is an accepted solution.
ok,
Follow this:
1. open section->collection-template.liquid file and find ' paginate.pages > 1' condition.
then add bellow code in side this condition.
<input type="hidden" value="{{ paginate.next.url }}" data-next-url> <input type="hidden" value="{{ paginate.pages }}" data-total-pages> <input type="hidden" value="{{ paginate.current_page }}" data-current-page> <div class="load-more_wrap"> <button class="btn js-load-more"> <span load-more-text>Load more</span> <span class="hide" loader>{% include 'icon-spinner' %}</span> </but
2. Now add this js in Asset->theme.js
$('.js-load-more').on('click', function(){ var $this =$(this),totalPages = parseInt($('[data-total-pages]').val()),currentPage = parseInt($('[data-current-page]').val()); $this.attr('disabled', true); $this.find('[load-more-text]').addClass('hide'); $this.find('[loader]').removeClass('hide'); var nextUrl = $('[data-next-url]').val().replace(/page=[0-9]+/,'page='+currentPage); $('[data-current-page]').val(currentPage); $.ajax({ url: nextUrl, type: 'GET', dataType: 'html', success: function(responseHTML){ $('.grid--view-items').append($(responseHTML).find('.grid--view-items').html()); }, complete: function() { if(currentPage <= totalPages) { $this.attr('disabled', false); $this.find('[load-more-text]').removeClass('hide'); $this.find('[loader]').addClass('hide'); } } }) });
This is an accepted solution.
Replace with this Js code:
$('.js-load-more').on('click', function(){ var $this =$(this),totalPages = parseInt($('[data-total-pages]').val()),currentPage = parseInt($('[data-current-page]').val()); $this.attr('disabled', true); $this.find('[loader]').removeClass('hide');
currentPage = currentPage+1; var nextUrl = $('[data-next-url]').val().replace(/page=[0-9]+/,'page='+currentPage); $('[data-current-page]').val(currentPage); $.ajax({ url: nextUrl, type: 'GET', dataType: 'html', success: function(responseHTML){ $('.grid--view-items').append($(responseHTML).find('.grid--view-items').html()); }, complete: function() { if(currentPage <= totalPages) { $this.attr('disabled', false); $this.find('[load-more-text]').removeClass('hide'); $this.find('[loader]').addClass('hide'); } } }) });
This is an accepted solution.
User | RANK |
---|---|
69 | |
65 | |
63 | |
53 | |
47 |
We're excited to announce improvements to the threaded messaging experience in our communi...
By TyW May 31, 2023Thank you to everyone who participated in our AMA with Klaviyo. It was great to see so man...
By Jacqui May 30, 2023Photo by Marco Verch Sales channels on Shopify are various platforms where you can sell...
By Ollie May 25, 2023