Sales Channels
Queries and Mutations listed here are used to send requests to the Admin Sales Channel API Routes.
All hooks listed require user authentication.
A sales channel indicates a channel where products can be sold in. For example, a webshop or a mobile app. Admins can manage sales channels and the products available in them.
Related Guide: How to manage sales channels.
Mutations
useAdminCreateSalesChannel
This hook creates a sales channel.
Example
import React from "react"
import { useAdminCreateSalesChannel } from "medusa-react"
const CreateSalesChannel = () => {
const createSalesChannel = useAdminCreateSalesChannel()
// ...
const handleCreate = (name: string, description: string) => {
createSalesChannel.mutate({
name,
description,
}, {
onSuccess: ({ sales_channel }) => {
console.log(sales_channel.id)
}
})
}
// ...
}
export default CreateSalesChannel
Mutation Function Parameters
The details of the sales channel to create.
Mutation Function Returned Data
The sales channel's details.
useAdminUpdateSalesChannel
This hook updates a sales channel's details.
Example
import React from "react"
import { useAdminUpdateSalesChannel } from "medusa-react"
type Props = {
salesChannelId: string
}
const SalesChannel = ({ salesChannelId }: Props) => {
const updateSalesChannel = useAdminUpdateSalesChannel(
salesChannelId
)
// ...
const handleUpdate = (
is_disabled: boolean
) => {
updateSalesChannel.mutate({
is_disabled,
}, {
onSuccess: ({ sales_channel }) => {
console.log(sales_channel.is_disabled)
}
})
}
// ...
}
export default SalesChannel
Hook Parameters
id
stringRequiredThe sales channel's ID.
Mutation Function Parameters
The details to update of the sales channel.
Mutation Function Returned Data
The sales channel's details.
useAdminDeleteSalesChannel
This hook deletes a sales channel. Associated products, stock locations, and other resources are not deleted.
Example
import React from "react"
import { useAdminDeleteSalesChannel } from "medusa-react"
type Props = {
salesChannelId: string
}
const SalesChannel = ({ salesChannelId }: Props) => {
const deleteSalesChannel = useAdminDeleteSalesChannel(
salesChannelId
)
// ...
const handleDelete = () => {
deleteSalesChannel.mutate(void 0, {
onSuccess: ({ id, object, deleted }) => {
console.log(id)
}
})
}
// ...
}
export default SalesChannel