Product targeting

Pro

Choose which products, variants, or collections a promotion or pickup rule applies to.

Install
Example

Installation

Install command

Writes app/components/product-targeting.tsx and adds @shopify/polaris-types@2.0.0 once authenticated.

API reference

valueRequired
ProductTargetingValueUse scope all, products with productIds and variantIds, or collections with collectionIds. Persist the scope and Shopify global IDs on your rule.
Required
recordsRequired
ProductTargetingRecordsDisplay records keyed by Shopify global ID with status available, unavailable, or unverified and optional title, imageUrl, detail, and meta. Omitted records are unverified.
Required
onChangeRequired
(value: ProductTargetingValue, picked: readonly TargetRecord[]) => voidUpdate the controlled value and merge any newly selected display records. Save the value with the rest of the host form.
Required
picker
TargetPickerOverride selection with a function that receives the resource kind and current IDs. Resolve to display records on confirmation or undefined on cancellation.
Shopify Resource Picker
scopes
readonly ProductTargetingValue["scope"][]Restrict which targeting scope radio choices are presented to merchants.
["all", "products", "collections"]
maxSelections
numberDisplay a selection count cap badge and warn merchants when selected targets exceed the limit.
Optional
filterThreshold
numberMinimum selected item count before rendering the inline selected-items filter search field.
4
checking
booleanShow progress while the host verifies its saved selections.
false
onRecheck
() => voidResolve the current IDs again. Update the display records when the request completes.
Optional
heading
stringName the targeting section.
Product targeting
disabled
booleanDisable targeting edits while the host is saving or reopening the rule.
false

Run under Shopify App Home AppProvider. Point polarisUrl to the Polaris 2.0 runtime.

The default picker opens the Shopify Resource Picker through App Bridge. Whole products include all their variants. Choose exact variants separately.

Changing scope starts a new selection. Confirming a picker updates its resource kind and preserves omitted unavailable or unverified IDs. Remove those IDs from the form.

The usage example connects a promotion or pickup editor to an authenticated resource route. useTargetingRoute connects reopening, saving, and rechecking to your app’s rule store and Shopify Admin API.