Creating a Low-Stock warning in the CW Admin
There is no warning for stocks getting low in supply in Cartweaver, however you can create a simple query and display it in the admin showing a warning about low-stock products. Create a page called LowStockProducts.php in the cw2/admin/ folder. On that page, use this code:
<?php
// Fill in the value that you want to use for the low-stock warning
$stockCheck = 5;
$query_rsCWGetSKUs = "SELECT DISTINCT P.product_ID
, P.product_Name
, S.SKU_ID
, S.SKU_MerchSKUID
, S.SKU_Price
, S.SKU_Stock
FROM tbl_products P
INNER JOIN tbl_skus S
ON P.product_ID = S.SKU_ProductID
WHERE P.product_OnWeb = 1
AND P.product_Archive = 0
AND S.SKU_Stock <= $stockCheck";
$rsCWGetSKUs = $cartweaver->db->executeQuery($query_rsCWGetSKUs);
$rsCWGetSKUs_recordCount = $cartweaver->db->recordCount;
$row_rsCWGetSKUs = $cartweaver->db->db_fetch_assoc($rsCWGetSKUs);
if($rsCWGetSKUs_recordCount > 0) {
?>
<h2>Low Stock Products Alert</h2>
<h3>Products where stock has reached a quantity of <?php echo($stockCheck);?> or less</h3>
<table class="tabularData" id="tableSearchResults">
<tr>
<th>Item Name</th>
<th>SKU ID</th>
<th>Price</th>
<th>Stock</th>
<th>View</th>
</tr>
<?php
$recCounter = 0;
do {
?>
<tr class="<?php cwAltRow($recCounter++);?>" style="vertical-align: top">
<td><?php echo($row_rsCWGetSKUs["product_Name"]);?></td>
<td><?php echo($row_rsCWGetSKUs["SKU_MerchSKUID"]);?></td>
<td><?php echo(cartweaverMoney($row_rsCWGetSKUs["SKU_Price"]));?></td>
<td><?php echo($row_rsCWGetSKUs["SKU_Stock"]);?></td>
<td><a href="ProductForm.php?product_ID=<?php echo($row_rsCWGetSKUs["product_ID"]);?>"><img src="assets/images/viewdetails.gif" alt="View Product" width="15" height="15" border="0"></a></td>
</tr>
<?php
} while ($row_rsCWGetSKUs = $cartweaver->db->db_fetch_assoc($rsCWGetSKUs)); ?>
</table>
<?php } /* end if($rsCWGetSKUs_recordCount > 0) */?>
Then, on the AdminHome.php file, add an include somewhere on the page to display this warning:
<?php include("LowStockProducts.php");?>