Only showing products that are in stock

4 posts by 2 authors in: Forums > CMS Builder
Last Post: July 17, 2014   (RSS)

By CommonSenseDesign - July 16, 2014

I have a page that I produced for a client some time ago, which shows plants and flowers in various categories: e.g. http://www.colourparadise.com/plantsSubcategory.php?main_category=13. I've added a new drop down menu - called "availability" - in CMSB so they can choose if a product is "In Stock Now" or "Unavailable". Is it possible to show in the bullet list only the plants where "In Stock Now" has been selected?

This is the code that displays the bullet list:

    <ul><?php foreach ($product_detailsRecords as $detailRecord): ?>
     <li>
       <a href="<?php echo $detailRecord['_link'] ?>"><?php echo $detailRecord['title'] ?></a>
             <?php endforeach ?>
          
              <?php if (!$product_detailsRecords): ?>
       </li>
    <?php endif ?></ul>

Attachments:

plantsSubcategory.php 7K

By claire - July 16, 2014

Have you got anything in the products table to mark whether a product is in stock or not? A checkbox perhaps?

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By claire - July 17, 2014

That works too.

So this means rewriting some of the PHP to allow the search. See the file I uploaded, and the code I added at lines 36 and 141.

This adds a conditional chunk to the getRecords function that gets the products, and I've included a few header links to swap between them. It might not work if I've got the variable names wrong.

Take a look and let me know what you think.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Attachments:

plantsSubcategory.php 8K