Jump to content
Robando

Out of stock items not hidden

Recommended Posts

Posted (edited)

Please make this edit. In /classes/catalogue.class.php:

Lines 1835-1849:
From:
            if (isset($search_data['featured'])) {
                $where[] = "I.featured = '1'";
            }
            // Only look for items that are in stock
            if (isset($search_data['inStock'])) {
                $where[] = $this->outOfStockWhere();
            }

            $whereString = (isset($where) && is_array($where)) ? implode(' AND ', $where) : '';
            if (!empty($whereString)) {
                $whereString = ' AND '.$whereString;
            }
            $whereString .= $this->_where_live_from;

            $joinString = (isset($joins) && is_array($joins)) ? implode(' JOIN ', $joins) : '';


To:
            if (isset($search_data['featured'])) {
                $where[] = "I.featured = '1'";
            }

            $whereString = (isset($where) && is_array($where)) ? implode(' AND ', $where) : '';

            // Only look for items that are in stock
            if (true || isset($search_data['inStock'])) { // Forcing a filter for only in-stock items. Includes _where_live_from.
                $whereString .= $this->outOfStockWhere(false,'I'); // BUG!! Using this method at this location requires using the table alias.
            } else {
                $whereString .= $this->_where_live_from; // Adding the _where_live_from to the $whereString.
            }
            if (!empty($whereString)) {
                $whereString = ' AND '.$whereString;
                $whereString = str_replace('AND  AND', 'AND', $whereString); // Hack to kill double verb from empty $where[] causing _where_live_from being first. Note two spaces between verbs.
            }

            $joinString = (isset($joins) && is_array($joins)) ? implode(' JOIN ', $joins) : '';

 

Edited by bsmither
  • Thanks 1

Share this post


Link to post
Share on other sites

looks as though there are some missing braces. Please confirm...

 if (isset($search_data['featured']))  { //<- here
                                              
...

                                              
} else {
$whereString .= $this->_where_live_from; // Adding the _where_live_from to the $whereString.
} //<- and here

With these changes, It appeaars to be working. NOTE to anyone else... copying and pasting this code made the double space between ANDs go away.

Share this post


Link to post
Share on other sites

Thanks for catching that. Fixed.

(I added diagnostic code which, if the reporting function is missing, will cause a fatal error. In deleting that code prior to posting, I sometimes delete too much. I really must double check that.)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...