Jump to content
Sign in to follow this  
Robando

Out of stock items not hidden

Recommended Posts

Hi all,

I have a few out of stock products on my store that I do not want to be displayed. I have gone to settings > store settings > stock and checked Hide out-of-stock product but the items are still displayed. 

Am I right in thinking this setting should hide out of stock products?

 

I've found a solution I cleared my browsers cache and the out of stock items are no longer displayed :rolleyes:

Edited by Robando

Share this post


Link to post
Share on other sites

Be aware that "Hide out-of-stock product" has a condition - it's mentioned next to the checkbox - that if you are logged in as an admin, even if viewing the storefront as a signed-in customer, you will see some things that would normally be hidden.

 

Edited by bsmither

Share this post


Link to post
Share on other sites

Thank you for pointing that out.

I have quite a lot of products that go out of stock. Would it be better to hide products out of stock or not? 

Share this post


Link to post
Share on other sites

Depends on your business model. Do you want customers to know that you have/had these items, or are they so prevalent that if you don't have these products for immediate fulfillment, you would rather they go elsewhere instead of you getting more from your supplier?

Share this post


Link to post
Share on other sites

this must affect google shopping submissions though? as the product  page is not visable when you enter it manually either

Share this post


Link to post
Share on other sites

One issue with hiding out of stock products, is that they effectively no longer exist.

As far as your customer is concerened, you do not stock this item.

We prefer to mark it 'Out of Stock', at least then, our customers know that it does exist, and that we are currently out of stock.

Whilst it doesn't solve the issue of a lost sale, it does mean the customer may come back at some point in the future.

Share this post


Link to post
Share on other sites

If you submit the items to google merchant and you haven't updated your feed, you'll get item disapprovals which take a few days to clear when the item is In stock again.

It's really up to your self, if it's long term out of stock, you can hide it then update your feed, to prevent disapproval 

Share this post


Link to post
Share on other sites

Should Hide out-of-stock work when searching with search terms?  We imported thousands of products that we may eventually carry at one point and just want to add stock when/if we get it.  Otherwise we want it to appears we DO NOT have it (stock it).   Hide seems to work when browsing by category, but if I search I get hundreds of out of stock listings.  And yes, Hide is checked, and the Use Stock level is checked for both product default and options matrix.  Do I misunderstand the feature.  fyi.. just upgraded to 6.2.5 - same result.

Edited by warpsor
typos / clarifications

Share this post


Link to post
Share on other sites

Welcome warpsor! Glad to see you made it to the forums.

There is an issue with this:
https://github.com/cubecart/v6/issues/2279
https://forums.cubecart.com/topic/54251-list-all-products-link-is-this-possible/

The (advanced) Search page allows to filter for in-stock items only. Otherwise, a search will find everything (which I disagree with).

The most effective way to hide out-of-stock items from a search is to assign these items to a primary category that has its status as unchecked.

 

Edited by bsmither

Share this post


Link to post
Share on other sites

Thanks for the quick reply.  Ugh...  Our categories are also set several levels deep 😕 That would be a huge project.  I could just query the database and fix it, but do you suppose there would be any benefit in recreating our entire hierarchy under an "unchecked" category so we don't loose the work we did putting them where they go? Or is there a better way you could suggest?

Share this post


Link to post
Share on other sites

All the sub-categories are not the same as the item's primary category. So, even if Cat-D of A/B/C/D is the primary, setting Cat-A to disabled is not a solution.

I suggest an edit to the code. I will have to examine CC625 to see if the issue has been resolved in some way, and if not, we will have to deal with that as well.

The edit is to enforce a filter to drop out-of-stock items from the search results.

Let us know when you are ready to experiment with a code edit.

Share this post


Link to post
Share on other sites

Ready yesterday!  Bring it on!  I was about to start digging... I am good with a hard-coded default of in-stock only results.  By the way, I don't have an in-stock only check box in my advanced search... only the stock high-low/low-high dropdown option. Did I misunderstand? 

Share this post


Link to post
Share on other sites

