Drupal Commerce Blog

What's happening in the world of Drupal Commerce.

Commerce 2.x Stories: Stores

Last time we talked about currencies. Now it's time for arguably one of the biggest new concepts in Commerce 2.x: stores.

Stores represent billing locations, and were made to cover these two primary use cases:

  1. One business with multiple billing locations

    The same product catalog is used for all stores. Customers always belong to a single store, usually based on their billing address.

    Example: Commerce Guys has a French office and a US office. These offices are separate legal entities. People who purchase Platform.sh are billed from one of the offices based on their location. EU customers are assigned to the French office, North American customers to the US store.

  2. The "Etsy" marketplace model

    Sellers can open accounts on the site, create and sell their own products.

    The product catalog is store specific. The site lists multiple stores, each with their own products. Products are grouped into carts/orders per store.

Implementation

Stores are content entities. They contain the following information:

  • Email (used on order confirmation mails)
  • Address (shown on invoices)
  • Supported billing countries (restricts the country list shown on checkout)
  • Tax settings

Knowing the store address is a big help when resolving tax types. E.g, if the customer is German, and the system knows that the store is located in France, it can select the French VAT by default.

Stores can have multiple types, and are fieldable. Does your store exist in the analog world and needs to show the opening hours on the site? No problem, just add a new field.

Products can belong to one or multiple stores. An order always belongs to a single store. Carts are still orders, but there can now be multiple active carts, one for each order type and store. If a customer adds products from two stores to his cart, they will get two carts, two checkouts. This is the same UX as implemented on Etsy. Other Commerce entities will also be store aware. For example, it will be possible to limit a discount to one or multiple stores.

To improve the UX of store selection, we've created a special form element (and matching field widget) called entity_select. If the element is required and there's only one available entity, it outputs a hidden field. This means that people that use Commerce with only 1 store won't ever see the store selector. For up to 7 available entities (configurable) a set of checkboxes/radio buttons is shown, and for more than that, an autocomplete field is shown instead.

Getting started

So, how do you start selling with Commerce 2.x? The flow is:

  1. Import a currency.
  2. Create a store.
  3. Create products.
  4. Find customers!

To make steps #1 and #2 quicker (and less clicky) we provide our first of many Drupal Console commands:

It asks for the store name, email, and country. It then finds the default currency for that country, and offers a chance to confirm or override it. Finally, it imports the currency and creates the store.

Conclusion

It's much easier to design Commerce for multiple stores but allow people to use it with only one, than to do it the other way around. The Etsy use case still won't be complete without a contrib module, but Commerce itself is now doing the heavy lifting, thanks to the store entity and multiple carts. And of course, for those sites that only bill from one location, the UX remains unchanged from Commerce 1.x.

Bojan Zivanovic
Posted: Nov 10, 2015

Comments

WeBla cedric_a on November 10, 2015

Amazing work! I can see some good ideas already well implemented in the Maciej Zgadzaj's Marketplace module. Great to see that it will come in DC 2.
About the Etsy use case, what part need a contrib module ?

bojanz Bojan Zivanovic on November 10, 2015

The main question with marketplaces is payments. You have several models for that:
1) Each merchant inputs own paypal account
2) Site gets money, distributes to merchants (can be tough tax wise)
3) A special gateway (paypal adaptive payments?) that takes money, distributes to site & merchant.

#1 and #2 are doable with Commerce out of the box. #3 will require a custom payment module.

The rest is mostly about UI customizations. You want a nice UI where the user can register, create a store, create discounts, view repots etc. You also want to lock&hide the store selector on the product add/edit form. We are still working on UIs and permissions on our side, so I don't know how many tweaks the module would need to provide, hopefully not many. Ideally someone would start work on that, and submit patches to Commerce where relevant.

WeBla cedric_a on November 10, 2015

Thank you for this quick reply.
And last question, what about shipping services/costs : is it possible to specify different shipping services for each store ?

sushichris sushichris on November 10, 2015

I have never used this type of currency and it seems to be gaining in popularity, will this "currency type" be importable as well? I haven't used Bitcoin but this could be an alluring feature for customers.

tim@ellemeet.net tim on December 7, 2015

Amazing work (commerce) guys,

Would this new store model also improve the following use case:

You have dropshipping agreements with say three stores A,B and C. However a customer doesnt have to bothered with that. So I would like him to see all to products without any differentiaton in product or cart display and payment. So for UX it doesnt matter if you buy 4 product from A or 2 from A, and 1 from B and C. But offcourse the site should notify each specific store about the relevant part of the order.

Is this something that will be improved by this model or will this be a custom job again?

Keep up the good work,

Regards
Tim

bojanz Bojan Zivanovic on December 10, 2015

Products are grouped in orders by store (unless the logic is swapped/altered), so it sounds like a custom job, at least partially.

You can show products shared between stores, but the customer would still get multiple carts.

Didi on December 9, 2015

This is an awesome addition. As someone who is interested in a marketplace setup, this is a very good news. I hope the adaptive payments functionality will be added soon.

Manish on December 30, 2015

"One business with multiple billing locations" - The product catalog will be the same for all stores. In this scenario is it possible to have different prices for different stores? Also, if the product gets out of stock in one store, we should be able to set it as out of stock only for that store.