This is how to add inventory levels for each product in your customer's cart. I don't know PHP so I'm slowly learning by trial and error because I need implement some wholesaler code and have been unable to find a reliable programmer. So I am learning while I continue to look for one. Anyway, this is my latest accomplishment.

The goal is to get something like "CURRENT STOCK LEVEL: "stock number from database"" for each item in the cart, right under the product name link (you can put it anywhere you want but I put it there because it made sense to me. What was there before was %%GLOBALS_ProductAvailability%% which is what helped me figure all this out in the first place).
In /include/classes/class.quote.item.php FIND THIS:
Code: Select all
/**
* Return the product availability string for this product. This is just
* a field configured for the product and shown during checkout.
*
* @return string Availability message.
*/
public function getAvailability()
{
$productData = $this->getProductData();
if (!empty($productData['prodavailability'])) {
return $productData['prodavailability'];
}
return '';
}
Code: Select all
/**
* Return the product stock level string for this product. This is just
* a field configured for the product and shown during checkout.
*
* @return string stock level message.
*/
public function getStockl()
{
$productData = $this->getProductData();
if (!empty($productData['prodcurrentinv'])) {
return $productData['prodcurrentinv'];
}
return 'Out of Stock!';
}
Code: Select all
$GLOBALS['ProductAvailability'] = $item->getAvailability();
Code: Select all
$GLOBALS['ProductStockl'] = $item->getStockl();
Code: Select all
%%GLOBALS_ProductAvailability%%
Code: Select all
<strong>CURRENT STOCK LEVEL: %%GLOBAL_ProductStockl%%</strong>
You are all done! Now your shopping cart should show your stock levels for each item in the cart. I'll be working on getting this to work on the category product listing pages (where I really need it).