it would appear the $OUT_OF_STOCK value is not as expected... in content.search.php so it doesn't display

   {if !isset($OUT_OF_STOCK)}
   <div class="row">
      <div class="small-8 columns"><input type="checkbox" name="search[inStock]" id="in_stock" value="1"><label for="in_stock">{$LANG.search.i$
   </div>
   {/if}

 

Share this post


Link to post
Share on other sites

Yes, in admin, Store Settings, Stock tab, if "Hide out-of-stock product" is not checked, then this search filter selection gets displayed. (See CubeCart->_search().)

In the file /classes/catalogue.class.php, near lines 1838-1841:

Find:

            // Only look for items that are in stock
            if (isset($search_data['inStock'])) {
                $where[] = $this->outOfStockWhere();
            }

Change to:

            // Only look for items that are in stock
            if (true || isset($search_data['inStock'])) { // Force in-stock-only (admin sees all)
                $where[] = $this->outOfStockWhere(); // May cause problems in search - other edits probable
            }

 

Edited by bsmither

Share this post


Link to post
Share on other sites

Ok, so I have to turn off hide in order to "hide" them in the search?  DOH! 

image.png.469d26def137200a193bf436d2521f2d.png

Confirmed!  Unchecking it makes the chechbox appear, but something is still not right.

Checking the In Stock only results in nothing found.

Using the sort by stock high-low without the in stock button returns dozens of in-stock results.

Of course, searching by category now shows all the out-of-stock items.

So my concern with a mod is that even if I force the In-stock only for all searches I will get no results regardless of whether or not I have the Hide out-of-stock set in admin.

Share this post


Link to post
Share on other sites

"If I force the In-stock only for all searches I will get no results regardless of whether or not I have the Hide out-of-stock set in admin."

True, as was hinted at earlier.

Refresh this forums page as I added more content to my previous post (which won't show unless page is refreshed.)

Edited by bsmither

Share this post


Link to post
Share on other sites

Right. The next edit is to fix the issue posted in the Github. Working on that now.

 

Share this post


Link to post
Share on other sites

Don't know if this helps, but until you can find a not-so-hacky fix..

I tweaked your code above like this

            // Only look for items that are in stock
            if (true || isset($search_data['inStock'])) { // Force in-stock-only (admin sees all)
                $where[] = str_replace("CubeCart_inventory","I",$this->outOfStockWhere()); // May cause problems in search - other edits probab
le
            }

appears the alias I is required in the where clause

and I stripped out the extra AND when it's concatenated  (super hacky)

    public function outOfStockWhere($original = false, $label = false, $force = false)
    {
        $def = $original ? str_replace('WHERE ', '', $GLOBALS['db']->where('CubeCart_inventory', $original, $label)) : '';
// Changed this
        //$def .= $this->_where_live_from;
// to
        $def .= str_replace("AND","",$this->_where_live_from);

Now it works!  I get only in stock products when searching and I have hide out-of-stock checked!

spoke too soon... it did fix that searching but broke category browsing... never mind 😕

Share this post


Link to post
Share on other sites

Can't effectively muck about with outOfStockWhere(). Too many other places use it.

Working on the "unknown column" error that just manifested.

Share this post


Link to post
Share on other sites

If it's what I hit, it's the fact that the aliased name needs to be used instead of the CubeCart_inventory reference

 

SELECT I.*, MATCH (I.product_code,I.description,I.name) 
AGAINST('criteria' IN BOOLEAN MODE) AS Relevance 
FROM CubeCart_inventory AS I 
LEFT JOIN (
	SELECT product_id, MAX(price) as price, MAX(sale_price) as sale_price 
    FROM CubeCart_pricing_group 
    WHERE group_id = 0 
    GROUP BY product_id) as G ON G.product_id = I.product_id  
WHERE I.product_id IN (
		SELECT product_id FROM `CubeCart_category_index` as CI 
		INNER JOIN CubeCart_category as C 
		where CI.cat_id = C.cat_id AND C.status = 1) 
	AND I.status = 1 
    AND (MATCH (I.product_code,I.description,I.name) AGAINST('criteria' IN BOOLEAN MODE)) >= 0.5  
    AND  `live_from` < UNIX_TIMESTAMP()  
    AND (
      -- switch to I alias below
		(I.stock_level > 0 AND I.use_stock_level = 1) 
		OR I.use_stock_level = 0) 
        AND `live_from` < UNIX_TIMESTAMP()  ORDER BY `Relevance` DESC LIMIT 12 OFFSET 0;

this works and returns results for me.

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.

Sign in to follow this  

×
×
  • Create New...