OriginProtocol / dshop

Origin Dshop - launch your own decentralized store
https://www.originprotocol.com/dshop
MIT License
138 stars 87 forks source link

Set limit for product quantity #632

Closed gullible1 closed 3 years ago

gullible1 commented 4 years ago

A number of merchants who sell "unique" items need to be able to set a limit for the quantity of each product they sell.

shahthepro commented 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?

cc @nick @franckc What do you think about this?

nick commented 3 years ago

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.

shahthepro commented 3 years ago

@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

nick commented 3 years ago

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.

shahthepro commented 3 years ago

Got it. Thanks for your comments :)

franckc commented 3 years ago

+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

shahthepro commented 3 years ago

Done with #730