Hello
How Do I show the number of products in stock for a child product on the product detail page ? I have tried the following override and I only get the total number of products for all of the child products.
templates/mytemplate/html/com_virtuemart/productdetails/default.php
echo '<strong>' . vmText::_('COM_VIRTUEMART_PRODUCT_IN_STOCK') . ': </strong>' ;
$nrAvail = ($this->product->product_in_stock - $this->product->product_ordered);
if ($nrAvail > 5)
echo vmText::_('COM_VIRTUEMART_MORE_THAN_FIVE_IN_STOCK');
elseif ($nrAvail > 1)
echo $nrAvail;
else
echo vmText::_('COM_VIRTUEMART_ONLY_ONE_IN_STOCK');
VM 3.0.8
JOOMLA 3.4.1
best regards
Jörgen @ Kreativ Fotografi
Yep Jörgen,
have reported this in March I think. Still a problem 3.0.8
for the moment I add in administrator\components\com_virtuemart\models\product.php getProduct() func at ~ line 796
//GJC fix for child stock
$child->child_stock = $child->product_in_stock;
//GJC
add the above just before ->
if(!isset($child->orderable)){
$child->orderable = TRUE;
}
then in the FE the actual child stock of individual children is available as $product->child_stock & $this->product->child_stock etc
the $child->product_in_stock later in the func seems to get a cumlative total
Hello GJC
Thanks for the fix, great. I must have missed this when searching through the forum. I will try this later tonight :)
best regards
Jörgen @ Kreativ Fotografi
Hello GJC
Thanks for this
I placed the following in the code
//GJC fix for child stock
$child->child_stock = $child->product_in_stock;
//GJC
// JH fix for child ordered
$child->child_ordered = $child->product_ordered;
//JH
Subtracting the ordered amount will give the actual available stock :)
regards
Jörgen @ Kreativ Fotografi