Open alexsegura opened 4 years ago
I'm not sure it was a good idea to have closed the issue #1518.
It could take probably months to complete this "refactoring": I don't think on the other hand that's is so hard to change only the denomination of the stores in clients on the interface: and this would solve some misunderstandings since "stores" wouldn't be used in two different meanings on the platform.
In general it should be taken in considerations that the clients of the normal same-day-delivery business can be also "private persons" using the service regularly and paying on invoice. These clients are not necessarily always "shops" or "businesses".
I don't think it's worth opening a new issue.
I'm thinking maybe we can refactor the platform with this hierarchy:
Store
restaurants
)stores
)store
is the general word used on the internet I think for online shops.
a restaurant is not necessarily the only kind of store
that can have an e-commerce presence.
e-commerce can be any kind of store. non e-commerce can also be any kind of store.
I'm commenting this as I'm thinking about the documentation. So in the docs we should have a guide for creating a e-commerce store
or a non e-commerce store
on the platform.
I'm unsure about my previous comment.
Mex, are you proposing to have 1 business account, either e-commerce or non-ecommerce? With a sort of toggle, when it's ON that business can be seen on the front-end for customers to purchase and if the toggle is OFF that shop disappears from the front-end?
The problem
One of the main design problems we have, is that "B2B customers" (i.e, customers that don't have a customer-facing page) are represented as a
Store
entity, under the/api/stores
endpoint.The have a slightly different behaviour & features. For example, a
Store
may have aPricingRuleSet
& aTimeSlot
.Actually, a
Store
& aRestaurant
are pretty similar. They are both aLocalBusiness
, and bike messenger companies deliver their products. The bike messenger company may deliver their products to customers, or businesses (or both).The biggest difference is that a
Store
doesn't have customer-facing page.No matter if this is a
Store
or aRestaurant
, the main question is:So it's more a matter of "enabling" online shopping for a
Restaurant
or aStore
.Introducing Shop concept
For a better separation of concerns, a customer-facing page should become a first-class citizen. A pretty simple way to do this is to extract all the logic into a
Shop
class. AShop
just exposes the catalog of aLocalBusiness
online.A
LocalBusiness
, no matter if it is aStore
or aRestaurant
, may have severalShop
. This would easily fix the problem of franchises, where the same restaurant brand has several locations in the same city, with more or less the same catalog (currently, they are duplicated).This would also allow to easily add online shopping later for a B2B customer. Since the beginning of the COVID-19 pandemic, we have seen lots of businesses switch from B2B to B2C.
Refactoring
The
Restaurant
&Store
entities should be unified under a singlelocal_business
table in database, with inheritance mapping. All the entries in thestore
table need to be moved to thelocal_business
table. We will lose the previous ids but YOLO.A
LocalBusiness
may have one or manyShop
The catalog of products should be abstracted instead of being named a
Menu
. We can still expose a/api/restaurants/{id}/menu
API operation but only for restaurants, for stores it should return a 404.On the opposite,
Restaurant
should be closer to the wayStore
behaves, regarding deliveries for example. Currently, deliveries may be associated to aStore
, but not directly to aRestaurant
(the relationship is restaurant <-> order <-> delivery).API endpoints (to be confirmed)
/api/shops
should slowly replace/api/restaurants
/api/restaurants
should be kept for backward compatibility/api/shops/{id}/deliveries
should retrieve the collection of deliveries of a shop/api/local_businesses/{id}/shops
should retrieve the collection of shops for a business