Show On Stock products only by default?

  • Is there a reasoning why TB (actually PS and transfered to TB) made it so that products that are not on stock are shown by default on stores?

    I am not sure if I am the only one but wouldnt most merchants want to show only products on stock by default?

    Maybe some day we could have an option in settings to “Show only products on stock” by default instead of hacking our way into the .tpl file or using cron jobs for this simple task. Or is it just me?

  • If we did this at render time, so to say, I guess it would require a SQL query per displayed/requested product to check the stock quantities.

    I that’s true, wouldn’t that be inefficient?

  • Well… when you load the product.tpl page you already have an array of the products.

    Thats how I hack this issue at the moment, I go to the .tpl and if the product has 1 or more then it shows it otherwise it doesnt… I am sure you dont require any additional queries because I certainly dont need to add one to achieve it.

  • But if you do it at product.tpl, what will you display then?

  • @moy2010 I only display products that are on stock.

    If it has 0 stock the template simply ignores it.

  • Yes, but what I mean is, do you display a blank page when a user clicks on a product with 0 stock?

  • If I have a product that is out of stock, but I am going to re-stock it, then I like to still show it, that way people can ask about it, or put it in their wish lists. If I am not going to restock it, then I disable it, or delete it from my database.

  • @moy2010 no…

    Say you click a category and there are 25 products… If 5 products are out of stock I want the page to just show the 20 that are on stock.

    @slick_303 yes I get that situation. In my case I would rather not spend time answering customers regarding items that are not available because I can’t restock that easily.

    As soon as it is out of stock I don’t show it… When I have it available again then I let the store show it again.

  • Got it. If the product page was indexed by Google and it appears on search results, do you display the product page it a user clicks on it?

    I guess that your approach is useful for unique or rare products that cannot be easily found elsewhere.

  • @moy2010 said in Show On Stock products only by default?:

    If the product page was indexed by Google and it appears on search results, do you display the product page it a user clicks on it?

    That’s something I didn’t think about. I dont mind them clicking and seeing the product that way since they wont be able to add it to the cart.

    The issue is that I tell my customers “The page only shows what is available” becasue they ask OVER and OVER again “Whats available today?”

    I think my situation is not very common since the type of store I run has completely new products every months or so, and products I sold this month will not come back (probably ever). That’s due to the kind of suppliers I have here in this country. I am really restricted on that topic tbh.

    I am trying to fix that Importing goods directly from china but Importing to Dominican Republic is a royal pain in every sense.

  • it can be done with MySQL trigger, I’ve using this method and works great. Open your phpMyAdmin > click your database > go to triggers (between events & designer tab) > and add trigger

    Trigger name: change_visibility_after_update
    Table: ps_stock_available
    Time: After
    Event: UPDATE

    UPDATE ps_product_shop SET visibility="none" WHERE id_product IN (SELECT id_product FROM ps_stock_available WHERE quantity=0);
    UPDATE ps_product_shop SET visibility="both" WHERE id_product IN (SELECT id_product FROM ps_stock_available WHERE quantity>0);

    Definer: just leave it blank

    the result will looks like this
    0_1516544083316_Screenshot from 2018-01-21 21-14-24.png

    source: vekia

  • Great tip, thanks! I guess this could be modified to change the default combination instead of visibility. I’ll look into it.

  • How easy would it be to create a ‘In Stock’ tab similar to ‘Best Sellers’ and ‘New Products’ (that shows up if there are some actually)?

    I would love to move such a tab to be the first - that way a user sees only the in stock ones by default and can move to other tabs to see all products.
    I guess it is safe from a google indexing perspective as well.

    Thoughts please?

  • @chandra I think no need for that, try MySQL trigger method from my post above, your shop will hide out of stock products from catalog and search (not disable the produtcs), so someone still can access the products using direct url including traffic from google seo or social media share link.

  • @dosbiner
    Thanks. But I would like the catalog and search to have the products available. I just want to highlight the in stock ones, so it is easier for the customer to order.

  • @chandra you could create a dedicated category for Products on stock and update the trigger above to associate / dissociate products to this category.

    Then you could configure Featured products on the homepage module to show this category.

    Alternative is to modify the source code of that module.

  • @datakick
    Seems a good idea, thank you.
    Let me try a trigger to update products in home category.

  • @chandra let me know if you need any help with that

  • @datakick said in Show On Stock products only by default?:

    @chandra let me know if you need any help with that

    Will do.
    You are too good, this and the review module!

Log in to reply

Looks like your connection to thirty bees forum was lost, please wait while we try to reconnect.