Closed (fixed)
Project:
Commerce Stock
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
26 Sep 2011 at 09:36 UTC
Updated:
27 Feb 2012 at 02:20 UTC
Jump to comment: Most recent file
Comments
Comment #1
guy_schneerson commentedHi @carn1x,
Yes i am aware of this issue. The initial goal was to make sure users cant order out of stock items and make sure the module operates securely and with no errors, i was planning of adding this functionality as part of version 2 but may try and do it before as i agree it is not the best user experience.
i am downgrading priority to Normal, as most of the issues raised so far actually stooped the module from working as described above.
Comment #2
carn1x commentedThanks a lot :)
Comment #3
carn1x commentedOk in the interests of time, I hacked the commerce_stock.module and changed the following function:
Since you're aware of this issue and working on V2, I won't bother rolling a patch, please anybody let me know if I can improve the code at all. Still very noobish regarding what functions commerce and entity API provides :)
Comment #4
guy_schneerson commentedHi @carn1x,
looks good if you got time to add a patch i will include it in version 1, let me know if you don't and ill make the change when i get a chance.
Comment #5
joachim commentedSeveral points:
- this fix doesn't cover the case where one product node shows multiple products -- the commerce_stock_add_to_cart_validate validator is not added to the form in this case. we probably need a new, separate validator to handler already-in-cart stock checks
- secondly, I'm not sure this is the best way to deal with the use case. What if there are two widgets, and Alice adds one to her cart, then Bob adds one to his, and Alice adds one more to her cart? Who wins? Is it whoever reaches checkout first? Admittedly, this makes the whole stock control rather more complex, because it becomes a resource allocation system, and you have to build a system for releasing resources after a certain time. Basically, adding an item to your cart would mean you decrease stock count and have it for a certain time. Also, not all sites would necessarily want this model. One for another issue, I think.
- code style in the patch: comments should be full sentences; variables shouldn't use abbreviations; run the code through Coder module for other tweaks :)
Comment #6
joachim commentedAh, my second point seems to be covered here: #1182404: Allow management of stock based on in-cart status of products
Comment #7
guy_schneerson commentedThanks @joachim this patch is unlikely to go into the V1 as I have now started work on version two and will review this functionality for all cases.
Comment #8
guy_schneerson commentedpatch based on the stock V2 function for taking the current Cart quantity into account for the add to cart functions.
Comment #9
guy_schneerson commentedcommitted http://drupalcode.org/project/commerce_stock.git/commit/4085e5f
Comment #11
hibersh commentedpatch adds line item type check, avoid exception for entitymetadata wrapper
Comment #12
guy_schneerson commentedthanks @hibresh i think you solved an issue that was responsible for http://drupal.org/node/1411032#comment-5575072, I am going to look into this and a few other issues this weekend.
I think the correct way to handle this will be by making sure $line_item->type is in commerce_product_line_item_types().
missed that out :(
Comment #13
guy_schneerson commentedpatch fixes the issue adds a check that the line item is a product, i am committing this for both version 1 and 2.
Comment #14
guy_schneerson commentedcommitted
V1: http://drupalcode.org/project/commerce_stock.git/commit/74f61a7
V2: http://drupalcode.org/project/commerce_stock.git/commit/f612733
Comment #15
guy_schneerson commentedComment #16
carn1x commentedAwesome thanks :D