VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: e-trader on January 31, 2014, 16:57:22 PM

Title: VM2 allows checkout of out of stock products
Post by: e-trader on January 31, 2014, 16:57:22 PM
Version VM2.0.24b  JM 2.5.14

Hello,

We do not allow customers to order products out of stock. Still, we get orders for products that are out of stock. Scenario:

Customer A has a product in cart
Customer B has same product in cart
Customer A clicks confirm order to go to payment page. Stock for product should be 1 and booked 1. Product is now out of stock.
Customer B now clicks confirm... it places the order! It should check the stock again before allowing this.

Screenshots of settings attached.

Can you reproduce this and confirm it is a bug?

Thanks.

[attachment cleanup by admin]
Title: Re: VM2 allows checkout of out of stock products
Post by: Milbo on January 31, 2014, 21:02:26 PM
Please update to 2.0.26D, maybe it was fixed meanwhile.
Title: Re: VM2 allows checkout of out of stock products
Post by: e-trader on January 31, 2014, 21:50:50 PM
Hello Milbo,

With a new clean setup using 2.0.26D I can also checkout products not in stock  :'(
Title: Re: VM2 allows checkout of out of stock products
Post by: lindapowers on February 01, 2014, 19:25:07 PM
Have not checked but I should since this affects us also, I believe that is the reason why this plugin exists http://extensions.joomla.org/extensions/extension-specific/virtuemart-extensions/virtuemart-orders/25835
Title: Re: VM2 allows checkout of out of stock products
Post by: e-trader on February 01, 2014, 19:34:54 PM
Thanks for the tip on the plugin lindapowers, no idea the plug-in existed.

VM1.1 managed the checkout of products not in stock; checkout was refused until the item that was no longer in stock was removed from the cart.
Now I'm praying Milbo can help with a fix within VM2.
Title: Re: VM2 allows checkout of out of stock products
Post by: Milbo on February 03, 2014, 10:37:33 AM
This is strange, cause we "fixed" that already, you can find old posts here. But maybe the problem is in vm2.0 and I solved it already for vm2.1.
Title: Re: VM2 allows checkout of out of stock products
Post by: e-trader on February 03, 2014, 14:55:58 PM
Hi Milbo,

Seems like you did not fix it in 2.0.
Could you kindly have a look and see if you can re-produce it?

Thanks.
Title: Re: VM2 allows checkout of out of stock products
Post by: e-trader on February 10, 2014, 21:32:39 PM
Guess we just leave the bugs where they are?
Title: Re: VM2 allows checkout of out of stock products
Post by: bunglehaze on February 13, 2014, 01:03:21 AM
It is something I experienced for the first time earlier too. I know that customers couldn't order zero stocked items before 2.0.26D though.

