Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2004
    Posts
    762
    Plugin Contributions
    0

    Default How to hide Out Of Stock products?

    What file would we need to edit in order to not return/display any products that don't have any stock when you click a category?

    I tried to edit the header in includes/modules/pages/search_result, by doing the following:

    $where_str = " WHERE (p.products_status = 1
    AND p.products_quantity > 0 <--------------ADDED THIS
    AND p.products_id = pd.products_id
    AND pd.language_id = :languagesID
    AND p.products_id = p2c.products_id
    AND p2c.categories_id = c.categories_id ";

    However, that doesn't appear to do anything. When I click a category, I am still seeing products load which are out of stock.
    - Jeff

  2. #2
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,684
    Plugin Contributions
    123

    Default Re: How to hide Out Of Stock products?

    Rather than edit the code, just use the built-in stock management settings that get you what you want.

    Track stock, disallow backorders, set status when out of stock to 0.

    https://docs.zen-cart.com/user/running/stock/

    Then use Install SQL Patches to set products whose quantity is 0 to disabled. (Moving forward, this will be automatic, but you have to deal with ones you haven't disabled yet that are out of stock.)
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  3. #3
    Join Date
    Aug 2004
    Posts
    762
    Plugin Contributions
    0

    Default Re: How to hide Out Of Stock products?

    Quote Originally Posted by swguy View Post
    Rather than edit the code, just use the built-in stock management settings that get you what you want.

    Track stock, disallow backorders, set status when out of stock to 0.

    https://docs.zen-cart.com/user/running/stock/

    Then use Install SQL Patches to set products whose quantity is 0 to disabled. (Moving forward, this will be automatic, but you have to deal with ones you haven't disabled yet that are out of stock.)
    Scott - the issue is that I also use the CEON Back In Stock Notifications plugin, so I DO want out of stock items to show up under actual search queries (so that people can sign up for in stock notifications). However, I don't want them to show if looking under the categories, new products, featured products, etc. Those should only display available products (quantity > 0).

    I do have it configured this way on my current 1.5.7 site. OOS items are NOT disabled (but they will not show up if browsing through categories). However, if you use the search bar and type in the OOS product by name, it WILL show up (and still show up if anyone comes to our website through a direct link).

    Simply put: I don't want the product to be disabled/hidden from being directly visited by a link. I just don't want people to be inundated by a ton of out of stock links when they are looking through categories.

    So ideally speaking, I wanted to just edit the SQL SELECT statement when it queries for product listings to only return results if products_quantity > 0. I just don't see where to edit that in the 1.5.8 code. Can you point me in the right direction?
    Last edited by Jeff_Mash; 24 Mar 2023 at 07:07 PM.
    - Jeff

  4. #4
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,684
    Plugin Contributions
    123

    Default Re: How to hide Out Of Stock products?

    The file you were editing is only relevant for product searches. It doesn't change the behavior of the category listing page.
    It sounds like you don't want to change the search page, just the other pages.

    You can change the category listing page (and all products, featured products, new products) but each one is a separate modification.

    Category listing page: modify includes/index_filters/default_filter.php

    Featured listing page: modify includes/modules/pages/featured_products/header_php.php
    (all products, new products - same file in folders includes/modules/pages/products_all and products_new.)
    Note that bootstrap has replacements for these files.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  5. #5
    Join Date
    Aug 2004
    Posts
    762
    Plugin Contributions
    0

    Default Re: How to hide Out Of Stock products?

    Quote Originally Posted by swguy View Post
    Category listing page: modify includes/index_filters/default_filter.php
    YES! Thanks, that was it! I had that modified in my previous 1.5.7 store, but for some reason, I missed it on my WinMerge file checking when porting over my changes.

    I modified that file in a few places and now, it will NOT display out of stock items when browsing through product listings......however, it WILL still pull up the out of stock items if someone uses the Search Bar (or goes directly to a link to it). Exactly what I wanted. Thanks again!
    - Jeff

 

 

Similar Threads

  1. Hide out of stock products from advanced search
    By solo_400 in forum Basic Configuration
    Replies: 4
    Last Post: 28 Mar 2013, 06:08 PM
  2. Replies: 0
    Last Post: 16 Nov 2012, 04:36 PM
  3. Show but hide out of stock products
    By gmrm in forum General Questions
    Replies: 2
    Last Post: 17 Apr 2011, 10:53 PM
  4. hide products out of stock
    By balihr in forum Setting Up Categories, Products, Attributes
    Replies: 6
    Last Post: 18 Jun 2010, 10:45 PM
  5. Hide Out of Stock Products
    By ryanb4614 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 10 Feb 2010, 04:11 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR