News:

Support the VirtueMart project and become a member

Main Menu

Why do child product stock level show the total of all child products ?

Started by Jörgen, June 07, 2015, 09:12:41 AM

Previous topic - Next topic

Jörgen

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
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

GJC Web Design

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

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Jörgen

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
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Jörgen

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




Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.