- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
B2B Recipe Soon
This recipe provides the general steps to implement a B2B store with Medusa.
Overview#
In a B2B store, you provide different types of customers with relevant pricing, products, shopping experience, and more.
Medusa’s commerce modules, including Sales Channel, Customer, and Pricing modules facilitate implementing this setup. Medusa’s architecture and extendible nature allow you to customize your store based on your use case.
Create B2B Sales Channel#
Use sales channels to set product availability per channel. In this case, create a B2B sales channel that includes only B2B products.
You can create a sales channel through the Medusa Admin or Admin REST APIs.
Create a Publishable API Key#
Use publishable API keys to specify the context of client requests:
- You associate the publishable API key with one or more sales channels.
- In a client such as a storefront, you pass the publishable API key in the header of your requests.
Then, all products retrieved belong to the associated sales channel(s).
You can create a publishable API key through the Medusa Admin or the Admin REST APIs, then associate it with the B2B sales channel. Later, you'll use this key when developing your B2B storefront.
Create Key#
Associate Key with Sales Channel#
Add Products to B2B Sales Channel#
You can create new products or add existing ones to the B2B sales channel using the Medusa Admin or Admin REST APIs.
Create Products#
Add Products to Sales Channel#
Create B2B Module with Relationship to Customer Groups#
Use customer groups to organize your customers into different groups. Then, you can apply different prices for each group.
This is useful in B2B sales, as you often negotiate special prices with each customer or company.
You can create a B2B module that adds necessary data models to represent a B2B company. Then, you link that company to a customer group. Any customer belonging to that group also belongs to the company, meaning they're a B2B customer.
Add B2B Customers#
After adding your B2B customer group, add B2B customers and assign them to the B2B customer group.
You can do that through the Medusa Admin or Admin REST APIs.
Create Customers#
Assign Customers to Groups#
Create B2B Price List#
Use price lists to set different prices for each B2B customer group, among other conditions.
You can create a price list using the Medusa Admin or the Admin REST APIs. Make sure to set the B2B customer group as a condition.
Create Custom Data Model#
To implement a more advanced B2B sales flow, add custom data models such as Company
, Employee
, Admin
, and Buyer
to your B2B module.
This provides more granular control of your B2B sales and allows you to build features like privileges, limits, and more.
Create an API Route to Check Customers#
On the frontend clients communicating with your store, such as the storefront, you need to check whether the currently logged-in customer is a B2B customer.
The API route can check if the customer has any group with an associated company.
Customize Admin#
Based on your use case, you may need to customize the Medusa Admin to add new widgets or pages.
The Medusa Admin plugin can be extended to add widgets, new pages, and setting pages.
Customize Storefront#
Medusa provides a Next.js storefront to use with your application. You can either customize it or build your own to represent your B2B features.
Use the publishable API key you associated with your B2B sales channel in the storefront to ensure only B2B products are retrieved.