Dynamic paginate collection.products - how to?

Highlighted
Tourist
22 0 1

I have searched far and wide and unless I am searching for the wrong keywords, I can't find any resources anywhere in the internet that talks about dynamic pagination ofr products on shopify.

I know I can manually set a "products per page" value by modifying

{% paginate collection.products by 12 %}

BUT... like 99% of stores on the internet - I want the USER to be able to select how many products per page.

What seems to be the most basic functionality appears to be unachievable from what I can see?

I can't read HTTP_REQUEST variables from the URL so manually passing a value to the page doesn't work?

I am quite new to shopify and am perplexed by this conundrum.

0 Likes
Shopify Expert
9718 43 1377

You can use cart attributes to save the value and read that back to replace the 12 with No doubt you've seen this useless page but the concept is (and largely copy / pasted):

  • Add a select menu to the page
  • Bind a change event to it that fires a function
  • The function reads the value (eg: "12") and uses ajax to set the cart attribute
  • Reload the page, and use the cart attribute for the pagination amount

If that's not your flavour you can also setup alternate templates, each with different pagination amounts set. You can then use the ?view= querystring parameter to call up the specific template.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Tourist
22 0 1

What is the ?view= querystring parameter? and how can it help me achieve what I need?

0 Likes
Shopify Expert
9718 43 1377

Check out the alternative template docs. 
https://help.shopify.com/themes/customization/store/create-alternate-templates

You could make a series of different templates with different pagination settings hard coded in.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes