| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Let Customer choose number of products displayed on page | ||||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Let Customer choose number of products displayed on page
I have had a long look through existing messages and haven't come across anyone who's done this before or asked about how to do it.
I was hoping to include a drop down menu, added to the 'Sort by' options across the top of a page of products, allowing the customer to select the number of products the page is showing. This is currently an admin setting. How could I go about keeping the admin setting as the default, but allowing the user to choose to display a higher or lower number of products on the page, depending on the way they like to view products and the speed of their connection? For example: Products per page: 10 20 30 50 75 100 All I guess the other consideration would be would how the option would work if the user is not logged in and how it would work for logged in users. For users not logged in, the preference lasts for the duration of the session. If they are logged in, perhaps that preference is retained... or maybe that would be too complicated... Anyone with any ideas about what template changes to make to implement this?
__________________
X Cart Pro v. 4.1.9 Download Expander (from Altered Cart) X-Magnifier Dynamic Preview (from BCS Engineering) Customer Rewards Points (BCSE), used as credit purchasing system |
|||||||
#2
|
|||||||||
|
|||||||||
Re: Let Customer choose number of products displayed on page
Yes, you can do it.
First of all you should create file in root dir called "change_ppp.php" with this code: File "change_ppp.php": Code:
Next step: include into "auth.php" before end of file (?>) Code:
Next step: include into /skin1/customer/main/products.tpl Code:
after Code:
This modification allows customer to select products per page and selected value will stored in session variable. You can change this code as you want. I've checked this code and sure he works correctly.
__________________
Regards, Anthony Holub X-Cart Skins Store - twenty two different skins available; - both 4.1.x and 4.2.x versions compatible; - refresh you store now! Smart menu X-Cart add-on Featured Products Slide Show X-Cart add-on "What's New?" FREE X-Cart add-on |
|||||||||
#3
|
|||||||
|
|||||||
Re: Let Customer choose number of products displayed on page
Many thanks for the prompt reply Holub!... It's 1am here and I'm probably better to implement with a clear mind on a good night's sleep - looking forward to trying it first thing in the morning... thanks again.
__________________
X Cart Pro v. 4.1.9 Download Expander (from Altered Cart) X-Magnifier Dynamic Preview (from BCS Engineering) Customer Rewards Points (BCSE), used as credit purchasing system |
|||||||
#4
|
|||||||||
|
|||||||||
Re: Let Customer choose number of products displayed on page
If you have any questions or problems then feel free to ask any questions or information. I'm glad to help you.
__________________
Regards, Anthony Holub X-Cart Skins Store - twenty two different skins available; - both 4.1.x and 4.2.x versions compatible; - refresh you store now! Smart menu X-Cart add-on Featured Products Slide Show X-Cart add-on "What's New?" FREE X-Cart add-on |
|||||||||
#5
|
|||||||
|
|||||||
Re: Let Customer choose number of products displayed on page
Will do, thanks and goodnight
__________________
X Cart Pro v. 4.1.9 Download Expander (from Altered Cart) X-Magnifier Dynamic Preview (from BCS Engineering) Customer Rewards Points (BCSE), used as credit purchasing system |
|||||||
#6
|
|||||||
|
|||||||
Re: Let Customer choose number of products displayed on page
It's a beautiful thing... Many thanks Holub.
I ended up placing it in /main/search_sort_by.tpl as I just wanted it to apply alongside the other sort by features, rather than having it on the featured products on the home page as well. I applied a little bit of styling and it's perfect. For anyone else wanting to do the same, here's my /main/search_sort_by.tpl: Code:
Oh and for others wanting to implement Holub's solution here, you may have to resolve the path that points to change_ppp.php if your shop is in a subdirectory of your main domain name, as I did... For Example: action="/yourshopdirectory/change_ppp.php"
__________________
X Cart Pro v. 4.1.9 Download Expander (from Altered Cart) X-Magnifier Dynamic Preview (from BCS Engineering) Customer Rewards Points (BCSE), used as credit purchasing system |
|||||||
#7
|
|||||||||
|
|||||||||
Re: Let Customer choose number of products displayed on page
To err on the side of caution in preventing sql injection, I would modify change_ppp.php and:
FIND: Code:
CHANGE TO: Code:
FIND: Code:
|
|||||||||
#8
|
|||||||||
|
|||||||||
Re: Let Customer choose number of products displayed on page
In version 4.1.9 (as minimum) the auth.php file included in change_ppp.php will protect any POST variables from sql injection. However, God helps those who help themselves
Use for pleasure!
__________________
Regards, Anthony Holub X-Cart Skins Store - twenty two different skins available; - both 4.1.x and 4.2.x versions compatible; - refresh you store now! Smart menu X-Cart add-on Featured Products Slide Show X-Cart add-on "What's New?" FREE X-Cart add-on |
|||||||||
#9
|
|||||||
|
|||||||
Re: Let Customer choose number of products displayed on page
Thanks to you both - I've implemented Jon's suggestion anyway and done some reading up on SQL injection.
__________________
X Cart Pro v. 4.1.9 Download Expander (from Altered Cart) X-Magnifier Dynamic Preview (from BCS Engineering) Customer Rewards Points (BCSE), used as credit purchasing system |
|||||||
#10
|
|||||||||
|
|||||||||
Re: Let Customer choose number of products displayed on page
EDIT: $products_per_page however could possibly be specified from an external post.
I didn't go through the x-cart code to see if the query checks this variable prior to use or assumes it is safe because it usually comes from the config, but I figure better safe than sorry |
|||||||||
|
|||
X-Cart forums © 2001-2020
|