Forums / Templates, Stylesheets, Page Layout / Sold-Out products to bottom of the page automatically

Sold-Out products to bottom of the page automatically

Started by pricediscrimination on 16 Jun 2016, 11:43 PM · Views: 809

Results 1 to 4 of 4
16 Jun 2016, 11:43 PM
#1
pricediscrimination avatar

pricediscrimination

Zen Follower

Join Date:
May 2008
Posts:
401
Plugin Contributions:
0

Sold-Out products to bottom of the page automatically

Hello, doesn't anyone happen to know of the possibility to make sold-out products automatically be sorted to the bottom of the product list? It's not convenient to have to set a sort order for thousands of products, but they should still be displayed in the product listing, just not in between in stock items. Any advice would be terrific. Thank you!

16 Jun 2016, 11:47 PM
#2
pricediscrimination avatar

pricediscrimination

Zen Follower

Join Date:
May 2008
Posts:
401
Plugin Contributions:
0

Re: Sold-Out products to bottom of the page automatically

Going one step further, as desired is the ability to separate the sold-out items from the in-stock items. With a title above the break "Sold Out Items". Right now, all setting the sort order does is moves them to the end of the list. Also impossible to do with so many items.

17 Jun 2016, 12:52 AM
#3
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Sold-Out products to bottom of the page automatically

There are utilities that can make changing the sort order simple(r). For example EasyPopulate V4 could be used setting the primary key as products_id, could export your product (by category if so desired), open the file, then for filter the product by quantity, then using the max() function identify the highest sort order currently applied, add a little to the first of the 0 quantity and number the sort order in some reasonable increment using a function (=row above+10 for example), save the file upload/import and that takes care of the first issue. The second well, depends on if you want a sold out product to show at all with non-sold out or if it has to exist starting on its own page, but thinking could review the returned data from the page split function and if a sold out product existed then to display your "above the fold" info.

Just a thought, otherwise, could create some other "field" to use and then could add it to the list of sortable fields and filter product by that on default.

A third option to have a sold-out section off of your main category so that the product there can be "viewed" (I know not exactly desirable but possible).

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

26 Jun 2016, 10:06 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Sold-Out products to bottom of the page automatically

In v1.5.x /includes/index_filters/default_filter.php is where the query is built to retrieve product-listing data.

You could add changes there, or perhaps simply just add an observer to fire when an appropriate notifier hook is triggered, to apply your filter.

(ie: first might be to change the order-by to make "products_status desc" be the first order-by clause; 2nd enhancement could be to let the visitor apply a filter and then you could check $_GET or $_POST to see if that filter has been set, and then instead of changing order-by you'd add a "where" clause for products_status = 1 for only-enabled, or make no change to "where" if the filter doesn't need to exclude sold-out items)

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.