Forums / General Questions / Hide sold out products from category listings and search without disabling product.

Hide sold out products from category listings and search without disabling product.

Views: 6,202

Results 1 to 17 of 17
5 Jan 2011, 6:02 PM
#1
illum avatar

illum

New Zenner

Join Date:
Jan 2008
Posts:
25
Plugin Contributions:
0

Hide sold out products from category listings and search without disabling product.

I have products that are completely discontinued, that I will probably never sell again and they have 0 quantity in stock, the shopping cart button says sold out... all of this is fine, however...

I don't want them to show up under the category listing and searches performed by zencart as it clutters the products I do have in stock. I know I could just disable the product, which I would love to but it makes the link to the product no longer work.

I would like search engines and other links which point back to a product on the site to be able to see a discontinued product if the exact url is used. I just do not want discontinued products to show up unless that is the case, is this possible to do?

5 Jan 2011, 7:17 PM
#3
illum avatar

illum

New Zenner

Join Date:
Jan 2008
Posts:
25
Plugin Contributions:
0

Re: Hide sold out products from category listings and search without disabling product.

kobra:

See the posts by Ajeh here
http://www.zen-cart.com/forum/showthread.php?t=102712&highlight=disable+stock

Ready through that whole thread, I figured all that out already. ZenCart allows you to show a product which is out of stock by setting the configuration that shows the soldout button instead of add to cart button if quantity = 0.

Since I don't want to see all those sold outs on the category listing/search pages I also have the option to set the product_status = 0, either through the stock configuration or manually through the edit product view. Which hides all products on the frontend of the website.

That's all find and dandy, exactly how I want it in fact, however there is one instance that I want the products to show up. And that is if you manually go the the exact url of the product. Then I want the product to show the out of stock page.

This is so search engines that already have links to the product and other websites that linked to it in the past don't get a product not found page, rather they get a product out of stock page. In other words I don't want links which used to work to no longer work anymore. (broken links)

Just wondering if I will have to hack Zen Cart to do this, or if there is another way? Cause the only thing that I can think of is changing some of the queries to not pull products with quantities of 0 or less. Or writing a custom configuration, will have to dig through you code to see how this is done.

5 Jan 2011, 9:42 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Hide sold out products from category listings and search without disabling product.

Edit the file:
/includes/index_filters/default_filter.php

and add the code around line 27 that is in red above the code in black:

[B]  $alpha_sort .= " and p.products_quantity > 0 ";[/B]
  if (!isset($select_column_list)) $select_column_list = "";

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

5 Jan 2011, 10:32 PM
#5
illum avatar

illum

New Zenner

Join Date:
Jan 2008
Posts:
25
Plugin Contributions:
0

Re: Hide sold out products from category listings and search without disabling product.

Ajeh:

Edit the file:
/includes/index_filters/default_filter.php

and add the code around line 27 that is in red above the code in black:

[B] $alpha_sort .= " and p.products_quantity > 0 ";[/B]
if (!isset($select_column_list)) $select_column_list = "";


Did exactly what I wanted, thanks!
5 Jan 2011, 11:00 PM
#6
illum avatar

illum

New Zenner

Join Date:
Jan 2008
Posts:
25
Plugin Contributions:
0

Re: Hide sold out products from category listings and search without disabling product.

Do you know the path of the file that I need to edit to add to the 'p.products_quantity > 0' to the search query?

6 Jan 2011, 4:42 AM
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Hide sold out products from category listings and search without disabling product.

I gave you the exact location of that file ...

Look at your site and you will find the file in that location ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

6 Jan 2011, 10:44 AM
#8
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Hide sold out products from category listings and search without disabling product.

Ajeh:

Edit the file:
/includes/index_filters/default_filter.php

and add the code around line 27 that is in red above the code in black:

[B] $alpha_sort .= " and p.products_quantity > 0 ";[/B]
if (!isset($select_column_list)) $select_column_list = "";


Nice one Ajeh! Thanks a lot :smile: - that code should be a permanent one in all installs for SE purposes ...

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

6 Jan 2011, 2:13 PM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Hide sold out products from category listings and search without disabling product.

Thanks for the update that this is now working for you ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

30 Jan 2011, 4:20 PM
#10
brewtusplease avatar

brewtusplease

New Zenner

Join Date:
Nov 2010
Posts:
20
Plugin Contributions:
0

Re: Hide sold out products from category listings and search without disabling product.

Hi Ajeh,

Nice job! I applied this as a test for my products and it works like a charm. I will not be able to use it on my site as there are some products that I do still want to show as a Sold Out...ones that I am still replenishing stock on and want the customers to see that I still carry it. And that's ok...I'll carry on as I currently am.

The only reason I mention this is that it might be a good future addition to the software to add some flexibility to a feature like this, even if it was embedded as an option for each product id. For example, we decided to sell watches during the fall on a limited basis. We now have the remaining watches on Clearance and do not plan to re-order them. I still want the links through the search engines to show 'Sold Out' and want the menu filter to not show them anymore. But I do have a purse that I also sold out of, but will be receiving new shipments soon. I have customers that search for this type of purse and I want it to appear within the menu even when 'Sold Out' so they know I offer the product.

If you can think of possibilities around this, great! Certainly not a priority, just a thought...
Thanks for the help.

1 Mar 2011, 11:52 PM
#11
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Hide sold out products from category listings and search without disabling product.

Ajeh:

Edit the file:
/includes/index_filters/default_filter.php

and add the code around line 27 that is in red above the code in black:

[B] $alpha_sort .= " and p.products_quantity > 0 ";[/B]
if (!isset($select_column_list)) $select_column_list = "";


I noticed that when using the Filter by Manufacturer or Alpha sorter, that products with >0 re-appear in the product listing, any quick fixes to this?

Thanks
2 Mar 2011, 7:22 AM
#12
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Hide sold out products from category listings and search without disabling product.

disregard, my mistake, I forgot to save file before refreshing page.

16 Sep 2012, 12:11 PM
#13
ricangem avatar

ricangem

Zen Follower

Join Date:
Dec 2010
Posts:
138
Plugin Contributions:
0

Re: Hide sold out products from category listings and search without disabling product.

@Ajeh, Pardon me for asking but is this technique safe to do, since the products will no longer be displayed on the site, but will still show on search engines?

16 Sep 2012, 1:25 PM
#14
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Hide sold out products from category listings and search without disabling product.

This hides it from the Categories listings ... not from anything else ...

Test it out and you should not see it when navigating the Categories listing, but you will see it in the sideboxes and centerboxes and New Products listing (if new) and All Products listing and Specials listing (if on special) and Featured listing (if a featured product) ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

16 Sep 2012, 1:39 PM
#15
ricangem avatar

ricangem

Zen Follower

Join Date:
Dec 2010
Posts:
138
Plugin Contributions:
0

Re: Hide sold out products from category listings and search without disabling product.

Your right. I tested it on my site and they still appear on the sideboxes. I was worried the website would get penalized if the out of stock items weren't showing on the site but on the search engines. I guess it wouldn't get penalized. Thanks Ajeh. :smile:

16 Sep 2012, 3:45 PM
#16
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Hide sold out products from category listings and search without disabling product.

NOTE: the spiders are seeing just what you are on this as nothing is masked with css but actually either there or not there based on the code change ... and spiders can only see what is actually there ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!