Price Lists
Queries and Mutations listed here are used to send requests to the Admin Price List API Routes.
All hooks listed require user authentication.
A price list are special prices applied to products based on a set of conditions, such as customer group.
Related Guide: How to manage price lists.
Mutations
useAdminCreatePriceList
This hook creates a price list.
Example
import React from "react"
import {
PriceListStatus,
PriceListType,
} from "@medusajs/medusa"
import { useAdminCreatePriceList } from "medusa-react"
type CreateData = {
name: string
description: string
type: PriceListType
status: PriceListStatus
prices: {
amount: number
variant_id: string
currency_code: string
max_quantity: number
}[]
}
const CreatePriceList = () => {
const createPriceList = useAdminCreatePriceList()
// ...
const handleCreate = (
data: CreateData
) => {
createPriceList.mutate(data, {
onSuccess: ({ price_list }) => {
console.log(price_list.id)
}
})
}
// ...
}
export default CreatePriceList
Mutation Function Parameters
The details of the price list to create.
Mutation Function Returned Data
The price list's details.
useAdminUpdatePriceList
This hook updates a price list's details.
Example
import React from "react"
import { useAdminUpdatePriceList } from "medusa-react"
type Props = {
priceListId: string
}
const PriceList = ({
priceListId
}: Props) => {
const updatePriceList = useAdminUpdatePriceList(priceListId)
// ...
const handleUpdate = (
endsAt: Date
) => {
updatePriceList.mutate({
ends_at: endsAt,
}, {
onSuccess: ({ price_list }) => {
console.log(price_list.ends_at)
}
})
}
// ...
}
export default PriceList