Price Preference Hooks - Admin Components

Note: These hooks are available since Medusa v2.21.0.

The price preference hooks retrieve price preferences from the Medusa backend. A price preference controls how prices are displayed and entered for a region or a currency, such as whether prices are tax inclusive.

Code
1import {2  pricePreferencesQueryKeys,3  usePricePreferences,4} from "@medusajs/dashboard/hooks"

These hooks are built on TanStack Query. Use them in your widgets and UI routes.


usePricePreferences#

Retrieve a paginated list of price preferences. Pass query parameters to filter the price preferences, for example by attribute or value.

Code
1const { price_preferences, count } = usePricePreferences({2  limit: 20,3})

Parameters#

Loading...

Returns#

Along with the following, the hook returns the rest of TanStack Query's useQuery result.

Loading...

pricePreferencesQueryKeys#

pricePreferencesQueryKeys is the query key factory for price preference queries. Use all, lists(), list(query), details(), and detail(id) to build the keys that the hook above registers.

Use it to invalidate cached price preference data after a custom mutation:

Code
1import { useQueryClient } from "@tanstack/react-query"2import {3  pricePreferencesQueryKeys,4} from "@medusajs/dashboard/hooks"5
6const queryClient = useQueryClient()7
8queryClient.invalidateQueries({9  queryKey: pricePreferencesQueryKeys.lists(),10})
Was this page helpful?
Ask Bloom
For assistance in your development, use Claude Code Plugins or Docs MCP server in Cursor, VSCode, etc...FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break
⇧↵