The marketplace model is where you have many sellers who are taking payment for unique products.

Currently, there are some bottlenecks in commerce core which needs to change for implementing the marketplace model. Let's describe these here as child issues.

CommentFileSizeAuthor
#41 Capture du 2018-05-19 22-45-48.png121.66 KBzenimagine

Comments

tormi created an issue. See original summary.

mglaman’s picture

Many people have asked, and a single hurdle is Store access handling. I've written a quick proof of concept here which limits adding stores to one per user, and when making products limiting the reference to only their store: https://github.com/mglaman/commerce_marketplace.

It also exposes some major issues with references and entity permissions. I think we can get a lot of these fixed upstream in the Entity module + Core by just having entity reference selection respect "view own entity"

drugan’s picture

I've tested your module and wonder what was the reason to restrict to only one store could be created by an owner. Currently, as the site admin we may create multiple stores and assign a product to any of those stores. This is great because the same products are reusable in this case and can be presented differently in different countries.

I think that we can consider a stores(s) owner as the site's sub-admin who can administer any number of their own stores/products or even products created by other users, for example by the site's admin. The only restriction is that products not belonging to a store owner can not be edited. ...but could be sold!

bojanz’s picture

Both store-per-user and multiple-stores-per-user are valid use cases, and a real contrib would ideally support both.

The trickiest part of the marketplace model is payments. Some sites use a marketplace payment gateway such as PayPal Adaptive Payments, others use a gateway per store, or multiple gateways per store. For that use case I've started https://github.com/bojanz/commerce_store_gateways

drugan’s picture

There is an alternative to the Commerce Marketplace module, also WIP:

https://github.com/drugan/commerce_multistore

Beyond installing the module just uploading master.zip file into the modules/contrib directory you may do the following:

On existing Drupal Commerce 2.x site

Ensure your site is upgraded to Drupal Core 8.4.x version.

Go to directory where composer.lock file lives.

Then, if you want just the module, nothing more:

composer config repositories.commerce_multistore vcs https://github.com/drugan/commerce_multistore
composer require drupal/commerce_multistore:dev-master

Or, you may require it as part of the 8.4-2.x fork of the Drupal Commerce:

composer config repositories.commerce_multistore vcs https://github.com/drugan/commerce_multistore
composer config repositories.commerce vcs https://github.com/drugan/commerce
composer require --update-with-dependencies drupal/commerce:dev-8.4-2.x

Why is the fork?

Think of it as the testing environment for Drupal Commerce patches which cannot be or have no sense to be implemented in a custom module. Make your pull request on the fork, we discuss it all together, apply and test it on our development (or, why not on a production one) sites and then maintainers of the Drupal Commerce can make more easily decisions on to whether to apply it on the base project.

Also, all tests on the fork are modified to require commerce_multistore module everywhere commerce_store module is required on a test. Just to be sure that the module works flawlessly with the whole system.

Installing a new Drupal Core 8.4.x + Drupal Commerce 8.4-2.x site

Includes all the above:

composer create-project --repository=https://raw.githubusercontent.com/drugan/project-base/8.x/packages.json drugan/project-base some-dir --stability dev

The following issues are fixed by the module:

#2848232: Only show stores with permission on product creation page
#2904657: Allow a user to create only those store types which they have permission to
#2904355: Only admin should be allowed to choose/change a store owner
#2904653: Do not show the product add form for a user who is not owner of a store
#2903974: Redirect to the canonical instead of collection URL after creating/updating a store
#2900472: Views refuse to display the product type label
#2880510: Add store/ID/edit, store/ID/products, user/ID/stores views tabs
#2909501: Improve the UX of managing default stores
#2885448: How do I display the products and nodes of the same author in the current page ?
#2870053: Add store name to shopping cart when multiple stores enabled
#Update sept 20: A regular store owner should not be allowed to change their product author
#Update sept 21: Enable admin to restrict number of stores allowed to create both per store type basis and for individual store owner
#Update sept 25: Allow store owner view default currency label in views
#Update sept 26: Allow store owner view store type labels in views
#Update oct 12: #2897698: With a view catalog, only the first product variations works

Also, the Label Compact configurable formatter is added to display list of referenced entity labels wrapped into details HTML element. In our case it is product variation labels but actually could be used for any referenced entity.

