VirtueMart Forum

VirtueMart Dev/Coding Central: VM1 (old version) => Virtuemart 1.1 Development (Archiv) => Quality & Testing VirtueMart 1.1.x => Topic started by: AtPaul on October 23, 2009, 12:24:14 PM

Title: Problem with Add to cart popup message
Post by: AtPaul 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
Title: Re: Problem with Add to cart popup message
Post by: Scar on October 23, 2009, 14:32:59 PM
What version?
Title: Re: Problem with Add to cart popup message
Post by: AtPaul on October 23, 2009, 15:32:03 PM
Vm 1.1.4
Title: Re: Problem with Add to cart popup message
Post by: Scar 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)
Title: Re: Problem with Add to cart popup message
Post by: Scar on October 23, 2009, 16:09:52 PM
Problem is in ps_cart.php. I think this line:$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)
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;
}
Title: Re: Problem with Add to cart popup message
Post by: AtPaul 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)
Title: Re: Problem with Add to cart popup message
Post by: deemee3 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.

:)