I am getting more and more anxious to try 2.1 though Milbo :)
Title: Re: VM2 allows checkout of out of stock products
Post by: GJC Web Design on February 13, 2014, 12:28:34 PM
If this is because you had two people with the "stock level of 1 product" in their carts simultaneously (there is NO check that someone else hasn't added it to their cart before you do  - this is all BEFORE checkout and confirm)
then one checked out and confirmed (stock level goes to 0)

2nd client checks out and confirms (there is NO check of stock level in 2.0.26 at this point) they will be able to - and you will get an order for a out of stock item

this - as lindapowers mentions - is why I wrote this plugin .. http://extensions.joomla.org/extensions/extension-specific/virtuemart-extensions/virtuemart-orders/25835
http://forum.virtuemart.net/index.php?topic=119859.0

it simply adds a custom field to the product as soon as it is added to a cart - this custom field prevents anyone else from adding it to their cart until it is either deleted from the other cart or a timed script deletes the custom field from dead cart sessions
Title: Re: VM2 allows checkout of out of stock products
Post by: bunglehaze on February 13, 2014, 13:17:26 PM
In my case it was products in a coming soon category that had zero stock level so th problem was with ordering non stock items really
Title: Re: VM2 allows checkout of out of stock products
Post by: e-trader on March 06, 2014, 21:50:24 PM
Version VM2.0.26d  JM 2.5.18 confirmed still not fixed.
Is VM 2.0 still supported or only VM 2.5 now?
Title: Re: VM2 allows checkout of out of stock products
Post by: Milbo on March 07, 2014, 02:24:50 AM
vm2.5 is vm2.0, you can directly update to it without hazzle, but the problem is solved in vm3, which is currently still vm2.1 at dev.virtuemart.net. You may test it
Title: Re: VM2 allows checkout of out of stock products
Post by: zczfwz on May 09, 2014, 14:02:56 PM
Hi Milbo,

Could you give us a simple solution first please? Something like check stock before the final check out step!
I'm running VM 2.6.0

Many thanks!
Title: Re: VM2 allows checkout of out of stock products
Post by: Milbo on May 13, 2014, 02:02:41 AM
In vm2.6.0a should be a fix to prevent it. Vm3 has another architecture to prevent it.
Title: Re: VM2 allows checkout of out of stock products
Post by: GJC Web Design on May 13, 2014, 10:51:56 AM
Checked this in 2.6.0a -

Make a product with stock level 1
Action when a Product is Out of Stock - Do not display Product
Open two browsers
You can add the product to both carts simultaneosly.... i.e. add to one - then the other -- there is no check on whether the product has been added to a cart and no limit to the number of visitors to do this..
Then it is a race to the line

When one is checked out the others fail on Product out of Stock.. so this is fixed in 2.6.0a - in previous versions you could also happily checkout as many as had them in their carts

This I guess is fine for shops where stock runs out but hardly ideal for shops selling one off products..
Especially as a couple of my clients run their shops as a time limited selling .. i.e. the shop only opens at a specified time till that batch of products are sold

hence http://forum.virtuemart.net/index.php?topic=119859.0

Title: Re: VM2 allows checkout of out of stock products
Post by: bunglehaze on May 14, 2014, 22:52:14 PM
It is not fixed for me in 2.6.0a - I am getting people are able to add low stock items to the cart beyond the in stock values.
Title: Re: VM2 allows checkout of out of stock products
Post by: GJC Web Design on May 15, 2014, 00:01:14 AM
just checked on clean 2.6.0a
stock 3

can add up to 3 in cart
4th gives  ->  Product out of stock Nice Saw

2 browsers - each can add 3 - but if one checks out 2nd can not -> Product out of stock Nice Saw

Are you sure you have: Product is Out of Stock - Do not display Product ?
Title: Re: VM2 allows checkout of out of stock products
Post by: bunglehaze on May 15, 2014, 13:03:45 PM
My site is exactly setup as it has since the first version of VM 2.x so the do not display product setting is correct - another issue I have also found is that since upgrading to 2.6.0a all of my parent items in one category had their stock values reset to zero. The child products within had the correct stock levels but due to the parent showing as zero stock it was causing problems ordering.

Personally I would like to see a checkbox of some form or intelligent configuration that can specify that a parent child can be ignored for stock control - in my case and I suspect many others, the parent item is only used to contain the child products so there is no need to check the stock in this regard.
Title: Re: VM2 allows checkout of out of stock products
Post by: GJC Web Design on May 15, 2014, 13:20:26 PM
QuotePersonally I would like to see a checkbox of some form or intelligent configuration that can specify that a parent child can be ignored for stock control - in my case and I suspect many others, the parent item is only used to contain the child products so there is no need to check the stock in this regard.

Agree fully with this - have only ever used parents as holders for children if I use Parent-child relations
Title: Re: VM2 allows checkout of out of stock products
Post by: Milbo on May 16, 2014, 21:45:41 PM
There is an option for that
Title: Re: VM2 allows checkout of out of stock products
Post by: GJC Web Design on May 16, 2014, 22:11:23 PM
See - we never investigate properly...  ;)   :D
Title: Re: VM2 allows checkout of out of stock products
Post by: bunglehaze on May 17, 2014, 00:05:51 AM
Milbo, where is that as I have never seen one?
Title: Re: VM2 allows checkout of out of stock products
Post by: Milbo on May 17, 2014, 11:10:46 AM
VmConfig => Tab shopfront => inventory => "Do not Display Product, if child products also out of stock"

