Turn Speech into Text »

How to Make Zen-Cart Not Display Product if Price is Zero

In the default settings of version 1.3.8 of Zen-Cart, if you have a product with zero for the price, Zen-Cart will still display the product but with no price showing.

The following steps will make Zen-Cart not display the product when the price is zero or negative. This will make it so that if you forget to enter the price of a product, Zen-Cart will not show it so that you customer can not accidentally purchase a product for free. Also I can not see any reason why a price would be negative, unless it was an human error during adding of product. So in this case, we also do not want Zen-Cart to display the product.

1. We do not want the product to appear in the category listing. So we alter the code for the file ...
/includes/modules/yourtemplate/product_list.php where "yourtemplate" is the name of your custom template folder as prescribed by the ZenCart code override system.

(Note that this procedure is advanced and requires experience with PHP and ZenCart overrides. Hence if you are not comfortable, consider hiring a professional here.)

Look for the while-loop shown and add the indicated statements which starts an if-clause...

2. The if-clause that we are adding will wrap most of the while-body, except for the $listing->MoveNext()

So we close the if-clause right above that line as shown...

3. Now we have to hide the product from its product-detail page as well. So we alter the file ...
/includes/templates/yourtemplate/templates/tpl_product_info_display.php

Start an if-condition at the top of the file as shown...

4. Close the if-body at the bottom of the file ...

So that the if-condition wraps the entire contents of the file.