Raw
1 ---
2 products:
3 - product
4 - customer
5 - sales channel
6 - pricing
7 ---
8
9 import { AcademicCapSolid, UsersSolid } from "@medusajs/icons"
10
11 export const metadata = {
12 title: `B2B Recipe`,
13 }
14
15 # {metadata.title}
16
17 This recipe provides the general steps to implement a B2B store with Medusa.
18
19 <Note title="Tip">
20
21 Medusa has a ready-to-use B2B starter that you can install and use. Refer to the [B2B Starter GitHub repository](https://github.com/medusajs/b2b-starter) for more details.
22
23 </Note>
24
25 ## Overview
26
27 In a B2B store, you provide different types of customers with relevant pricing, products, shopping experience, and more.
28
29 Medusa’s Commerce Modules, including [Sales Channel](../../commerce-modules/sales-channel/page.mdx), [Customer](../../commerce-modules/), and [Pricing](../../commerce-modules/pricing/page.mdx) modules enable this setup out-of-the-box:
30
31 - **Sales Channel**: Use sales channels to set product availability per channel. In this case, create a B2B sales channel that includes only B2B products.
32 - **Customer**: Use customer groups to organize your customers into different groups. Then, you can apply different prices for each group.
33 - **Pricing**: Use price lists to set different prices for each B2B customer group, among other conditions.
34
35 In addition, Medusa’s extensible architecture and Framework for customization allow you to scope existing and custom features to specific customer groups or sales channels.
36
37 <Note title="Related use-case">
38
39 [Visionary: Frictionless B2B ecommerce with Medusa](https://medusajs.com/blog/visionary/)
40
41 </Note>
42
43 ---
44
45 ## Create B2B Sales Channel
46
47 Sales channels allow you to set product availability per channel. For B2B use cases, you can create a B2B sales channel that includes only B2B products.
48
49 Then, on the storefront, you retrieve only the B2B products for B2B customers, which is explained more in the next section.
50
51 You can create a sales channel through the Medusa Admin or Admin REST APIs.
52
53 <CardList items={[
54 {
55 href: "!user-guide!/settings/sales-channels",
56 title: "Using Medusa Admin",
57 text: "Create the sales channel using the Medusa Admin.",
58 icon: UsersSolid,
59 },
60 {
61 href: "!api!/admin/sales-channels/create-sales-channel",
62 title: "Using Admin API",
63 text: "Create the sales channel using the REST APIs.",
64 icon: AcademicCapSolid,
65 },
66 ]} />
67
68 ---
69
70 ## Create a Publishable API Key
71
72 A publishable API key allows you to specify the context of client requests:
73
74 - You associate the publishable API key with one or more sales channels, such as the B2B sales channel.
75 - In a client such as a storefront, you pass the publishable API key in the header of your requests.
76
77 So, if you use the publishable API key associated with the B2B sales channel in your storefront, the Medusa server will only return products that are available in the B2B sales channel.
78
79 You can create a publishable API key through the Medusa Admin or the Admin REST APIs, then associate it with the B2B sales channel. Then, you can use this key when developing your B2B storefront.
80
81 ### Create Publishable API Key
82
83 <CardList items={[
84 {
85 href: "!user-guide!/settings/developer/publishable-api-keys",
86 title: "Using Medusa Admin",
87 text: "Create the API key using the Medusa Admin.",
88 icon: UsersSolid,
89 },
90 {
91 href: "!api!/admin/api-keys/create-api-key",
92 title: "Using Admin API",
93 text: "Create the API key using the REST APIs.",
94 icon: AcademicCapSolid,
95 },
96 ]} />
97
98 ### Associate Key with Sales Channel
99
100 <CardList items={[
101 {
102 href: "!user-guide!/settings/developer/publishable-api-keys#manage-publishable-api-keys-sales-channels",
103 title: "Using Medusa Admin",
104 text: "Associate the key with the sales channel using the Medusa Admin.",
105 icon: UsersSolid,
106 },
107 {
108 href: "!api!/admin/api-keys/manage-sales-channels",
109 title: "Using Admin API",
110 text: "Associate the key with the sales channel using the REST APIs.",
111 icon: AcademicCapSolid,
112 },
113 ]} />
114
115 ---
116
117 ## Add Products to B2B Sales Channel
118
119 You can manage products to be available in specific sales channels. For B2B, this allows you to add products that are only available to B2B customers.
120
121 You can create new products or add existing ones to the B2B sales channel using the Medusa Admin or Admin REST APIs.
122
123 ### Create Products
124
125 <CardList items={[
126 {
127 href: "!user-guide!/products/create",
128 title: "Using Medusa Admin",
129 text: "Create the products using the Medusa Admin.",
130 icon: UsersSolid,
131 },
132 {
133 href: "!api!/admin/products/create-product",
134 title: "Using Admin API",
135 text: "Create the products using the REST APIs.",
136 icon: AcademicCapSolid,
137 },
138 ]} />
139
140 ### Add Products to Sales Channel
141
142 <CardList items={[
143 {
144 href: "!user-guide!/settings/sales-channels#manage-products-in-sales-channel",
145 title: "Using Medusa Admin",
146 text: "Create the products using the Medusa Admin.",
147 icon: UsersSolid,
148 },
149 {
150 href: "!api!/admin/sales-channels/manage-products",
151 title: "Using Admin API",
152 text: "Add the products to the sales channel using the REST APIs.",
153 icon: AcademicCapSolid,
154 },
155 ]} />
156
157 ---
158
159 ## Add B2B Customers and Groups
160
161 Customer groups allow you to organize your customers into different groups. Then, you can apply different prices for each group.
162
163 This is useful for B2B sales, as you often negotiate special prices with each customer or company.
164
165 You can create a customer group for each B2B company, then add customers of that company to the group.
166
167 ### Create Customers
168
169 <CardList items={[
170 {
171 href: "!user-guide!/customers/manage",
172 title: "Using Medusa Admin",
173 text: "Create customers using the Medusa Admin.",
174 icon: UsersSolid,
175 },
176 {
177 href: "!api!/admin/customers/create-customer",
178 title: "Using Admin API",
179 text: "Create customers using the REST APIs.",
180 icon: AcademicCapSolid,
181 },
182 ]} />
183
184 ### Assign Customers to Groups
185
186 <CardList items={[
187 {
188 href: "!user-guide!/customers/manage#manage-customers-groups",
189 title: "Using Medusa Admin",
190 text: "Assign customer to groups using the Medusa Admin.",
191 icon: UsersSolid,
192 },
193 {
194 href: "!api!/admin/customer-groups/manage-customers",
195 title: "Using Admin API",
196 text: "Assign customer to groups using the REST APIs.",
197 icon: AcademicCapSolid,
198 },
199 ]} />
200
201 ### Flexible Customizations: Create Custom Module
202
203 B2B use cases often require more complex customer management, such as managing roles in a company with employees having different privileges.
204
205 For more complex use cases, you can create a custom module that introduces data models like `Company`, `Employee`, and other relevant models.
206
207 Then, you can link those companies to existing customers and groups, allowing you to benefit from existing features like price lists for specific customer groups.
208
209 <CardList items={[
210 {
211 href: "!docs!/learn/fundamentals/modules",
212 title: "Create Module",
213 text: "Learn how to create a module.",
214 icon: AcademicCapSolid,
215 },
216 {
217 href: "!docs!/learn/fundamentals/module-links",
218 title: "Define Module Links",
219 text: "Define links between data models.",
220 icon: AcademicCapSolid,
221 },
222 ]} />
223
224 ---
225
226 ## Create B2B Price List
227
228 Price lists allow you to set different prices for each customer group, among other conditions. They're useful to override prices for custom use cases.
229
230 For B2B use cases, you can use price lists to set different prices for each B2B customer group. Then, B2B customers can see different prices on the storefront based on their group.
231
232 You can create a price list using the Medusa Admin or the Admin REST APIs. Make sure to set the B2B customer group(s) as a condition.
233
234 <CardList items={[
235 {
236 href: "!user-guide!/price-lists/create",
237 title: "Using Medusa Admin",
238 text: "Create price list using the Medusa Admin.",
239 icon: UsersSolid,
240 },
241 {
242 href: "!api!/admin/price-lists/create-price-list",
243 title: "Using Admin API",
244 text: "Create price list using the REST APIs.",
245 icon: AcademicCapSolid,
246 },
247 ]} />
248
249 ---
250
251 ## Customize Medusa Admin
252
253 Based on your use case, you may need to customize the Medusa Admin to add new widgets or pages.
254
255 For example, you may want to add a page to manage companies and their employees, or you may want to add a widget to show the company associated with a customer group.
256
257 The Medusa Admin is an extensible application within your Medusa application. You can customize it by:
258
259 - **Widgets**: Adding widgets to existing pages, such as the customer group page.
260 - **UI Routes**: Adding new pages to the Medusa Admin, such as a page to manage companies and employees.
261 - **Settings Pages**: Adding new pages to the Medusa Admin settings, such as a page to manage company settings.
262
263 <CardList items={[
264 {
265 href: "!docs!/learn/fundamentals/admin/widgets",
266 title: "Create Admin Widget",
267 text: "Add widgets into existing admin pages.",
268 icon: AcademicCapSolid,
269 },
270 {
271 href: "!docs!/learn/fundamentals/admin/ui-routes",
272 title: "Create Admin UI Routes",
273 text: "Add new pages to your Medusa Admin.",
274 icon: AcademicCapSolid,
275 },
276 ]} />
277
278 <Card
279 href="!docs!/learn/fundamentals/admin/ui-routes#create-settings-page"
280 title="Create Admin Setting Page"
281 text="Add new page to the Medusa Admin settings."
282 icon={AcademicCapSolid}
283 className="mt-1"
284 />
285
286 ---
287
288 ## Customize or Build Storefront
289
290 Medusa provides a Next.js Starter Storefront to use with your application. You can customize it for your B2B use case, such as adding a login page for B2B customers or expanding the profile page to show the company associated with the customer.
291
292 Alternatively, you can build your own storefront using the Medusa APIs. This headless approach gives you the flexibility to build a custom storefront without limitations on which tech stack you use, or the design of the storefront.
293
294 In your storefront, you can use the publishable API key you associated with your B2B sales channel to ensure only B2B products are retrieved.
295
296 <CardList items={[
297 {
298 href: "/nextjs-starter",
299 title: "Next.js Starter Storefront",
300 text: "Learn how to install and customize the Next.js Starter Storefront.",
301 icon: AcademicCapSolid,
302 },
303 {
304 href: "/storefront-development",
305 title: "Storefront Development",
306 text: "Find guides to build your own storefront.",
307 icon: AcademicCapSolid,
308 },
309 ]} />
310
311 <Card
312 href="!api!/store/publishable-api-key"
313 title="Use Publishable API Keys"
314 text="Learn how to use the publishable API key in client requests."
315 icon={AcademicCapSolid}
316 className="mt-1"
317 />