News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

When a product is getting 'Booked, ordered'. the in stock doesnt update

Started by kaistudios, February 08, 2016, 06:32:48 AM

Previous topic - Next topic

kaistudios

Can anyone help please.
When a product is getting 'Booked, ordered'. the amount of stock doesn't reflect in the 'in stock' field. 
it does show on the front end as out of stock but the in stock field doesn't change.
this makes the product appear as in stock on the product feed with VirtueMart 3.0.10

Jörgen

Hello

Available stock is the combination of "In stock" and "Booked/ordered". The in stock value should not be updated at this point. Available stock is apparently displayed correctly in your frontend. Are You using any third party component for the feed You are talking about ?

regards

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

kaistudios

Thank you Jörgen!

so it seems the available stock isn't taking the booked/ordered amount from the total number
I have an item has 6 in stock and 6 booked/ordered shows as out of stock on the product flypage but shows as 6 available on the feed.

Yes I'm using third party component for the feed obRSS but it will also show out of stock products on other feeds i have installed like the google base xml.

one more thing is I added <?php echo $this->product->product_in_stock ?> to the product fly page to show the amount of items available in stock and it takes the number from the 'in stock' field so the product will be out of stock but still show the amount of in stock items as available 6. even if I hide out of stock products from the site completely they will show on the feed because of the number in that field.

so what do I need to do to manage live inventory and make sure when an item is booked or ordered that the 'in stock' level or the available stock will reflect this?

Jörgen

Hello

You should add this to Your code to get available stock:

<?php echo ($this->product->product_in_stock $this->product->product_ordered)  ?>

This should also be added into the logics of Your third party feed. Speak with the developers.

regards

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Milbo

Thank you, Jörgen. Yes this is part of the default.php, but commented.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Jörgen

Yes I saw that code now.
But since I use a lot of Child Products I am actually using a different approach in order to detect stock for child products. These lines of code detect if it is a parent and hides the stock for the parent. If there is a better way to do then please tell me.

// JH 2015-11-08 is this a parent ?
$db = JFactory::getDbo();
$q = 'SELECT product_parent_id FROM `#__virtuemart_products` as pc
WHERE  product_parent_id = ' . $this->product->virtuemart_product_id;
$db->setQuery($q);
$product_parent_id = $db->loadResult();
if (!($product_parent_id == $this->product->virtuemart_product_id))
// No it is a child item
echo '<div style="text-align: right">';
echo '<strong>' . vmText::_('COM_VIRTUEMART_PRODUCT_IN_STOCK') . ':  </strong>' ;
$nrAvail = ($this->product->child_stock - $this->product->child_ordered);
if ($nrAvail > 5)
echo '&nbsp;' . vmText::_('COM_VIRTUEMART_MORE_THAN_FIVE_IN_STOCK');
elseif ($nrAvail > 1)
echo '&nbsp;'. $nrAvail;
elseif ($nrAvail > 0)
  echo '&nbsp;' . vmText::_('COM_VIRTUEMART_ONLY_ONE_IN_STOCK');
else
echo vmText::_('COM_VIRTUEMART_OUT_OF_STOCK');
echo '</div>';
}
else // Yes it is Parent
  echo '<br />'; 
// Parent don´t show any kind of stock, I usually set parent stock to 1 gives which then displays "last item", which is undesirable. With this code I only get the available stock if its not a parent product.
// end jh



This works for VM 3.0.8 and displays no stock for parent products otherwise I would get "last item", since I set all my parent products stock to 1. I think this looks more neat. Thoughts on this welcome :)

regards

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Lexiboy

At what point is the stock updated and the amount ordered put to zero?


Quote from: Jörgen on February 08, 2016, 08:07:04 AM
Hello

Available stock is the combination of "In stock" and "Booked/ordered". The in stock value should not be updated at this point. Available stock is apparently displayed correctly in your frontend. Are You using any third party component for the feed You are talking about ?

regards

Jörgen @ Kreativ Fotografi
With kind regards,
Alex Stienstra

Studio 42

The logic is how you process the real the stock
Eg for quantity 2
On confirmed or customer confirmed :
Booked/ordered +2
in stock = no change(your real stock is same as before, but your shop cannot sold this 2 booked products)
On shipped 
Booked/ordered -2
in stock -2(your real stock is not same as before)

I don't explain you all, to simplify