News:

Support the VirtueMart project and become a member

Main Menu

Product in stock display errors

Started by wizzin, September 27, 2012, 16:13:59 PM

Previous topic - Next topic

wizzin

Stats: J! 2.5.7 and VM 2.0.10

I'm trying to display the number of items in stock as text on the details page.  I've got the text to display, but it's wrong.  I got the info from this thread: http://forum.virtuemart.net/index.php?topic=105026.msg351091#msg351091  and this thread: https://forum.virtuemart.net/index.php?topic=102087.0

However, when I use this code:

<?php if (!VmConfig::get('use_as_catalog') and !(VmConfig::get('stockhandle','none')=='none') && (VmConfig::get 'display_stock')) ) : ?>
  <?php echo JText::_('COM_VIRTUEMART_STOCK_LEVEL_DISPLAY_TITLE_TIP') .' '$this->product->product_in_stock $this->product->product_ordered?>
<?php endif; ?>


modified like this:

   <?php if (!VmConfig::get('use_as_catalog') and !(VmConfig::get('stockhandle','none')=='none') && (VmConfig::get 'display_stock')) ) : ?>
  <div>ONLY <?php echo JText::_('COM_VIRTUEMART_STOCK_LEVEL_DISPLAY_TITLE_TIP') .' '$this->product->product_in_stock $this->product->product_ordered?> In Stock.  ORDER BEFORE IT'S TOO LATE!</div>
<?php endif; ?>


I get two problems.  Problem 1) is that the result of subtracting "product_ordered" from "product_in_stock" is resulting in a negative number.  Problem 2) is the math is wrong.  I have 14 items in stock and 9 items have been ordered.  This should result in (a positive) 5 but the output of the code above is "-9".  I don't have a clue where it's getting negative 9 as the result unless it's simply outputting the "product_ordered"???

Additionally in config, I have "order statuses" set so that Shipped, Confirmed, Confirmed by Shopper and Pending all set the stock handling to "is removed".  Pending because of something that seems to have happened recently with paypal that I haven't figured out yet.  I get orders that are not getting updated to confirmed even though everything is going through paypal correctly.  I get the confirmation from paypal but nothing from VM.  Bad thing is, it's only randomly happening.  Day before yesterday I had an order come through that worked correctly.  Shopper paid via paypal and I got an email from paypal followed by an email from VM and the status of the order was automatically set to confirmed.  I had an order placed this morning that all I got was an email from paypal and the order in VM is still set at pending.

This may be two separate issues, but I thought the information might be relevant to the first issue of the stock handling.

I wasn't sure whether to post in the other 2 threads or start a new one since my situation is different and there is no answer to this problem anywhere I've seen by searching.  Any help?  Thx.