Page 1 of 2 Cartweaver is an online shopping cart system available from cartweaver.com for PHP, ColdFusion, and ASP. It is intended as an easy-to-use solution for building an online store. It doesn't have all the bells and whistles of some of the more pricey carts available, but with a little coding, many new features can be added. Part 1 will show how to add a low-stock warning to the Cartweaver 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 home page showing a warning about low-stock products. First, create a new configuration item in the Cartweaver config section—this is the key to adding any new feature to Cartweaver. Follow these steps:

Figure 1: Adding a new configuration item to the Cartweaver store
That gives your store a new store-wide setting called LowStockCheck, which is now available as a session variable to use in your code:
$_SESSION["LowStockCheck"]
Next, create a PHP page called LowStockProducts.php in the cw3/admin/ folder. On that page, use this code:
<?php
// Fill in the value that you want to use for the low-stock warning
$stockCheck = isset($_SESSION["LowStockCheck"]) ? $_SESSION["LowStockCheck"] : 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");
$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) */?>
The code is essentially saying "give me all the SKUs that have stock counts less than or equal to 5."
Keywords
cartweaver,php,e-commerce,ecommerce,e-store,cart,shopping,admin,administration