-
Notifications
You must be signed in to change notification settings - Fork 2
Unable to add product to cart if stock is not configured. #698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Does the product node have an actual stock property on it? |
It does not. |
Having similar problems, there seems to be a major bug or breaking change introduced in 15.3. I today updated a project to use Commerce 15.3.1 from 15.2.2 and suddenly it's impossible to add products, any product to the cart, also a workaround with adding a stock property doesn't work, it seems the Stock property isn't binding to IPublishedContent... I do have a custom productadapter in place, removing it for the default makes adding products work again |
Yea, in 15.3.0 some extra validation handlers were added to ensure an item being added to the cart doesn't exceed the stock of an item, however these shouldn't trigger if there is no stock property editor on your node. @nickfrederiksen are you also using a custom product adapter? I've got a workaround I can give you but I'd like to figure out what the actually bug is here as on my local environment, a product with no stock property editor on the product doc type doesn't trigger the validators |
@mattbrailsford |
Yea, product adapters aren't really responsible for managing stock levels so it's weird if they are connected 🤔 |
Ahh, ok, I think I might have found it |
@mattbrailsford Calling GetProductSnapshotAsync on my product adapter calls the base class method: The result has an iPublishedContent for item1 (the product). When i add a stock property to my document type i see the value correctly in the properties collection, but the actual property Stock on the model shows 0M as value, maybe a valuebinder problem? |
So I think the problem is when we work out the stock, we have to try and work out where the stock is stored because we can have nodes with no variants, nodes with child variants, and nodes with multi variants. When we work that out, we request the a product snapshot and see if it is Ultimately I think this needs updating to return a default stock of A quick test your end might be to have your product adapter return a product snapshot that implements I'll do a quick build though with the default stock defaulting to |
There should be a 15.3.2--preview.4 build on the nightly feed that sets the default stock to |
@mattbrailsford Thanks for the quick action on this, just to make everything complete, I implemented the IUmbracoProductSnapshot interface on my custom ProductSnapshot that previously only implemented IProductSnapshot. This also fixes the issue and makes adding products (without stock property) work again |
Same issue. All I do in my adapter, is to get the snapshot using base.GetProductSnapshotAsync, and then manipulate the Prices property. |
@nickfrederiksen by "same issue" you mean running |
@mattbrailsford correct. |
@nickfrederiksen ok, so is there anything else custom about your install? Have you implemented a custom |
@mattbrailsford tons, but nothing I can see is related. We have some notification handlers for OrderLineAddingNotification, but no custom validation or anything else. Most customizations relates to checkout. We do have a custom discount rule. But that only checks for the current session and some custom database entries. |
Is the product being added to the cart a simple product? or a bundle? |
Simple product. Nothing fancy. |
Did your node EVER have a stock property on it? |
Never. |
if you look in the |
It does. And it is set to 0. Could it be a bug where a default 0-value has been added on save if no stock property has present? |
It very well could be as it shouldn't be storing a zero value, and it definitely shouldn't be storing a value for a product that doesn't have a stock property on it |
Do you have other entries with zero values? |
I do. I'm currently trying to get a list. But it seems to only be a few products. Those that has been saved after the upgrade. |
You mean republishing the product content node? |
Yes. |
Have you been experimenting with the partial refunds feature at all? I may have found an edge case here |
No. I haven't. Not yest. |
Shoot! Was hoping that was it. Struggling to think of other scenarios that would cause the stock to get updated in the stock table. |
I've raised an issue here with details of the edge case I've found #699 |
So @nickfrederiksen I can give you some code to disable the new validation event handlers which would solve the problem for you for now, but I really would like to figure out why you have stock levels in the DB at zero. The issue above is the only way I've managed to replicate it at the moment. |
@mattbrailsford Sure, let me have it. At least it will make things work for now. |
You can add this in your
|
Seems to be working now. |
Ok, I've pushed a 15.3.2--preview.6 to the nightly feed (should be there shortly). It would be good to know if you comment that code back out, and then maybe delete any stock db entries with a value of |
@mattbrailsford Seems to be working now. Also after a save-and-publish on a non-stock product. |
Ok great. Then I'll consider it fixed, but if you do come across it again, please let me know and you've always got the code snippet in your back pocket to get it back to working. |
Thanks! I have kept a note on the workaround. |
Which component is this issue related to?
Umbraco Commerce (Core)
Which Umbraco Commerce version are you using? (Please write the exact version, example: 10.1.0)
15.3.1
Bug summary
There's an issue where a product that has no stock information configured, can't be added to the cart.
I get this error:
Insufficient stock: Product '9bdde03e-7339-4e58-9321-f03c92d3c9f4' has 0,000000 item(s) left, but 1 were requested.
We have no custom validators and this issue seems to have been introduced with the 15.3.0 update. The product does not have stock and should therefore not be validated as such.
It's rather critical for this to be fixed.
Specifics
No response
Steps to reproduce
Install 15.3.0 (or 15.3.1).
Create product with no stock property.
Add that product to the basket.
Expected result / actual result
Product should be added. With no error.
Dependencies
No response
The text was updated successfully, but these errors were encountered: