Forum

Thread tagged as: Question, Runway, Shop

More products to come / No products left in listing view

Hi,

I am using ajax to implement a "Show More" button on my product listing page. It's a pretty simple implementation, I have my main shop page with this template:

perch_shop_products([
   'count' => $count,
]);

And a button which increments that count by a certain number, and sends it off to an ajax page with the same function, which then returns the results. Similar to the approach here: https://forum.grabaperch.com/forum/09-04-2014-loading-x-amount-of-shop-items-on-the-same-page-with-a-load-more-button

I would now like to hide my "Show More" button if there are no more products to show. I have tried to use perch_item_last to apply a class for this, but it appears on the last item in the selected count, not the last item overall.

My question is can I add anything to the template which I can detect, which would indicate there are more products available beyond the count / no more products available beyond the count?

Thanks!

Mike

Mike Harrison

Mike Harrison 37 points

  • 4 years ago

Hi,

I didn't spot the total in the showall - that is exactly what I needed. For future reference this is what I have done to add a class to the last item:

<perch:if id="perch_item_index" match="eq" value="{total}">last</perch:if>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, great.