This should show a parent product with stock 0, IF one of the childs has a positive stock.
Title: Re: VM2 allows checkout of out of stock products
Post by: bunglehaze on May 18, 2014, 00:42:27 AM
That does not work for me Milbo, parent products have to have a stock of 1 or more for the child to display. I am using the stockable plugin for child products though (if that makes a difference) as the other way to display child products needs a page load for each option and is just frustrating (and can be slow)
Title: Re: VM2 allows checkout of out of stock products
Post by: bunglehaze on May 19, 2014, 15:56:40 PM
I just tested the setting again Milbo, the product does display corrently but if the parent stock is 0 you cannot order any of the child products - you get a product out of stock message when adding to cart. If just 1 item is added to the parent stock, the customer cannot add more than 1 item to their cart either as they get the same error which means that all parent items need to have multiples set at their stock (I choose 50 for this reason) in order for 5,10, 20 items in the child products to be orderable
Title: Re: VM2 allows checkout of out of stock products
Post by: bunglehaze on May 20, 2014, 14:39:37 PM
To update this thread again. I had 1 product in stock in a certain size yesterday (child product), a customer has managed again to purchase 2 of this child product somehow.

I have also had an order this morning of a product that was out of stock (I know it was out of stock as I manually adjusted it again yesterday). If the parent product was working with stock @0 then the child products would not even show as in stock, that said though there should be no way to order a child product with stock 0 and I am confused how this keeps happening.
Title: Re: VM2 allows checkout of out of stock products
Post by: vaistik on June 04, 2014, 14:43:46 PM
I'm having similar issues running on an older version (2.0.10).

Of course I can't expect a fix for this but could you give me any pointers as to where I should look if I wanna add a small booked/stock check when the user checks out? This is the way we want to go and do the check at checkout while allowing multiple users to have the same product in their carts, thus the aforementioned plugin won't work for us.

I've been looking around the cart model/helper, checking the dataValidated vars etc but as far as I can tell there is not a single check for product status after it's in the cart.

Any pointers to functions/files would be greatly appreciated.
Title: Re: VM2 allows checkout of out of stock products
Post by: GJC Web Design on June 04, 2014, 16:42:43 PM
QuoteI've been looking around the cart model/helper, checking the dataValidated vars etc but as far as I can tell there is not a single check for product status after it's in the cart.

correct in the VM version you mention  - this is why I went with my system - to attach a flag as soon as it enters a cart.

Haven't checked the VM2.6.x series...

If you want to check it at Confirm purchase your going to have to write your own check in the cart system.
Title: Re: VM2 allows checkout of out of stock products
Post by: bunglehaze on June 04, 2014, 22:49:49 PM
As it happens I set tonight to one side to try and test if the parent product stock@zero and child products all carrying stock worked as Milbo mentioned before and can confirm again that even on standard Virtuemart (no overrrides) and basic Joomla atomic template I get an out of stock warning when trying to add child products that are in stock.

To clarify the situation:

Parent Item  = stock of zero
Child Item 1 = stock of 10
Child item 2 = stock of 5

I go to the parent and select the child from the dropdown, click add to cart and get 'product out of stock'. Same situation happens on any child product selected.

If this is the intended functionality of the parent/child relationship and having the do not show parent while child products out of stock option being selected it would appear that this is not working.

How we have been working around this based on what I read  on this forum is that shop owners have to have the parent item as always carrying stock, this is counterproductive as it means other addons that look to remove out of stock items will always display the parent even when child items are all out of stock.

Any idea how to fix this or where to even begin? I would understand if this was happening using overrides but certainly not on a basic VM2 install and native Joomla template

Ignore the above - fix was found today that I can confirm works:
http://www.rupostel.com/phpBB3/viewtopic.php?f=5&t=937&sid=1b5d2e395866210264df3bf3f077ebbc
Title: Re: VM2 allows checkout of out of stock products
Post by: vaistik on June 05, 2014, 12:31:23 PM
Quote from: GJC Web Design on June 04, 2014, 16:42:43 PM
correct in the VM version you mention  - this is why I went with my system - to attach a flag as soon as it enters a cart.

Haven't checked the VM2.6.x series...

If you want to check it at Confirm purchase your going to have to write your own check in the cart system.

Thanks for the reply! It's a shame the client insists on doing the check during purchase confirmation, your plugin would save me ALOT of time. Do you have any pointers as to which files/functions I should look at?

