Previous and Next Links in Product Info Page

By | March 27, 2013

Someone messaged me with the need for a “previous” and “next” link in product_info.php, which links to the previous and next product within the same category.

Needs

1. If there is only 1 product in the category: do not show next link, do not show previous link
2. If the viewer is looking at the 1st product in the category: do not show previous link
3. If the viewer is looking at the last product in the category: do not show next link
4. For previous and next links, show the product name

There are a couple of contributions that can do some of this [1] [2]. Both of these are coded poorly, so it is time to come up with something new.

A. Grab the other products in the category being looked at.
B. Pass these into an array
C. Use array functions to grab the array entries either side of the current item
D. Pass those entries into jqueryui buttons and mine the products name

It ended up like this

20130327-1

And in action

Need something similar? Email me, and you can have this for a beer fee.

One thought on “Previous and Next Links in Product Info Page

  1. John

    Good post on this. I especially like the product names in the buttons. I did something like this a few years ago on my product pages. When you look at the first product you can still hit the previous button and it will circle to the end of the “list”. Same thing when you are on the last product. An example is below:

    http://pcforms.com/peel-shipping-label-sheets-p-79.html

Leave a Reply

Your email address will not be published.