Author Topic: Problem with Add to cart popup message  (Read 7150 times)

AtPaul

  • Beginner
  • *
  • Posts: 16
Problem with Add to cart popup message
« on: October 23, 2009, 12:24:14 pm »
Hi all,

Here is the problem I have. Not sure yet if this is a bug.

- For instance: identify a product for which only 5 items are available in stock (5 products left)
- Add to cart this product one by one up to five
- Pop up says "Product added to the cart" or something like that --> which is excellent

- However if you now try to add one more product (when stock says zero) the popup comes up showing no message at all.
Searching a bit in the code I found that this might be dealt with in ps_cart.php. It seems that the key PHPSHOP_CART_QUANTITY_EXCEEDED would not be printed.

Any idea ?

Thanks

Scar

  • Full Member
  • ***
  • Posts: 1035
    • J-lux
Re: Problem with Add to cart popup message
« Reply #1 on: October 23, 2009, 14:32:59 pm »
What version?

AtPaul

  • Beginner
  • *
  • Posts: 16
Re: Problem with Add to cart popup message
« Reply #2 on: October 23, 2009, 15:32:03 pm »
Vm 1.1.4

Scar

  • Full Member
  • ***
  • Posts: 1035
    • J-lux
Re: Problem with Add to cart popup message
« Reply #3 on: October 23, 2009, 15:54:35 pm »
Confirmed. No message with either AJAX or without AJAX add to cart is displayed when trying to add 0 stock products with Check Stock enabled.

Fresh install with standard milkyway template, J1.5.14 and VM 1.1.4, on XAMPP 1.7.1 (PHP5.2.9)

Scar

  • Full Member
  • ***
  • Posts: 1035
    • J-lux
Re: Problem with Add to cart popup message
« Reply #4 on: October 23, 2009, 16:09:52 pm »
Problem is in ps_cart.php. I think this line:
Code: [Select]
$vmLogger->tip( $VM_LANG->_('PHPSHOP_CART_QUANTITY_EXCEEDED',false) );
should be in the elseif right before return false, it seems to work then. So the whole thing should look like:

(Line 283-290)
Code: [Select]
else if ($request_stock ) {
            $vmLogger->tip( $VM_LANG->_('PHPSHOP_CART_GOTO_WAITING_LIST',false) );
} elseif( $total_quantity == 0 ) {
vmRequest::setVar('product_id', $product_id );
$GLOBALS['last_page'] = 'shop.product_details';
$vmLogger->tip( $VM_LANG->_('PHPSHOP_CART_QUANTITY_EXCEEDED',false) );
return false;
}

AtPaul

  • Beginner
  • *
  • Posts: 16
Re: Problem with Add to cart popup message
« Reply #5 on: October 23, 2009, 17:02:42 pm »
Thanks a lot Scar. This works great. Good job.
For those who get the same pb please also make sure you have a key PHPSHOP_CART_QUANTITY_EXCEEDED valued in your language file (it happened to me  ;D)

deemee3

  • Beginner
  • *
  • Posts: 8
Re: Problem with Add to cart popup message
« Reply #6 on: November 16, 2009, 21:24:45 pm »
Dear Scar,

I said in the other topic ( http://forum.virtuemart.net/index.php?topic=61913.0 ) that this didn't work for me. I discovered why: when you add 1 (or more) with the add-to-cart button after the stock limit is already reached, your solution works fine and the message correctly appears in the cart dropdown saying "Info: The selected quantity exceeds quantity available in stock". If you enter an excessive quantity right from the start though (let's say 6 when 5 are in stock), than it's the out-of-stock message that loads instead of the dropdown one. So we're half way through the solution...:-)) Hope you (or someone else) can help us.

:)