Skip to main content
Skip to main content

Sales Channel Module

The Sales Channel Module is the @medusajs/sales-channel NPM package that provides sales-channel-related features in your Medusa and Node.js applications.

What's a Sales Channel?

A sales channel indicates an online or offline platform that you sell products on.

Some use case examples for using a sales channel:

  • Implement a B2B Ecommerce Store.
  • Specify different products for each channel you sell in.
  • Support Omnichannel in your ecommerce store.

Features

Sales Channel Management

Store and manage sales channels in your store.

Each sales channel has different meta information such as name or description, allowing you to easily differentiate between sales channels.

const salesChannels = await salesChannelModuleService.create([
{
name: "B2B",
},
{
name: "Mobile App",
},
])

Product Availability

By combining the Product and Sales Channel modules, you can specify a product's availability per sales channel.

For example, B2B customers viewing products only see products in the B2B sales channel.

Cart and Order Scoping

Carts, available through the Cart Module, are scoped to a sales channel. Paired with the product availability feature, you benefit from more features like allowing only products available in sales channel in a cart.

Orders are also scoped to a sales channel due to the relation between the Sales Channel and Order modules.


Configure Sales Channel Module

After installing the @medusajs/sales-channel package in your Medusa application, add it to the modules object in medusa-config.js:

medusa-config.js
const modules = {
// ...
salesChannel: {
resolve: "@medusajs/sales-channel",
},
}

How to Use Sales Channel Module's Service

You can use the Sales Channel Module's main service by resolving from the dependency container the resource ModuleRegistrationName.SALES_CHANNEL imported from @medusajs/modules-sdk.

For example:

import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ISalesChannelModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"

export async function GET(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const salesChannelModuleService: ISalesChannelModuleService =
request.scope.resolve(ModuleRegistrationName.SALES_CHANNEL)

res.json({
sales_channels: await salesChannelModuleService.list(),
})
}
Was this section helpful?