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

Better error when submitting order with out of stock product #387

Closed

Conversation

marlena-b
Copy link
Collaborator

Issue: #375

Before when a product was added to an order and subsequently went out of stock before submission, the system incorrectly showed a success message "Your order is being submitted" while leaving the order in draft status. Now it shows "Order can not be submitted! Product not available in requested quantity!".

Zrzut ekranu 2024-08-26 o 10 48 44

I don't like my solution but I didn't know how to do it better. I see a few problems here:

  1. There is no information which product is out stock, and it will be hard to get.
  2. We assume that if order is not submitted then it is becasue of out of stock products. This assumption might not work in the future when e.g., an order is not submitted because it cannot be shipped to a certain location.
  3. It feels weird to fetch a read model to check the result of a command

I didn't know how to do it better because the error InventoryNotAvailable" is rescued in the ReservationProcess event handler and I would have to delete a lot of code to rescue this error in the controller and show this flash, which I think would break the intended original design.

I'm happy to close this PR if it doesn't fit the architecture, no hard feelings 😄

Copy link

netlify bot commented Aug 26, 2024

Deploy Preview for ecommerce-events failed.

Name Link
🔨 Latest commit ca1bd16
🔍 Latest deploy log https://app.netlify.com/sites/ecommerce-events/deploys/66d4ae20d4754f00091de78b

@marlena-b marlena-b marked this pull request as draft August 28, 2024 10:25
@marlena-b marlena-b force-pushed the order-with-out-of-stock-product-better-error branch from c858eb8 to ca1bd16 Compare September 1, 2024 18:10
@marlena-b marlena-b closed this Sep 1, 2024
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

Successfully merging this pull request may close these issues.

1 participant