The Resource Picker API provides a search-based interface to help users find and select one or more products, collections, or product variants, and then returns the selected resources to your app. Both the app and the user must have the necessary permissions to access the resources selected. > Tip: > If you are picking app resources such as product reviews, email templates, or subscription options, you should use the [Picker](picker) API instead.
const selected = await shopify.resourcePicker({type: 'product'});
The `Resource Picker` accepts a variety of options to customize the picker's behavior.
The action verb appears in the title and as the primary action of the Resource Picker.
Filters for what resource to show.
Whether to allow selecting multiple items of a specific type or not. If a number is provided, then limit the selections to a maximum of that number of items. When type is Product, the user may still select multiple variants of a single product, even if multiple is false.
GraphQL initial search query for filtering resources available in the picker. See [search syntax](https://shopify.dev/docs/api/usage/search-syntax) for more information. This is displayed in the search bar when the picker is opened and can be edited by users. For most use cases, you should use the `filter.query` option instead which doesn't show the query in the UI.
Resources that should be preselected when the picker is opened.
The type of resource you want to pick.
Whether to show [archived products](https://help.shopify.com/en/manual/products/details?shpxid=70af7d87-E0F2-4973-8B09-B972AAF0ADFD#product-availability). Only applies to the Product resource type picker. Setting this to undefined will show a badge on draft products.
Whether to show [draft products](https://help.shopify.com/en/manual/products/details?shpxid=70af7d87-E0F2-4973-8B09-B972AAF0ADFD#product-availability). Only applies to the Product resource type picker. Setting this to undefined will show a badge on draft products.
Whether to show hidden resources, referring to products that are not published on any sales channels.
GraphQL initial search query for filtering resources available in the picker. See [search syntax](https://shopify.dev/docs/api/usage/search-syntax) for more information. This is not displayed in the search bar when the picker is opened.
Whether to show product variants. Only applies to the Product resource type picker.
in GraphQL id format, ie 'gid://shopify/Product/1'
in GraphQL id format, ie 'gid://shopify/Product/1'
The `Resource Picker` returns a Promise with an array of the selected resources. The object type in the array varies based on the provided `type` option. If the picker is cancelled, the Promise resolves to `undefined`
in GraphQL id format, ie 'gid://shopify/Product/1'
in GraphQL id format, ie 'gid://shopify/Product/1'
in GraphQL id format, ie 'gid://shopify/Product/1'
string
The Resource Picker API provides a search-based interface to help users find and select one or more products, collections, or product variants, and then returns the selected resources to your app. Both the app and the user must have the necessary permissions to access the resources selected. > Tip: > If you are picking app resources such as product reviews, email templates, or subscription options, you should use the [Picker](picker) API instead.
Alternate resources
const selected = await shopify.resourcePicker({type: 'collection'});
const selected = await shopify.resourcePicker({type: 'variant'});
const selected = await shopify.resourcePicker({type: 'collection'});
const selected = await shopify.resourcePicker({type: 'variant'});
Preselected resources
const selected = await shopify.resourcePicker({
type: 'product',
selectionIds: [
{
id: 'gid://shopify/Product/12345',
variants: [
{
id: 'gid://shopify/ProductVariant/1',
},
],
},
{
id: 'gid://shopify/Product/67890',
},
],
});
const selected = await shopify.resourcePicker({
type: 'product',
selectionIds: [
{
id: 'gid://shopify/Product/12345',
variants: [
{
id: 'gid://shopify/ProductVariant/1',
},
],
},
{
id: 'gid://shopify/Product/67890',
},
],
});
Action verb
const selected = await shopify.resourcePicker({
type: 'product',
action: 'select',
});
const selected = await shopify.resourcePicker({
type: 'product',
action: 'select',
});
Multiple selection
const selected = await shopify.resourcePicker({
type: 'product',
multiple: true,
});
const selected = await shopify.resourcePicker({
type: 'product',
multiple: 5,
});
const selected = await shopify.resourcePicker({
type: 'product',
multiple: true,
});
const selected = await shopify.resourcePicker({
type: 'product',
multiple: 5,
});
Filters
const selected = await shopify.resourcePicker({
type: 'product',
filter: {
hidden: true,
variants: false,
draft: false,
archived: false,
},
});
const selected = await shopify.resourcePicker({
type: 'product',
filter: {
hidden: true,
variants: false,
draft: false,
archived: false,
},
});
Filter query
const selected = await shopify.resourcePicker({
type: 'product',
filter: {
query: 'Sweater',
},
});
const selected = await shopify.resourcePicker({
type: 'product',
filter: {
query: 'Sweater',
},
});
Selection
const selected = await shopify.resourcePicker({type: 'product'});
if (selected) {
console.log(selected);
} else {
console.log('Picker was cancelled by the user');
}
const selected = await shopify.resourcePicker({type: 'product'});
if (selected) {
console.log(selected);
} else {
console.log('Picker was cancelled by the user');
}
Initial query
const selected = await shopify.resourcePicker({
type: 'product',
query: 'Sweater',
});
const selected = await shopify.resourcePicker({
type: 'product',
query: 'Sweater',
});