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.

Option 1: Use Medusa Admin
Create the sales channel using the Medusa Admin.
Guide Soon
Option 2: Using the REST APIs
Create the sales channel using the 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#

Option 1: Use Medusa Admin
Create the publishable API key using the Medusa Admin.
Guide Soon
Option 2: Using the REST APIs
Create the publishable API key using the REST APIs.

Associate Key with Sales Channel#

Option 1: Use Medusa Admin
Associate the publishable API key with the B2B sales channel using the Medusa Admin.
Guide Soon
Option 2: Using the REST APIs
Associate the publishable API key with the B2B sales channel using the REST APIs.

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#

Using Medusa Admin
Create products using the Medusa Admin.
Guide Soon
Using REST APIs
Create products using the REST APIs.

Add Products to Sales Channel#

Using Medusa Admin
Add the products to the B2B sales channel using the Medusa Admin.
Guide Soon
Using REST APIs
Add the products to the B2B sales channel using the REST APIs.

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.

Create Module
Learn how to create a module in Medusa.
Create Data Models
Learn how to create data models.

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#

Option 1: Use Medusa Admin
Create the customers using the Medusa Admin.
Guide Soon
Option 2: Using the REST APIs
Create the customers using the REST APIs.

Assign Customers to Groups#

Option 1: Use Medusa Admin
Assign the customers to the B2B customer group using the Medusa Admin.
Guide Soon
Option 2: Using the REST APIs
Assign the customers to the B2B customer group using the REST APIs.

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.

Using Medusa Admin
Create the price list using the Medusa Admin.
Guide Soon
Using REST APIs
Create the price list using the REST APIs.

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 a Data Model
Learn how to create a custom data model in a module.

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.

Create an API Route
Learn how to create an API Route in Medusa.

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.

Create Admin Widget
Learn how to add widgets into existing admin pages.
Create Admin UI Routes
Learn how to add new pages to your Medusa Admin.
Create Admin Setting Page
Learn how to add new page to the Medusa Admin settings.

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.

Next.js Storefront
Learn how to install and customize the Next.js storefront.
Storefront Development
Find guides for your storefront development.
Use Publishable API Keys
Learn how to use the publishable API key in client requests.
Was this page helpful?
Edit this page