Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Number of products on Product Listing


gatzo

Recommended Posts

Posted

I had a look for a contrib for this but couldn't find any:

 

On product listing I want to enable the customer/visitor to select form a dropdown menu how many products to show on each page. This is currently set for all customers in the admin, but I would like each customer to be able to select their prefered number of products to list.

 

Does anyone know of a module for this?

Posted

Nothing that I know of. That would not be tht complex to do, if the info is not to be saved with the customers "profile". If you want to save this info, then it gets more complex.

 

By changing the define (found in the configuration table) value being used to have some logic where the customers custom value is used if set (save it as a session variable) or default to the system default. if the custom is not set will do the trick.

 

cheers,

Peter M

Peter McGrath

-----------------------------

See my Profile (click here) for more information and to contact me for professional osCommerce support that includes SEO development, custom development and security implementation

Posted

Thx for your reply!

Saving it as a session variable sounds like a good solution. No need to save it to the customer's profile.

 

I'm a unsure how to go about it, though. How do I save the selected option as a session variable?

Posted

create a form for the customer to add in the custom value. do this via a POST or GET.

 

Save this info using something like this:

 

 

 

	if (!tep_session_is_registered('custom_list_display')) {
  $custom_list_display = $_POST['custom_list_display'];  
  // change above to $_GET['custom_list_display'];  if using GET method
  tep_session_register('custom_list_display');
}

 

 

This will set the session variable $custom_list_display to use the custom value, then you will need to add in the logic to check if it is set and not NULL if so use it, else use the default define.

 

cheers,

Peter M

Peter McGrath

-----------------------------

See my Profile (click here) for more information and to contact me for professional osCommerce support that includes SEO development, custom development and security implementation

Posted

Looks to be working - Only thing missing is, I'm not sure how to get the page reloaded (and the value POST'ed). I placed the code in the modules/product_listing.php and in the form I do method=post but how do I set the action to the current URL (including the sID) so it can be used by $_POST['custom_list_display']; after the reload?

 

If you could point me in the right direction I'd be very grateful (again).

Posted

use in the form you set up, instead of a page URL use this instead:

 

tep_href_link(basename($PHP_SELF)

 

to maintain all of the GET data you need only add this to the function:

 

tep_href_link(basename($PHP_SELF, tep_get_all_get_params())

 

this will return the user after the form submission to the same page and maintain the GET data. Be careful, as some GET info may effect other areas so this should be tested well...

 

cheers,

Peter M.

Peter McGrath

-----------------------------

See my Profile (click here) for more information and to contact me for professional osCommerce support that includes SEO development, custom development and security implementation

Posted

Yes, thank you. I should've known to use that!

However, that does not seem to include the category part of the url:

/index.php?cPath=50_252&osCsid=a082mjolfcfubhuhnrt9upudv0

 

It only returns:

/index.php?osCsid=a082mjolfcfubhuhnrt9upudv0

so sends me back to main page instead of showing the current category with less/more products in the listing.

 

I must be missing something?! I can't see why it is not included :(

I have tried with and without the tep_get_all_get_params() included.

Posted

Not sure, never tried this. I have not looked at the function in a long time. If there is an issue and all you really want to return is the cPath, then add it manually.

 

 

Just use this instead then:

 

if(isset($cPath) && tep_not_null($cPath)){
tep_href_link(basename($PHP_SELF, 'cPath=' . $cPath));
}else{
tep_href_link(basename($PHP_SELF, tep_get_all_get_params());
}

 

cheers,

Peter M.

Peter McGrath

-----------------------------

See my Profile (click here) for more information and to contact me for professional osCommerce support that includes SEO development, custom development and security implementation

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...