Skip to content
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

Can't backorder variants if inventoryManagement is false #5123

Closed
janus-reith opened this issue Apr 13, 2019 · 2 comments
Closed

Can't backorder variants if inventoryManagement is false #5123

janus-reith opened this issue Apr 13, 2019 · 2 comments
Assignees

Comments

@janus-reith
Copy link
Collaborator

Issue Description

When inventoryManagement and inventoryPolicy are disabled for a variant, I am not allowed to order more than the available quantity.

I don't expect to have to turn on inventoryManagement to be able to allow backorders.

Steps to Reproduce

Please provide starting context, i.e. logged in as a user, configure a particular payment method.

  1. Create a product with variant
  2. In the variant, turn on allow Backorder ( just be sure, it will be greyed out in the next step)
  3. Turn of Manage inventory
  4. Publish
  5. Try to order any amount higher than the quantity that variant has
  6. Get error "Quantity ordered is more than available inventory for ..."

Possible Solution

The issue happens during publish and is not related to the order process.
Catalog item does not have canBackorder = true as the check fails.

buildOrderItem fails here, as canBackorder is missing:

if (!chosenVariant.canBackorder && (quantity > chosenVariant.inventoryAvailableToSell)) {

createCatalogProduct is using a separate funtion to determine wether canBackorder should be true:

canBackorder will only return if inventoryManagement is true:

return variants.every((variant) => !variant.inventoryPolicy && variant.inventoryManagement);

Why is this check necessary?
canBackorder should always be true when inventoryPolicy is false or not present

It should be just:
export default function canBackorder(variants) { return variants.every((variant) => !variant.inventoryPolicy); }

Further thinking

Maybe that check should be the opposite of the original:
only return false if inventoryManagement and inventoryPolicy are both true.

But currently, the product admin UI allows to set "Manage inventory" and "Allow backorder" independently, altough I would expect "Manage inventory
" turned of to grey out "Allow backorder" aswell.

But Im not sure what usecases might be there, maybe this is on purpouse?

For example someone needs to limit the quantity per order, which would be possible with that current implementation were both values are decoupled. <-- But this is still confusing and should, if necessary be implemented separately, as it is more of a trick using the current implementation.

Versions

v2.0.0-rc.11

@aldeed
Copy link
Contributor

aldeed commented Apr 29, 2019

I believe it's always been this way, and until recently the UI did grey out. You bring up a good point, and I agree with the theory that they should not be related. The ability to backorder is currently tied in with the inventory plugin, but it should be more the concern of the product/catalog plugins. We'll have to see how easy it is to disentangle.

@aldeed
Copy link
Contributor

aldeed commented Jun 4, 2019

Fixed by #5164. Without inventory tracking enabled, the default behavior is now to allow purchasing any quantity. Also, #5186 adds a shop-specific setting that can be used to change this behavior. Some installations need untracked products to be considered sold out.

@aldeed aldeed closed this as completed Jun 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants