Search & Discover Configuration

Configuration

Pass an options object to $.fn.preferabliSearchDiscover. integration_id is required. Every other option has a default.

$('#sd-search').preferabliSearchDiscover({
  integration_id: '11610',
  type: 'search',
});

Brand colors and pane layout are CSS variables, not plugin options. See Styling.

Quick reference

OptionTypeDefaultUsed for
integration_idString / Number—Required. API client identity
typeString'search'First view when the button opens
foodpairing_targetString'product'Product vs recipe when type is foodpairing
collection_idString / NumbernoneSearch, pairings, and similar-product requests
channel_idString / NumbernoneStock / availability (wheretobuy)
langString'en'API language + UI locale
placementString'right'Pane side: 'right' or 'left'
lokalise_textObject{}Override Lokalise copy by slug ('page.search.title': 'Find a wine')
showPriceBooleantruePrice on product heroes and cards
showBinBooleanfalseAisle / bin on the product hero
showRecipeDescriptionBooleanfalseRecipe description under the title
showDetailKeyBooleantrueLabels on Taste Facts rows
numberPriceDecimalsNumber0Price fraction digits
searchObjectsee belowSearch tabs and category filters
cta_buttonBoolean / ObjectfalseInject Preferabli CTA (false = use your own button). Object may set label (HTML ok), className, position, anchor
opt_out_trackingBooleanfalseMixpanel opt-out (true = do not track)
onShow / onHideFunctionnonePane open / close callbacks

Product and recipe buttons identify the item with a single merchant id: merchant_variant_id or merchant_recipe_id.

Which options each type needs

typeOpensRequired id
searchSearchnone (collection_id recommended)
productProduct panemerchant_variant_id
recipeRecipe panemerchant_recipe_id
foodpairing + foodpairing_target: 'product'Product on Food Pairings tabmerchant_variant_id
foodpairing + foodpairing_target: 'recipe'Recipe panemerchant_recipe_id

integration_id

Type: Number
Required

Preferabli client identity. Provided by Preferabli.

$('#sd-search').preferabliSearchDiscover({
  integration_id: 11610,
});

collection_id

Type: String or Number
Default: none
Provided by Preferabli.

channel_id

Type: String or Number
Default: none
Provided by Preferabli.

type

Type: String
Default: 'search'

Chooses the first view when the launcher button opens the pane.

ValueBehavior
searchOpens search. No product or recipe id required.
$('#sd-food').preferabliSearchDiscover({
  integration_id: '11610',
  type: 'search',
});

lang

Type: String
Default: 'en'

Supported languages

LanguageCode
Englishen
English (Canada)en_CA
English (United Kingdom)en_GB
Spanishes
Spanish (Guatemala)es_GT
Frenchfr
French (Canada)fr_CA
Germande
Italianit
Koreanko
Portuguesept
Portuguese (Brazil)pt_BR
Portuguese (Portugal)pt_PT
Vietnamesevi
Chinese (Simplified)zh_CN

Hyphenated codes such as es-GT and zh-CN resolve to es_GT and zh_CN. Unknown codes fall back to the primary language when available (for example fr-FR → fr), otherwise en.

Use changeLanguage to update every button and reload Lokalise.

$('#sd-search').preferabliSearchDiscover({
  integration_id: '11610',
  lang: 'es',
});

placement

Type: String
Default: 'right'

ValuePane opens from
rightRight
leftLeft

lokalise_text

Type: Object
Default: {}

Override any UI string by Lokalise slug. Keys are slugs; values are the copy to show. Host overrides win over remote and bundled catalogs.

$('#sd-search').preferabliSearchDiscover({
  integration_id: '11610',
  type: 'search',
  lokalise_text: {
    'page.search.title': 'Find a wine',
    'page.search.inputplaceholder': 'Search wines',
  },
});

Common slugs: page.search.title (default English: Search & Discover), page.search.inputplaceholder, product.pane.tab.food_pairings, product.gotoproduct. See the bundled files under src/locale/ for the full list.

showPrice

Type: Boolean
Default: true

When true, shows price on the product hero and on product cards in search / pairings / similar results (when the API returns a price).

showBin

Type: Boolean
Default: false

When true, shows aisle or bin from the product lookup on the product hero, if that value is present.

showDetailKey

Type: Boolean
Default: true

On the Taste Facts tab:

ValueDisplay
trueLabel + value (for example Type / Red)
falseValue only

numberPriceDecimals

Type: Number
Default: 0

Fraction digits when formatting a shown price (0 → $89, 2 → $89.00).


search

Type: Object
Default:

search: {
  allowed_search: ['tags', 'products', 'recipes'],
  allowed_products: [],
  collection_ids: [],
}

Only applies when the user is on the search view.

PropertyTypeDefaultDescription
allowed_searchString[]['tags', 'products', 'recipes']Which result tabs can appear
allowed_productsString[][]Sent as product_categories when non-empty
collection_idsArray[]Reserved for a multi-collection search list. When empty, the request uses top-level collection_id

allowed_search values

ValueTab label (English)
tagsAvailable Products
productsOther Products
recipesFood Pairings

Empty tabs are hidden automatically when a search returns no rows for that type.

$('#sd-search').preferabliSearchDiscover({
  integration_id: '11610',
  collection_id: '794101',
  type: 'search',
  search: {
    allowed_search: ['tags', 'recipes'],
    allowed_products: ['wine'],
  },
});

cta_button

Type: Boolean or Object
Default: false

Controls whether the plugin injects a Preferabli CTA button (class sdjs__launcher). Default is off — use your own button and call show / hide.

ValueBehavior
falseNo injected CTA (default). Open the pane from your UI with show
trueInject a CTA with the default label for type, pinned bottom-right on the window
{ label, className, position, anchor }Inject a CTA; omitted position / anchor use the defaults below
{ label, render: false }Same as false — no injected CTA
PropertyTypeDefaultDescription
labelString (text or HTML)from typeButton contents. HTML is allowed (icons, <span>, etc.)
classNameString / String[]noneExtra classes on .sdjs__launcher. Aliases: class, classes
positionString / false'bottom-right''bottom-left', 'bottom-right', 'center-left', or 'center-right'. Use false or 'inline' for flow layout in the host
anchorString'window''window' (fixed to the viewport) or 'element' (absolute inside the host)
renderBooleantrueSet false to skip injection

When label is empty, the plugin picks a locale string from type:

typeDefault CTA label
searchSearch

Positioned CTAs pin to that corner/side. anchor: 'window' mounts on document.body with position: fixed. anchor: 'element' keeps it in the host with position: absolute (the host is set to position: relative if it was static).

Custom host button (default)

<button type="button" id="my-search">Search wines</button>
<div id="sd-search"></div>
$('#sd-search').preferabliSearchDiscover({
  integration_id: '11610',
  collection_id: '794101',
  type: 'search',
  // cta_button defaults to false
});

$('#my-search').on('click', () => {
  $('#sd-search').preferabliSearchDiscover('show', { trigger: 'header_search' });
});

$('#my-close').on('click', () => {
  $('#sd-search').preferabliSearchDiscover('hide', { trigger: 'header_search' });
});

Injected Preferabli CTA

// Defaults to bottom-right on the window
$('#sd-search').preferabliSearchDiscover({
  integration_id: '11610',
  type: 'search',
  cta_button: { label: 'Find a wine' },
});

// Same as above — position/anchor are already the defaults
$('#sd-search').preferabliSearchDiscover({
  integration_id: '11610',
  type: 'search',
  cta_button: true,
});

// Custom HTML label + host classes
$('#sd-search').preferabliSearchDiscover({
  integration_id: '11610',
  type: 'search',
  cta_button: {
    label: '<img src="/icons/search.svg" alt="" /> <span>Find a wine</span>',
    className: ['my-site-cta', 'my-site-cta--search'],
  },
});

// Inline in the host element
$('#sd-search').preferabliSearchDiscover({
  integration_id: '11610',
  type: 'search',
  cta_button: { label: 'Find a wine', position: 'inline' },
});

// Absolute inside a sized host, center left
$('#sd-food-wrap').preferabliSearchDiscover({
  integration_id: '11610',
  type: 'search',
  cta_button: {
    label: 'Find a Wine',
    position: 'center-left',
    anchor: 'element',
  },
});

Style the injected CTA with --sdjs-brand-btn-bg / --sdjs-brand-btn-color, your className hooks, or .sdjs__launcher. Offset from the edge with --sdjs-launcher-inset (default 20px). See Styling.

label HTML is inserted as-is — only pass markup you trust. Mixpanel button_label is the plain-text version of label.

EventWhen
search discover cta clickedInjected Preferabli CTA is clicked (trigger: plugin_cta)
search discover shownPane opens — trigger is plugin_cta, custom, or your string
search discover hiddenPane closes — trigger is plugin_cta, custom, your string, or pane_ui (backdrop / Escape / X)

Payload includes type, foodpairing_target, merchant_variant_id, merchant_recipe_id, collection_id, channel_id, and lang.

opt_out_tracking

Type: Boolean
Default: false

When false, Disables tracking across the plugin, this can be integrated with cookie allowance.

onShow and onHide

Type: Function
Default: none

CallbackWhen it runsArgument
onShowAfter the pane opens (show)Current options object
onHideAfter the pane closes (hide)Current options object
$('#sd-search').preferabliSearchDiscover({
  integration_id: '11610',
  type: 'search',
  onShow(options) {
    console.log('opened', options.type);
  },
  onHide() {
    console.log('closed');
  },
});

Commands

Call commands as a string method on the same jQuery selection.

CommandArgumentsEffect
showoptional { trigger }Opens the pane for this instance’s type. Default trigger is custom
hideoptional { trigger }Closes the pane and clears the view stack. Default trigger is custom
changeLanguagelanguage codeUpdates API language + locale on all Search Discover instances
optOutTrackingBooleanSets opt_out_tracking on all instances (true = opted out)
$('#sd-search').preferabliSearchDiscover('show');
$('#sd-search').preferabliSearchDiscover('show', { trigger: 'header_search' });
$('#sd-search').preferabliSearchDiscover('hide');
$('#sd-search').preferabliSearchDiscover('changeLanguage', 'es');
$('#sd-search').preferabliSearchDiscover('optOutTracking', true);

Use show / hide with your own buttons when cta_button is false (the default). See cta_button.

$.fn.preferabliSD is the same method as $.fn.preferabliSearchDiscover.


Did this page help you?