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

Adjust available quantity when product placed in shopping cart #24

Open
asvishnyakov opened this issue Apr 23, 2019 · 1 comment
Open

Comments

@asvishnyakov
Copy link
Contributor

asvishnyakov commented Apr 23, 2019

@kamilgarey commented on Tue Apr 23 2019

Available quantity should be equal to InStockQuantity - ReservedQuantity(Sum of all quantities that placed to shopping cards).


@kamilgarey commented on Tue Apr 23 2019

I'll make PR for this.


Currently, we do not recalculate inventory if customer(s) added their products to the cart. So we have two business cases which uncovered on our system:

  1. Product has available quantity = 5, customer add 5 to cart, product still have available quantity 5, customer can add yet another 5 to cart (totally 10 in single cart)
  2. Product has available quantity = 5, customer A add 5 to cart, product still have available quantity 5, customer B can add yet another 5 to cart (totally 10 in two carts)

Proposal:

  1. Use currently non-used ReservedQuantity to store information about reservations
  2. Add AdjustInventoryCartChangedEventHandler in the Cart module. Set Reservation to delta between previous and current quantity of product in the cart
  3. AdjustInventoryCartChangedEventHandler should use same workaround with Hangfire as we do AdjustInventoryOrderChangedEventHandler in order to prevent data inconsistency because of concurrence
  4. We don't need to extend AdjustInventoryOrderChangedEventHandler because cart is deleting as part of order creation process
  5. On storefront we need to calculate AvailableQuantity of product as InStockQuantity - ReservedQuantity
  6. We need to add expiration mechanism for reservations. Still be open question. Proposal:
    6.1. Add expiration time property to cart object
    6.2. Move inventory adjustment method to separate singleton service with race tracing protection using Hangfire
    6.3. Call inventory adjustment when cart changes or by recurrent hangfire job with configurable time
@asvishnyakov
Copy link
Contributor Author

@tatarincev @yecli @kamilgarey FYI

@t13ka t13ka removed this from the Operations milestone Dec 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants