The tracking of available items cannot be disabled, even when inventoryPolicy and inventoryManagement are are set to false, and the inventory plugin is disabled.
When inventory is disabled, approving an order in the backend should not alter inventoryQuantity.
A product can be ordered with inventoryQuantity 0, and the checkout can be completed.
As soon as the the Admin clicks Approve in the backend, the inventorQuantity gets decremented -1, no matter which values inventoryPolicy and inventoryManagement have.
Further tries to add this product to cart will fail, as the inventoryQuantity will go below 0 at some point, so the Product can't be validated against the schema anymore - The addtoCart method throws an error.
Create a variant, use a GUI like Robomongo to monitor its inventoryQuantity field.
Disable inventory plugin, and inventory tracking of the variant.
Set its quantity to 0, add one to cart, checkout and approve.
Notice that inventoryQuantity changed to -1, and adding it to Cart again will fail.
Latest - 1.4.1
Hey @aaronjudd, I just noticed the needs-more-detail label.
Were you unable to reproduce the issue? - Which further information can I give to help out?
To sum it up, from what I see atm there is no proper way to disable inventory and stop products from running out of stock.
The main issue:
The method that is triggered when you click Approve for an order does not check for inventory tracking, and will always decrement inventoryQuantity by 1.
Instead, if the product/variant has inventoryPolicy/inventoryManagement set to false, it should not alter that value at all.
There are those three possible situations;
If Inventory tracking is enabled in the product, it will run out of stock, display an inline alert for the user and can't be added to cart anymore(like expected).
Furthermore, if the inventory plugin is enabled, and Quantity is zero, no matter if the product has inventory tracking, approving the order in the Backend throws an error and won't succed (inventoryQuantity smaller than 0 => Invalid Schema).
If inventory plugin is removed, and the product has inventory tracking disabled, Approving an order in the backend works, but will still decrement inventoryQauntity, so addtoCart will throw an error as soon as Quantity goes below zero.(=> Invalid Schema).
@janus-reith 馃憤 thanks that helps. Feels like we also need to look at why the schema is enforcing a positive number as well, as this is an optional functionality enabled in the product (allow backorder). So it should be possible to be a -1 which is part of the errors that you are seeing. (as in the removed scenario-> that should work).
Yep, removing this
would probably solve the issue, but furthermore there should be a better solution instead of an infinitely negative counting field for stores that don't use inventory.
Okay, that alone doesn't solve it.
Although removing the min field resolves the schema error,
adding Variants to Cart that have a Quantity <= 0 still fails due to a check in quantityProcessing of cart.js.
Hey guys, I would like to work on this issue. Will try to put together a PR in a few days.
@Akarshit has this been resolved by #2825
@janus-reith what's the best way to verify that this has been fixed?
Took a quick look at the PR, both the schema and the change for the addtoCard method I mentioned have been taken into account - looks fine to me so far.
I also didn't experience the issue on the marketplace branch anymore.
Simple way to verify:
Create a variant with inventoryQuantity 0. set inventoryPolicy/inventoryManagement to false.
Add to card and finish checkout, approve the order in the backend.
Observe how inventoryQuantity is decremented.
Maybe we should still keep this PR open, as the following still bugs me a little bit:
inventoryQuantity is still being altered, and starts to count negative
In 1.4.1 the value was decremented after Approval in the backend, not sure if that changed in marketplace. We should modify that function that is triggered there to check inventoryPolicy aswell and not decrement if disabled.
@spencern Will look into what @janus-reith said.
This original issue (cannot disable inventory) seems to be resolved so I am closing this issue. It would appear the issue of decrementing the inventory to negative has been resolved as well.
Most helpful comment
@spencern Will look into what @janus-reith said.