Просмотр исходного кода

Ensure only available products are shown online

Johannes Zellner 5 лет назад
Родитель
Сommit
ac9d416256
2 измененных файлов с 5 добавлено и 2 удалено
  1. 4 1
      website/DataBase/Product.php
  2. 1 1
      website/product_list.php

+ 4 - 1
website/DataBase/Product.php

@@ -146,7 +146,7 @@ class Product
 	}
 
 
-	function getByFilter($search_product, $search_category, $item_offset, $item_count)
+	function getByFilter($search_product, $search_category, $item_offset, $item_count, $available)
 	{
 		$query = "SELECT * FROM ".$this->db->product_table." ";
 
@@ -154,6 +154,9 @@ class Product
 		{
 			$query .= " WHERE ";
 
+			if ($available) $query .= " available=1 AND ";
+			else $query .= " available=0 AND ";
+
 			if($search_product != "")
 				$query .= " (product_id LIKE '%".$search_product."%' OR name LIKE '%".$search_product."%' OR details LIKE '%".$search_product."%') ";
 

+ 1 - 1
website/product_list.php

@@ -62,7 +62,7 @@ if($search_category != "")
 	</tr>
 <?php
 
-$list = $product->getByFilter($search_product, $search_category, $item_offset, $item_count);
+$list = $product->getByFilter($search_product, $search_category, $item_offset, $item_count, True /* available */);
 $count = $product->getCountByFilter($search_product, $search_category);
 
 for($i = 0; $i < count($list); $i++)