Update sept 27: the Compact options list configurable formatter is added to display list of billing and tax registration countries wrapped into details HTML element (if countries > 1, otherwise raw country name displayed).

Update oct 2: Added Products operation link for a store entity. So, products belonging to a store can be quickly accessed from the admin/commerce/config/stores or user/ID/stores view.

More features to come. Add yours one.

rbarreca’s picture

I'm looking to the feasibility of the following multi-store set up for an online local food marketplace. Just listing my requirements to spur any thoughts.

Many farms organizations with many associated farm manager users (i.e. Waialua Farms with Rob and Dan as managers) can create products and set inventory (i.e. 30 lbs of broccoli available this week). Newly created products or products whose "major" attributes (i.e. title, photo, unit of measure) were updated might require marketplace manager approval before going live.

There are many buyers (i.e. chefs, grocery managers, individual consumers) that can view all available inventory from all farms and make one easy purchase with credit card or purchase order/invoice and we collect payment later.

We collect payment and then pay farm vendors every other week for their share of the sales. I think paying marketplace vendors directly should not/does not need to be default behavior. There are cases like ours where it is necessary (due to collecting payment from buyers on terms, refunds for produce that goes bad after delivery, etc.) for the market to collect and hold money, then pay out vendors. The pay out can easily happen manually off-site, for example by check or BillPay, so that makes sense to me to separate into its own optional module.

Other requirements:

  • recurring subscriptions for items (i.e. automatically order and charge me for 20 lbs broccoli, 2 pints of honey, and 10 packs of chicken from these specific farm vendors if available every X days)
  • inventory management: be able to split inventory across multiple units (i.e. I have 100 lbs of broccoli available to sell this week and can sell by 20 lb case or by the pound)

goodeggs.com is a good example (use zip code 94110)

londova’s picture

Hi,
Thanks for the interesting topic. I have a question related to payments in marketplace environment.
Who is the payment beneficiary? Which entity are (receiving) payments belong to: the store or the owner (user)?

torgospizza’s picture

@Londova In a perfect world, both: the "store owners" (part of the marketplace) get paid for their goods or services, and the site owner usually receives a small portion of those funds as part of a fee structure. That's similar to how eBay, Etsy, and other such sites work.

drugan’s picture

@londova

The payment beneficiary should be the store owner. For this to happen they need their own payment gateways. That's not an easy task to perform. The Commerce Store Gateways has been started to make it possible. Though it has no actual functionality yet. I am also waiting for this to appear because it is basic requirement for the Commerce Multistore module. If you install both the modules then Payment gateways tab will be displayed in a row of a store administering tabs (View|Edit|Products|Payment gateways) and could configured by a store owner for their needs.

londova’s picture

Hi,
Thanks for the explanation.
Are there plans for Marketplace to support multi-domains?

londova’s picture

Hello everybody,
Are there intentions to publish the "alpha" version of the above mentioned modules?
Thanks

bradjones1’s picture

Taking a read of the above, it sounds like folks have a set of varying use-cases, and this also highly dependent on the payment gateway and marketplace payout approach. E.g., for Braintree Marketplace, there is actually one master payment gateway with sub-merchants onboarded at Braintree with a sub-account, and then service fees are split and disbursed at Braintree.

In other scenarios described above, the site owners would process payments and then initiate some sort of payment to the sub-merchant through a third-party service. Each scenario means a potentially very different implementation.

I think to move this forward, development time would either have to be sponsored or there should be a more concrete roadmap of which scenarios are supported through which suite of modules. E.g., for Big Island Fish, we are tightly integrated with Braintree and so our technical setup reflects that.

NewZeal’s picture

+1 for commerce_multistore. I've cloned it and will test.

andrews501’s picture

@drugan

I noticed your Commerce Multistore module. Good job!

Do you think could be possible to add an Access Control tab in each store, similar to Node access control? So instead of granting access to that entire store type by role, grant it on a user-by-user, store-by-store basis.

Currently, in order to grant that entire store type by role is done through Permissions only. It would be nice that stores also can't have different access control as Nodes.

Or even better, granting access to each store field, grant it on a user-by-user, field-by-field basis.

drugan’s picture

@andrews501

