Closed gullible1 closed 3 years ago
Have been looking at this. There is one potential problem that needs addressing. Where do we store the quantities of products sold/available?
products.json
but we cannot update it without doing a IPFS deploy of that file during each order placement/cancellation. products.json
or query from backend? Also, adding products to DB means that shops won't work without backend. cc @nick @franckc What do you think about this?
I think we can have a products model in the DB, but only store limited information, perhaps just starting out with productId and inventory. In products.json, we can specify that the frontend needs to lookup availability, something like checkInStock: true
. We can then add an endpoint /products/in-stock
that accepts an array of productIds and returns an object with true / false values depending on if the product is in stock or not.
@nick So, disable inventory check if backend is unavailable?
Also, I guess we can have the checkInStock
boolean in config.json
instead of having it for each product
In config.json
works, sure. If we need to later on, we can put an override in products.json (eg if there are some products in the store with stock and some without).
If the backend is unavailable and stock checking is enabled, we should show an error to the user.
Got it. Thanks for your comments :)
+1 for a products model where we store the number of items still available.
If we do that would be great to tie the orders table with the products table. So that we can track a product availability change to orders. A typical way would be to have a carts table. Carts stores a list of product ids and an order id. Cart data is equivalent to the offer data that we currently store on IPFS. In order to improve reliability we were already discussing storing that data in the DB as well. So perhaps upon checkout the following happens
Done with #730
A number of merchants who sell "unique" items need to be able to set a limit for the quantity of each product they sell.
[ ] There should be an extra field when creating a new product for "quantity available"
[ ] The product page should display "sold out" to a potential buyer if no inventory is left (see on Zeplin here and here)
[ ] This option should be disabled if the store is sync-ed to Printful