I was thinking messing around with the dataValidated variable but couldn't find a proper way to do so.
Title: Re: VM2 allows checkout of out of stock products
Post by: GJC Web Design on June 05, 2014, 17:39:46 PM
I haven't investigated this - I just attach a custom field to the product when 1st added to cart - any subsequent add to carts trigger a check if the product has that custom field - if so block it

You need to trace what triggers are called on confirm cart and write something for that that checks if it's really in stock..

from a user point of view  - you risk annoying the client with his nice selection of products - filled out his address, chosen payment - and then finds he can't confirm the cart.. :-[

Title: Re: VM2 allows checkout of out of stock products
Post by: Milbo on June 05, 2014, 19:21:24 PM
Quote from: bunglehaze on June 04, 2014, 22:49:49 PM
http://www.rupostel.com/phpBB3/viewtopic.php?f=5&t=937&sid=1b5d2e395866210264df3bf3f077ebbc

The strange thing is that exactly this line should update the product with the new stocking. For me it looks like the check is just disabled.
Title: Re: VM2 allows checkout of out of stock products
Post by: Milbo on June 06, 2014, 10:39:38 AM
Quote from: bunglehaze on June 04, 2014, 22:49:49 PM
Ignore the above - fix was found today that I can confirm works:
http://www.rupostel.com/phpBB3/viewtopic.php?f=5&t=937&sid=1b5d2e395866210264df3bf3f077ebbc

Again, I just rechecked it. This "fix" is definitly wrong, you just disable the function. Please try the attached file in BE/models

[attachment cleanup by admin]
Title: Re: VM2 allows checkout of out of stock products
Post by: bunglehaze on June 06, 2014, 19:45:50 PM
Quote from: Milbo on June 06, 2014, 10:39:38 AM
Quote from: bunglehaze on June 04, 2014, 22:49:49 PM
Ignore the above - fix was found today that I can confirm works:
http://www.rupostel.com/phpBB3/viewtopic.php?f=5&t=937&sid=1b5d2e395866210264df3bf3f077ebbc

Again, I just rechecked it. This "fix" is definitly wrong, you just disable the function. Please try the attached file in BE/models

OK, I removed the commenting on Rupostel 'fix' and replaced the /administrator/components/com_virtuemart/models/product.php with the file you attached Milbo,  the add to cart function  is no different to how it was before the 'fix' (ie you cannot check out anything). I re-commented the line again and I can add to cart again.

I hope that helps figure this out.
Title: Re: VM2 allows checkout of out of stock products
Post by: Milbo on June 06, 2014, 20:35:23 PM
It works for me. I tested it. So please give me your exact configuration of the stocking and the settings of the products.
Title: Re: VM2 allows checkout of out of stock products
Post by: bunglehaze on June 07, 2014, 00:03:09 AM
How do you want me to do that Milbo?  What files do you want to see?
Title: Re: VM2 allows checkout of out of stock products
Post by: norris on October 27, 2014, 01:16:13 AM
i can confirm the same experience as bunglehaze, after updating VM to 2.6.12 I had the problem with child variants showing up, but not able to be added to the cart unless the parent had some stock set.

I tried  replaced the /administrator/components/com_virtuemart/models/product.php with the file Milbo attached, but it didn't work.  I restored the original product.php and tried commenting out the line in cart.php and that fixed it.
Title: Re: VM2 allows checkout of out of stock products
Post by: bunglehaze on October 27, 2014, 22:38:28 PM
I have updated each version of VM2 since that 'fix' was first found and each time the same situation occurs with parent products flagging up the "out of stock" error when selecting child products in stock. Each time I commented the line in the 'fix' and it works again.
Title: Re: VM2 allows checkout of out of stock products
Post by: Milbo on October 28, 2014, 01:59:26 AM
How works vm3 for you?
Title: Re: VM2 allows checkout of out of stock products
Post by: bunglehaze on October 28, 2014, 02:37:06 AM
Quote from: Milbo on October 28, 2014, 01:59:26 AM
How works vm3 for you?

I haven't tried it for the last couple of revisions as the stockable plugin migration wasn't in place and my entire site us pretty much using it.

I have been hanging on until that worked and I'll give it a try