The idea of replicating access control from the node entity is a great one and should be explored. Nevertheless, I see the possibility to implement our custom access control mechanism to an owner store and store (owner's) products. It could be done by adding a simple "closed" property to a store entity and its products. The store property can be accessed both by the store owner and admin but the difference is that the owner is able to close the store (and its products) but to reopen it again can be done only by admin. Also, all the products belonging to the store will be updated with the "closed" property changed to TRUE. So, the access handler forbid any access to these products to all users except the admin. No matter, whether they are published or not, they'll become invisible. The issue when a product is assigned to multiple store owner's stores could be also fixed on the access handler. "If the product has stores > 1 then do not forbid". For convenience purposes the "close store" and "open store" VBO actions could be added to the admin/commerce/config/stores view.

As for the field-by-field access control for now I can't anything to say except that it is quite a complex task. Remember, a store type may have custom fields added and the access requirements for those fields can't be predicted.

Looking forward for having free time for this work to be done. Besides this I have some other ideas for the commerce_multistore and the main of those is implementing actual functionality on the https://github.com/bojanz/commerce_store_gateways module. Without this the commerce_multistore cannot be dimmed as the true marketplace functionality module.

rob c’s picture

I've been doing some work on the problem of assigning people to stores for a project i'm working on.

A physical store has multiple roles. Owner, Employee, store manager, etc. In a franchise environment it's even more complex, there you also have a franchise manager and the distinct separation of company and franchise stores.

I ended up creating a module that offers a way to assign users to stores, so they kinda become a group. Users have access to multiple things based on this assignment.

Why: because a franchise store owner is not able to add/edit products in most cases (but not all) and store employees should be able to sell products, but nothing else, except for the store manager (franchise or not) (and the company manages stores and status, franchise owner can only change details).

I had to rewrite some Commerce code and especially other modules like stock to pull this off, because of this radical access requirement.

For simple multi store implementations a node access-like setup will work, but the more complex cases prolly require something more. Maybe commerce_groups would be a nice idea for a new module in this direction, but that's just me dreaming a bit ahead.

drugan’s picture

@Rob C

Sounds great! It would be interesting to look into the code if you'll ever decide to share it.

zenimagine’s picture

@Rob C

It would be nice to have something similar to the "Group" module. That is, manage roles and perceptions directly in the store.

It would be useful to use "Commerce POS" and assign the cash payment to a cashier.

https://www.drupal.org/project/group

rob c’s picture

@drugan i might release parts of the code as soon as it's a bit more mature / stable, first looking for some feedback :) (and an ok from upstairs).

@zenimagine that's one of the reasons, commerce_pos is part of this project. So yes, i believe the same.

andrews501’s picture

@drugan

The case is :

The owner marketplace wants to offer products of different stores but without providing each store details to the customers so they don't contact the store owners. Also the marketplace owner has its own store or warehouse. For this reason Access Control for each store would be nice to have in order to allow view access of some stores and others not. A concept very close to dropshipping int he US.

I will be happy to do any testing of modules if this helps.

drugan’s picture

@andrews501

Now I see what you mean. I had the request for building a module providing similar functionality but just did not know the name for this sale method in English (dropshipping). Fairly speaking I did not even imagine that it could be so proliferated and thought of it as the specific one. The difference in the request was that a customer should be able to purchase products not only from the current site stores (or any other own sites) but also from the third-party sites like amazon or ebay.

So, what I can suggest. I've made a commercial offer for building the module and now waiting for the answer. If the answer will be positive then it may happen that the module owner can share it with others making it public. If it's not, then most probably I'll make this module for my own needs and share it with others some day.

Thank you for the hint because I've found the trend quite interesting :).

freelylw’s picture

Hi @drugan , Do you have a plan/time to publish your "commerce_multistore" on drupal.org to start as a project ?

drugan’s picture

@freelylw

Now I've asked for commit access for D.O commerce_marketplace module because this name is more appropriate for the module. As soon as I get approval I'll publish the module on D.O. See:

https://www.drupal.org/project/commerce_marketplace

Donit’s picture

@drugan Any news on this? And will it be a D7 or D8 version?

drugan’s picture

@Donit

I am working on it when I have free time. Hope it will be published on D.O on the next weekend.

Donit’s picture

Regarding payments: As bojanz mentioned in #4, it's one of the trickiest parts. There were recently some efforts by the Commerce Guys (lisastreeter & rszrama) on Stripe Connect (https://www.drupal.org/project/issues/search?issue_tags=connect). Not quite done there in order to offer full functionality, but with Stripe Connect, which offers real marketplace payment routing, it's going into right direction. As torgosPizza mentioned in #8, something real-life functioning needs one-to-many routing (https://stripe.com/connect#routing-payments): from customer to platform, from platform to stores. As far as I can tell, the missing part is currently connecting the stores, as Stripe accounts, with the site, as the platform on Stripe #2969422: Create Commerce Stripe Connect Accounts.

bradjones1’s picture

I would echo that any general API for marketplace needs to handle payments in a way that isn't too tightly coupled to a particular platform's API. Stripe looks super interesting, but I'm not personally very familiar with it. In the case of Braintree, some custom logic needs to be in place at the moment to configure the API call on payment creation to include the proper submerchant metadata. Additionally, one-to-many payments, e.g., one charge split to three recipients (sellers A and B with service fees from each due to master merchant C) are not supported on Braintree, but might in other contexts. And I believe at the moment, payment methods are tied to stores, which means in that case that we can only really use one store without having to basically re-configure what is basically the same payment method across all of them.

I'm not particularly sure what the "right" answer is for any of that, but it's worth considering before we paint the ecosystem's API into too much of a corner.

drugan’s picture

The commerce_multistore is now moved to the commerce_marketplace namespace on D.O:

https://www.drupal.org/project/commerce_marketplace

I've asked maintainer to make a dev release of the 8.x-1.x branch, so soon it will be available as a tarball too.

Still, the module lacks per store owner payment gateways support which hopefully will be added in the https://github.com/bojanz/commerce_store_gateways module. If you install both the modules then Payment gateways tab will be displayed in a row of a store administering tabs View|Edit|Products|Payment gateways) and could configured by a store owner for their needs.

zenimagine’s picture

@drugan Thank you for your work, but when I go on the module there is no version for drupal 8

drugan’s picture

@zenimagine

Unfortunately, I have commit access to the module repository but can't create new releases (no permission). I've sent a PM to the initial module maintaner and hope he will do the release in the next few days. For now you can clone the 8.x-1.x version using git but I'd recommend wait untill a tarball of the module could be downloaded either manually or using built-in drupal install/update system or with composer.

tormi’s picture

Big thanks, @drugan for the module!

@zenimagine, you can also add commerce_marketplace from GitHub using Composer (howto: https://drupal.stackexchange.com/a/243585).

zenimagine’s picture

Thank you, I will wait until it is available on drupal.org

- When a merchant creates a product, will he only sell his stores?

- Same question for orders, promotions, shipping methods and payment methods?

drugan’s picture

The commerce_marketplace tarball is now ready for downloading:

https://www.drupal.org/project/commerce_marketplace/releases/8.x-1.x-dev

Any suggestions or contributions are welcomed.

zenimagine’s picture

Good news. Can the module be used in production?

drugan’s picture

@zenimagine

Any dev version should be considered as unstable and might be used (or not) in production for your own risk.

All the features of the module are described in the #5 comment. Basically, even being uninstalled the commerce_marketplace does not break anything reverting to the initial state that was before installing it. The only thing you should to consider there is no backward compatibility promise because now the module have no per store owner payment gateways support yet. As soon as it will be available then the first alpha release have to be done which can be advised for use in production with some notices.

zenimagine’s picture

@drugan

Thank you. I installed it in production because it is necessary that when a merchant adds a product, he sees only his stores.
And also because of the many bug (only the first variation changes, the type does not appear) of Commerce.

There are problems with broken fields in the module view. I opened up problems for that.

zenimagine’s picture

@drugan I am experiencing a PHP error when I go to a product containing view or a product page. I have a blank page with "The website encountered an unexpected error. Please try again later."

If I log out, the anonymous user does not have this error and everything works.

If I connect with a user who does not have a store, he can not see the merchant's products because the error is displayed on the blank page.

TypeError: Argument 2 passed to Drupal\commerce\Context::__construct() must implement interface Drupal\commerce_store\Entity\StoreInterface, null given, called in /home/www.domaine.com/public_html/web/modules/contrib/commerce/modules/order/src/Plugin/Field/FieldFormatter/PriceCalculatedFormatter.php on line 169 in

drugan’s picture

@zenimagine

Seems that somehow a default store is not resolved in a chain of store resolvers. I can't even imagine how it could occur.The commerce_marketplace makes its best to ensure that there always will be at least one default store even there is no explicitly assigned default stores at all.

I am experiencing a PHP error when I go to a product containing view or a product page.

The view of a store owner products like http://test.me/store/3/products can be viewed only either an admin or this store owner. If you need these products viewed by other users you should create a custom products' view for this purpose.

Please, visit http://test.me/admin/commerce/config/stores page and check if you have a global default store assigned by admin and a store owner default store assigned either by admin or a store owner. Then check permissions for a store owner, authenticated user (not any store owner) and anonymous user. I'd recommend to assign the Marketplace owner role provided by the module for a regular store owner and check if other roles of this user don't conflict with owner permissions.

Also, if you have some specific requirements to resolve a store for you users you can create your own DefaultStoreResolver and return whichever of site's stores you need.

zenimagine’s picture

The problem is that if I create a custom view of the products, the error is displayed.

Any pages that display a product will cause this error.

drugan’s picture

@zenimagine

Please, open an issue verbosely describing everything required to reproduce it:

https://www.drupal.org/node/add/project-issue/commerce_marketplace

zenimagine’s picture

StatusFileSize
new121.66 KB

@drugan

I'm going to open a problem tomorrow. Here is the screenshot of the stores

zenimagine’s picture

@drugan

The relationship between the product and the store no longer works :

https://www.drupal.org/project/commerce_marketplace/issues/2984731

This problem makes the module unusable.

Even for a simple showcase site (without sale).

zenimagine’s picture

Hi, is the module abandoned ?

drugan’s picture

@zenimagine

I am really sorry for that I can't support commerce_marketplace right now because working on some project and have a strict deadline but... if you know some developer who can make a patch to fix the issue as in your comment then I'd be glad to review this patch as soon as it will be ready. Otherwise, please wait until November at least.

zenimagine’s picture

@drugan Thank you for your reply. Unfortunately I do not know a developer. I will wait or look for another solution :-(

zenimagine’s picture

@drugan The problem below is corrected with Commerce 2.10
Will it create an compatibility problem with Commerce Marketplace?
https://www.drupal.org/project/commerce/issues/2499645
https://www.drupal.org/project/commerce/issues/2810723

https://www.drupal.org/project/commerce_shipping/issues/2974155

karamveersingh’s picture

I am not sure my this https://www.drupal.org/project/commerce/issues/3086771 requirement is matching with this thread but there is very eagerness to get to know the answer, please respond asap thank you.

zenimagine’s picture

The module breaks Commerce since version 2.16 and it has become unusable:

- The administrator receives an error page if he tries to modify a store.
- The store owner can no longer duplicate a product variation.
- When the command "drush updatedb" is executed, an error message appears and requests to update Commerce to version 2.16 (Commerce is already in version 2.16).
- ...

It is urgent to release a new version of Commerce Marketplace.

It would be great if this module was a Commerce sub-module.

Thank you

jack2222’s picture

Hello,
For some reasons this new release is creating issues with the newest version of Drupal Commerce.

bradjones1’s picture

The module issue queue is the right place for those comments, please and thank you. :-)

juggernautsei-2’s picture

Hello,
I have started the install according to all the information above. I have an error message that I can't get past. I am on a ubuntu 18.x server with PHP 7.2. I used composer to install the app.

My error message is this
[Wed Mar 25 10:32:00.630807 2020] [php7:error] [pid 994] [client] PHP Fatal error: Class Drupal\\webprofiler\\Entity\\Decorators\\Config\\ConfigEntityStorageDecorator contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Drupal\\Core\\Entity\\EntityStorageInterface::restore) in /var/www/html/marketplace/web/modules/contrib/devel/webprofiler/src/Entity/Decorators/Config/ConfigEntityStorageDecorator.php on line 18, referer: http://mymarketplace.com/core/install.php?rewrite=ok&profile=commerce_ba...

I have checked permission. They all seem to be ok. What do I need to look for?