Motivation
Drupal 8 and Commerce 2.x are coming, we must have Commerce Stock, and we want it to be a much improved version.
Proposed resolution
I have been thinking about this for a while and have a plan for its architecture, however I have loads to catch up on D8 and commerce 2.x so anyone with knowledge in those areas that is interested in helping do get in touch.
Remaining tasks
The development process of development will have 4 steps. I will appreciate feedback on 1 & 3 & help on 2 &4:
1) Architecture
Define the high level functionality. started on Stock for D8: Architecture & high level functionality
2) Technology
Identify the technology (APIs) and techniques needed
3) Technical Architecture
Create implementation issues
4) Development
Get it all done
API changes
The current stock module had a sort of plugin architecture, thanks to Drupal moving to OOP, I am expecting for this to be properly implemented for 8.
Comments
Comment #2
guy_schneerson commentedfirst task:
Need to create an 8 branch so can assign this and other 8 related issues to.
Comment #3
guy_schneerson commentedComment #4
iaugur commentedComment #5
guy_schneerson commentedComment #6
guy_schneerson commentedComment #7
guy_schneerson commentedYou have an opinion on what the new version of stock should do checkout the architecture issue and feedback
Want to help get in touch :)
Comment #8
agoradesign commentedI don't know, if you're actually working together, but there's a port available on Github: https://github.com/INsReady/drupal-commerce-stock
It's mentioned in here: https://insready.com/en/blog/case-study-launching-inventory-control-syst...
Comment #9
guy_schneerson commentedHi @agoradesign yes I am aware and skyred has been updating me on progress.
they implemented some of the architecture in #2618906: Stock for D8: Architecture & high level functionality but their objective is to get something working for their use case while I am putting more effort into the architecture and making this a robust contrib module. I monitor the github repo regularly.
Also have to report that I have made loads of progress on both low level functionality and a plugable service architecture lately. should write a post myself but making to much good progress to stop and write about it :)
Comment #10
agoradesign commentedThat's great news! :-)
Just wanted to ensure that no one wastes his valuable time because of not knowing that some other person has already done great work too...
I'm looking forward to commerce_stock :) (unfortunately (or luckily) I don't need it in my current e-commerce projects, so I won't have the need to contribute by myself here...)
Comment #11
kscheirerHows the progress? I will need this module for a D8 commerce project soon, am willing to help out.
Comment #12
guy_schneerson commentedHi kscheirer,
The module has a loot ready and will not take much for a functioning basic version.
In short:
https://www.drupal.org/node/2710107
(If you send me a list of requirements I can be more specific )
Help would be great.
I will not have much time before Drupalcon Dublin but happy to arrange a Skype chat.
Comment #13
tasmaniaman commentedHI Guy,
Hows development of commerce_stock for D8 coming along?
I'd be happy to do testing for you, wheres the latest code to be found?
Peter.
Comment #14
steveoliver commented@tasmaniaman, Work is happening here in the d.o issue queue, with PRs at https://github.com/BBGuy/commerce_stock. Jump in! Jump on IRC and look for me (@steveoliver) if you need help finding an issue.
Comment #15
jon@s commentedAny ETA on an alpha release?
Comment #16
justas.raudonius commentedHello,
commerce_stock still requires commerce-2.x-dev, even if commerce 8.x-2.0-beta6 has come out. Maybe tag the beta as requirement? Would be nice to start using commerce 8.x-2.0-beta6, not the dev version.
Justas
Comment #17
guy_schneerson commentedHi Jon@s
We are making good progress We have two hurdles to resolve before we can think of an Alpha:
#2858391: Add Support for multiple stores & clean up locations store relationship
#2710107: Finalize the availability manager service
Comment #18
websiteworkspace commentedWhat level of functionality can be expected from D8 commerce stock, now that D8 commerce core is getting closer to what they consider a release version?
Comment #19
heddn@guy_schneerson, are the two listed blockers still accurate? Are they stalled out?
Comment #20
guy_schneerson commented@heddn: availability manager needs finalising and the bigger one is the multiple store support.
@heddn, @DrupalWebsiteBuilder - I have been busy with a big project (I am on week 9 of 11) and following that I have a week holiday, once those two are out of the way I am hoping to make a push to get a working version.
We have a few excellent architectural proposals but my objective will be to make sure we have a working version ASAP that way we have a working version to fall back while developing.
Comment #21
heddnLinking in related issues. And changing this to postponed since we seem to be effectively blocked until those issues are resolved.
Comment #22
guy_schneerson commentedThanks heddn for linking the issue in. I am changing back to active as the multi store support is a part of the port and we have other issues people are helping with like small bug reports.
I would say those are the main issues but not blockers.
Comment #23
websiteworkspace commentedWhen is the next expected - commerce_stock 8.x-1.x-dev - branch release?
Comment #24
guy_schneerson commentedI was busy with another project but have time again so will hopefully be working on the module for at list once a week. the two big challenges are:
1) support for multiple stores
2) integration to drupal commerce - the availability manager in commerce core has not been finalized yet
Once those are complete we can look at stabilizing and releasing a alpha version.
Comment #25
websiteworkspace commented@guy_schneerson wrote:
"the availability manager in commerce core has not been finalized yet"
Does that statement imply that Drupal 8 Commerce 2.x is still really a beta component with an incomplete infrastructure?
Comment #26
steveoliver commentedDrupalSiteBuilder, The availability checker interface currently returns boolean values for availability checks, which works for hard yes/no responses, but is not very flexible for making decisions based on more qualified information like stock levels and specific reasons for responses.
Drupal 8 core and now Commerce 2.x's release schedule allows for progressive enhancements like this to APIs for those that are willing and able to follow the progress.
See #2710107: Finalize the availability manager service.
Comment #27
maxplus commentedSubscribing,
looking forward for first working version Commerce Stock in D8!
Thanks already for all the effort for everybody working on this project!
Comment #28
guy_schneerson commentedUpdate:
I am just finishing looking at the commerce Availability responses PR https://github.com/drupalcommerce/commerce/pull/593 this is the number one priority but not much to do until its committed.
I will then look at the Support for multiple stores https://www.drupal.org/node/2858391 We have two candidate PRs on github, each with it's own aprouch, so we need to chose a direction.
https://github.com/BBGuy/commerce_stock/pull/27
https://github.com/BBGuy/commerce_stock/pull/35
Comment #29
websiteworkspace commentedThanks for working on this component!
... ready and willing test with gusto as soon as some dev/alpha/beta code is available ...
... looking forward to a working version of this component with great appreciation! ....
Comment #30
apsylone commentedOne of the most missing to Drupal Commerce. Looking forward too for first working version D8.
Thanks for the hard work !
Comment #31
CryptoKiwi commentedI would love to be able to use this module on my website. Is there any work that needs to be done so that PR #593 can be approved?
I'm not very experienced with Drupal yet, but I'm willing to contribute.
Comment #32
bgronek commentedHi All!
Thank you all for your hard work so far on this!
How far away from a alpha do you think we are? Is the current state of the effort reflected in the "Remaining Tasks" above? That seems to be very early days as Architecture is not indicated as being done yet.
Updating in the doc above may help minimize these annoying requests for status. Also, I'm another willing participant in helping this effort move forward on dev, testing, whatever!
Thanks!
Comment #33
zenimagine commentedDo you have a release date to communicate ?
Comment #34
BigEd commentedI have just seen this and I have a client asking when stock could be added to there store and why it is not default like it is on other commerce solutions. So I apologise in advance but I need to add to the voices here as I could do with getting an idea if this is going to be a problem for me.
Comment #35
agoradesign commented@BigEd: I haven't observed the development of commerce_stock and how mature it already is, but building a (temporary) simple stock solution (only having a single stock location, etc) should be rather trivial.
I may miss one point, but basically you'll want to:
Comment #36
maxplus commentedYes I agree with agoradesign,
you can already use commerce_stock in D8.
We have a site running on D8 with basic stock support, coming from D8 commerce_stock and here are some fragments from our composer.json:
"require": {
"drupal/commerce_stock": "1.x-dev",
=> These are the patches we are using:
"drupal/commerce": {
"AvailabilityChecker": "patches/commerce_2710107-availability-response.patch",
"drupal/commerce_stock": {
"MultiStore + Availability checker": "patches/2847529-add-to-cart-availability-full.patch"
Comment #37
guy_schneerson commentedHi All
The main issue with stock getting a release out is that drupal commerce core has not finalized its availability manager (as it was in my last post on 24 October 2017 at 10:14). We have two pull requests stuck waiting for it. As @agoradesign was saying this can probably be handled using a form alter meanwhile.
The next big thing is issues related to the stock computed field. The code for this was written before computed fields were properly implemented (I have not reviewed if this has been finalised) and curently results in the stock display not working but the entire code for this needs review.
A bunch of other stuff that's more architectural then direct functionality
@BigEd or anyone else- help is always appreciated, get in touch if you have the ability and time to help :)
Comment #38
BigEd commentedOk this sounds really positive thanks for the quick response guys.
If I am reading right there are two different solutions here. @maxplus I assume the code we are adding is a dev version of this module with patches is that correct?
If so we can all test this to help this module along.
If its a problem and not working for me I can always try the simple stock trick that @agoradesign suggested that also sounds not too painful to put together.
Comment #39
agoradesign commentedRight.. of course the very best for the community would, if you try commerce_stock and if necessary, help to improve it
If you nevertheless don't have resources for that, the simplified custom solution should really be that easy as described. Another thing I forgot before and you'll probably want to do is to ensure that you can't modify the quantity on the cart form to a higher number that is on stock... but that's also just another form alter hook with an additional custom validate callback
Comment #40
cassien commentedIn my opinion, quantities you're able to add to the cart have to be managed by the stock module. It's intrinsic.
Being able to use a select list (eventually with an high limit) instead of a simple field could be useful for that.
Comment #41
calbasiBy the way, I don't know if it could be help, but what about founding a beta release? I mean, get funds of all guys who need a beta release (what do not break in later upgrades).
I'm not a coder, but I can help adding funds in a microfunding process, if it has sense for you.
Comment #42
guy_schneerson commented@calbasi That is a good idea.
I am sure it will help with some of the contributes that would like to help.
Personally I am happy to contribute on my spare time (personal or work) but having it as paid work will result in it getting priority. Also (needs confirming) I can probably match each paid hour with a free hour sponsored by my company blue-bag for my time.
The only issue I can see is not having the time to organize this (when I have time I put it to coding) but if that's something you are happy to try and sort out that would be great. Maybe start an issue so people can show interest as the first stage.
Comment #43
guy_schneerson commentedOn other news I am close to finishing the event plug in system. This will make it easy to configure the stock event actions (e.g. reserve stock on order complete ..) and extend it.
Comment #44
.jch commentedI'm interested in testing the stock module: Current local sandbox is Core 8.5.0-beta1, commerce": "2.x-dev", commerce_shipping": "2.x-dev", commerce_stock": "1.x-dev", PHP 7.2.2
I am searching for documentation relating to the commerce_stock module configuration and use.
Comment #45
guy_schneerson commentedHi .jch
Unfortunately we still don't have any documentation, only the issue Q. I am not planing on writing any myself before we have a beta version out. Hopefully not long now.
Comment #46
.jch commentedThanks for getting back Guy, I'll give build 48492c5227 a try. 0d94acf was throwing quite a few errors which I assume was due to a combination of proper configuration and PHP 7.2
Comment #47
guy_schneerson commentedHi .jch’s
I have just tested the latest code with the latest Drupal/commerce versions and had no issues. I am currently on a machine with an older php version (will try and test on 7.2 wen I get a chance).
I created a readme file with basic instructions. If you find any issues with it please comment on https://www.drupal.org/project/commerce_stock/issues/2946421
Comment #48
yaazkal commentedHi, I have no the time to code to this project right now, but if I have a confirmation from a new project, Maybe I can contribute money to get a beta release according to @calbasi
What's blocking the beta?
Regards !
Comment #49
.jch commentedTesting 1.x-dev Stock configuration event handling.
When dealing with one of a kind items where "Stock Level" = 1 and the item is added to cart there is no method for reducing the stock level to make that item no longer available for selection.
As a result an item with "Stock Level" = 1 can be added to a cart by one or more customers unlimited times which implies there is no add_to_cart limit on any item regardless of stock level with level <> 0.
When an item is added to cart a negative transaction on stock level should occur resulting with that stock no longer available for selection beyond its available level.
When an item is removed from a cart the positive stock transaction should occur and make the stock available for selection again.
The "order complete" event is too late in the workflow for real-time interactive stock availability processing. Carts held for more than n hours could release their stock hold on items as well as incomplete orders.
Is there a way to move / configure the stock level manipulation event forward to the cart in order to more realistically represent a shopping item selection experience?
Comment #50
olafkarsten commentedHello @.jch, thanks for your effords. I think the question is somewhat out of scope for this issue, but anyway.
I can understand your point of view, though I'm not sure, that this should be the default behavior. @guy_schneerson should know if that was an frequently requested feature for the D7 branch. I wouldn't expect that. This introduces even more complexity (release stock from cart after x). We would need another state "reserved stock" or something ...
But I can see, that this behavior is more customer friendly and leads to better UX. So we should probably provide it in the long run. But I wouldn't implement this as default.
Comment #51
.jch commentedolafkarsten,
Thanks for getting back, I can see how from an implementation point of view, why not to adjust stock levels until after an order has been completed. However from a UX prospective being able to load up a cart with more items than physically exist and then proceed through the checkout workflow does not make sense especially when you can display 'n items in stock' and the customer can load n + whatever in the cart.
Or having two or more customers with the same item in carts totaling more than physically exist. Whoever checks out first wins?
I'm working on a marketplace model where by nature all items are unique and singular and will never be replicated. For my case I could probably simply implement a hook somewhere and flip the Boolean available switch in the variation when a item is added or removed from the cart.
I can imagine other scenarios with limited actual on-hand stock quantities out of sync with system stock levels that could cause problems leading to detrimental customer experience, loss of sales, and future site traffic.
Comment #52
olafkarsten commentedAgreed. Good use case. The UX in such cases would be terrible. Though I wouldn't consider a market place with unique items as the common use case for commerce sites, right.
On the other side - if you have non-unique items (common consumer goods things), you may loss sales, if an item is in the cart, but never purchased. During the "reservation" time, other customers may leave the site.
Other store admins may want to adjust the stock level a little bit later. E.g. at the time the customers go to the checkout page, because cancelation at this point is less likely.
That makes me think, that the event that triggers stock adjustments needs to be configurable. And you somehow needs to trigger a positive stock adjustment (release reserved stock) after a configurable time. I guess thats not an easy thing todo. Furthermore, that doesn't make sense for items that are backorderable. I'm not sure @guy_schneerson likes the idea to add this to commerce stock core. Maybe this is a job for a contrib module. Howsoever, we need to keep this is mind and make sure, our code allows for such modifications.
@.jch
I see that often in the wild, for "common" shops with consumer goods. I don't think this is exotic behavior, right?
I would label this a bug. A customer should never be able to put more items in cart, than the display suggests.
Comment #53
.jch commentedHi olafkarsten,
I'm not sure why you would want to push stock adjustments further back. I think this would compound the problem. A configurable point in the flow would be ideal.
I still believe if a item was reserved at cart_add and returned to stock at remove_from_cart an accurate stock level could be maintained for items which would enable reliable item selection for customers regardless of any item acquisition competition.
As for abandoned carts there are various timestamps within the order, one of them being the field 'Created'. This becomes populated with the time the first item hits the cart. After reasonable time of say 2 hours (or configurable "reservation" time) the cart could be presumed abandoned and the contents returned to stock.
Without cart stock reservation, and even if a customer were not allowed to place an item in the cart with a quantity greater than the current "Stock Level", they or others could continue to add the item beyond the physical number in existence.
Example: If there were an item with a stock level of 5 there would be nothing preventing one or multiple customers from placing that item
in the cart with a quantity of 5 multiple times.
Comment #54
olafkarsten commentedPersonally I think the better UX is with reservation at cart_add.
But I know some people will freak out, if this would be the only option.
Because of that numbers:
https://www.statista.com/statistics/457078/category-cart-abandonment-rat...
For the avarage retailer you will block a lot of stock for nothing.
Comment #55
guy_schneerson commentedHi @.jch
This discussion should have been in its own issue. Having it in this one, makes it difficult to read other topics and will get lost over time.
In short: Your requested functionality exists but is not common and in every case I know it works on a timed expired (i.e you have 15min to complete your order) and I am not aware of any sites that do this for more then a single item at a time (i.e. single order single line item). I believe an issue exists for D7 and works with the Commerce Cart Expiration module.
It will not be available on version 1 unless it is sponsored and conforms to what I believe is a corect aprouch. I was planing at some point to expend the events functionality to support this and possibly combined with other modules.
I would recommend creating a new issue and copy the comments over so they are not lost.
Comment #56
guy_schneerson commentedHi @Yaazkal
Thanks for you kind offer.
I am waiting for DrupalCamp London that's on next weekend and hopefully will have a plan at the end of it. Will post an update after.
Comment #57
cosmicdreams commentedHi gang. I love Drupal Commerce and would like to help out. I'll be looking over things at Midcamp. Anyone else going to be there?
Comment #58
guy_schneerson commentedHi everyone
Had a catch-up with Bojanz and he is committed to finishing the availability manager in the coming weeks. This makes a beta version of stock much more feasible.
Any help in the coming weeks will be greatly appreciated and I will contact people who offered help to try and coordinate tasks.
If you want to help you can also get in touch using my contact form.
Comment #59
calbasiBy the way, there is a new module like this one: Commerce Inventory
Comment #60
guy_schneerson commentedCommerce Stock Alpha is now out :) :) :)
https://www.drupal.org/project/commerce_stock/releases/8.x-1.0-alpha1
All core functionality should be working.
known issues:
- Views integration
- Purchasable entities that are not commerce_product_variation are not fully supported
- Improvements to the API that will improve support for custom inventory / ERP integration may be introduced before beta but should not effect normal use of the module
Comment #61
luksak@guy_schneerson wow, great news! I am going to test that soon!
What do you think regarding upgrade paths? Would you use the alpha version in production for a simple use case of local stock and only one inventory?
Comment #62
guy_schneerson commentedHi @Lukas von Blarer The alpha was built to be stable and the schema should not change. I suspect that any changes will not affect your type of use cases. However this is the first version and we should monitor issues raised in the next few weeks.
Comment #63
luksakAlright, great! I'll test this in coming few days and report any issues I encounter.
Comment #64
olafkarsten commentedLets close this one. We have issues for open task and feature requests. The main work is done. The remaining stuff is business as usual.