3 instantsearch+ customizing- table of contents...

58
1 Overview #2 2 AutoComplete Dropdown Customization #3 1 Dashboard Configuration #4 2 Advanced Style Customization #5 3 CSS Overrides #6 4 CSS Overrides Examples #7 3 Search Results Page Customization #8 1 Dashboard Configuration 2 CSS Overrides #9 3 CSS Overrides Examples #10 4 Advanced HTML Customization using JavaScript #21 1 IS+ Options JavaScript definitions #22 8 IS+ Quick View Examples #55 2 ISP_PRODUCTS Documentation #24 9 IS+ No Results Examples #58 3 IS+ Dropdown Examples #25 4 IS+ Recommendation Examples #36 5 IS+ Collections Examples #38 6 IS+ Search Results Examples #40 7 IS+ Facets Examples #54 InstantSearch+ Customizing- Table of Contents

Upload: others

Post on 15-Jun-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

1 Overview #2

2

AutoComplete Dropdown Customization #3

1 Dashboard Configuration #4

2 Advanced Style Customization #5

3 CSS Overrides #6

4 CSS Overrides Examples #7

3Search Results Page Customization #8

1 Dashboard Configuration

2 CSS Overrides #9

3 CSS Overrides Examples #10

4

Advanced HTML Customization using JavaScript #21

1 IS+ Options JavaScript definitions #22 8 IS+ Quick View Examples #55

2 ISP_PRODUCTS Documentation #24 9 IS+ No Results Examples #58

3 IS+ Dropdown Examples #25

4 IS+ Recommendation Examples #36

5 IS+ Collections Examples #38

6 IS+ Search Results Examples #40

7 IS+ Facets Examples #54

InstantSearch+ Customizing- Table of Contents

Page 2: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

InstantSearch+ CustomizingInstantSearch+ features are designed to fit your site by inheriting your site's design. In case additional customization is needed, there are a few ways to achieve that:

Overview

InstantSearch+ Dashboard ConfigurationDisabling a feature you don't need or adding one you desire to your Premium Search Results Page or AutoComplete Dropdown, might be one click away. We recommend you to start by taking a look at InstantSearch+ dashboard sections.

Style Customization using CSS overridesRequires HTML and CSS FamiliarityChanging the style of your site's premium search results page or AutoComplete Dropdown is possible via CSS overrides. You can change the design of the search results features: colors, fonts etc.This document gives guidelines for the easiest way to do so, and includes specific examples for popular customizations you can implement to your site.

HTML Content Customization using IS+ JavaScript Callback Requires Web Development expertiseAdding details to your site's premium search results page is possible via a JavaScript callback function.It is called upon the rendering of the InstantSearch+ search results.

2

Page 3: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

2. IS+ AutoComplete Dropdown Customization

2.1. IS+ AutoComplete Dropdown Dashboard Configuration

We recommend you start by taking a look at InstantSearch+ AutoComplete Configuration section. [InstantSearch+ dashboard > AutoComplete tab]. You can preview the changes as you go, using the InstantSearch+ preview- for easy, visual customization.

GeneralDefine which content will be shown on the dropdown.• Change the number and order of products, categories and popular searches suggestions.• Disable categories suggestions – do not show any categories. • Hide product descriptions – uncheck if you wish to see the description.

StyleThese settings allow you to change the style of the dropdown content. (Products, categories, popular suggestions and their headers)• Text color – when drop down appears. • Hover text color – the color of text after placing the cursor over the product.• Hover background gradient top, Hover background gradient bottom – the color of product background after placing the cursor over the product.• Headers background, Headers text color – change the Headers style ("Products", "Categories", "Popular searches")

3

Page 4: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

Dropdown style Change the style of the dropdown box. Note that you can reset to default at any time.• Dropdown layout– you can choose between two dropdown layouts:

Vertical dropdown layout (default): Or Horizontal dropdown layout:

• Dropdown background color – when dropdown appears• Width (px) – you can change the dropdown box width. • Max description characters – if you chose to show the description.• Border color, Border width (px), Border radius (px) – border settings.• Shadow color, Shadow horizontal (px), Shadow vertical (px), Shadow blur (px) – shadow settings.

4

Page 5: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

2.2. IS+ AutoComplete Dropdown Advanced Style Customization

Additional configuration to your site's AutoComplete Dropdown is possible on InstantSearch+ AutoComplete tab – Advanced style section. In the advanced style section you will find additional configurations that allow you to change and add content to the dropdown. (This section also includes the option to add CSS style rules, discussed below.)

Advanced StyleAdd a URL of an image that will be shown in the following cases: • Ranked Product Badge image – the image will be shown next to 'always' ranked products.• Default Category thumbnail image – to be used when a category does not have an associated image.• Default Product thumbnail image – to be used when a product does not have an associated image.

These settings Require HTML and CSS Familiarity:• Bottom HTML Banner – add an HTML banner to the bottom of the drop down list with every suggestion. • This can be useful for an ongoing promotions, sales, gift cards, or any other banner that you want displayed

for any search. • For example: <a href="/your-list-goes-here"> • Custom CSS - InstantSearch+ allows adding custom CSS. This option is discussed in the next section.

5

Page 6: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

2.3. IS+ AutoComplete Dropdown Advanced Style Customization - CSS overrides

Changing the style of your AutoComplete dropdown is possible via CSS overrides. You can use the rules examples on this document, or create your own CSS rule.After creating the desired rule, paste it in the "Custom CSS" box on InstantSearch+ Dashboard > AutoComplete tab > Advanced Style:

6

Page 7: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

2.4 IS+ AutoComplete Dropdown CSS Overrides ExamplesThis section contains basic CSS rules that can be applied to your AutoComplete dropdown:

.ui-autocomplete,

.as_magento_price,.isp_price_compare_at_price_exist,.as_magento_product_name,.as_magento_product_desc,

.as_magento_product_section, .n_b_acp { font-size: 11px !important; font-weight: normal !important; }

🔍 Change the font style

ul.ui-autocomplete .ui-menu-item { margin: 5px 0 !important; }

🔍 Change the space between items

li#acp_footer_css:hover { color: #fff; }li#acp_footer_acp { font-size: 16px !important;)

🔍 Change the "Show-all-results" footer font style

.as_magento_product_sku { display: block !important; }

🔍 Show SKU

@media (max-width: 768px) { @supports (-webkit-overflow-scrolling: touch) { // For Safari only .ui-autocomplete { display: block !important; } } }

🔍 Keep displaying dropdown after scroll on IOS devices (IOS momentum scroll fix)

7

Page 8: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

3. IS+ Search Results Page CustomizationDisabling a feature you don't need or adding one you desire to your Premium Search Results Page, might be one click away. We recommend you start by taking a look at InstantSearch+ Search Results Configuration section on InstantSearch+ dashboard > Search Results tab.

3.1. IS+ Search Results Page Dashboard Configuration

Search page functionality: • "Did You Mean" suggestions – suggests visitors’ typo-corrected results.• Related Searches – don't show associated search terms. • Search results sorting – allow visitors to sort results by relevancy, price, popularity or arrival date• InstantSearch+ Search Box – control the appearance of the large InstantSearch+ search box at the

top of• the search results page.• Favorite product marking by end-users – let visitors to create a favorites list of products for easy

access. • Content (blogs, articles, pages) search – allow InstantSearch+ to search your site's content and

display relevant results.

Showing/ hiding information about products: • Add to Cart button – present visitors Add-to-Cart button within the search results page.• Quick View – allow immediate product details view from within the search results page..• Sold Out Banner – add a sold out banner to out of stock products (requires having Out of Stock

sync on)• SKU – show product SKUs on the search results page.• Prices – display or hide prices on the search results page.• Product description – show or hide product descriptions.• Color swatch – show color swatches instead of color names filters. • Badges (Shopify and WooCommerce ) – add products badges to your products, based on products

tags.• The badge will be added to the top left corner. You can modify it using custom CSS, extra details

below.

8

Page 9: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

3.2. IS+ Search Results Page Style Customization - CSS Overrides

Changing the style of your site's premium search results page is possible via CSS overrides. You can change the design of the search results features such as colors and fonts. You can use the rules examples on this document, or create your own CSS rule.The easiest way to create a new CSS rule is by:

1. Open the page in Google Chrome2. Right-click on the desired element in the screen.3. Select "Inspect"4. In the Style section hit the "+" sign and override the CSS Rule5. Paste it in the "Custom SERP CSS" box on InstantSearch+ Dashboard

9

Page 10: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

3.3 IS+ Search Results Page CSS Overrides ExamplesThis section contains basic CSS rules that can be applied to your InstantSearch+ Premium Search Results Page. General - Search Results Page style

.isp_results_summary_wrapper { display: none !important; }

🔍 Remove the Search Results Page title: "Showing # of results for ..."

li.isp_grid_product { border: none !important; }

🔍 Remove all products borders

.favorite_is-favorited .heart {

fill: #c72929 !important;

stroke: #c72929 !important; }

🔍 Change the favorites hearts color

.isp_sorting_and_result_view_wrapper #isp_search_res_sorting_menu li#search_res_sorting_title { font-weight: normal !important; }

🔍 Change the 'Sort by:' text design (bold to normal)

li.isp_grid_product { width: 30%;height: 75%;}

🔍 Change product default size / change number of products per row

10

Page 11: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

3.3 IS+ Search Results Page CSS Overrides ExamplesGeneral - Search Results Page style

li.isp_grid_product div.isp_product_info { font-size: 12px; /* Default size - 17px */}

🔍 Change product description font size

.isp_sold_out_banner_container { /*Change the banner container position*/ }

.isp_sold_out_banner_content { /*Change the “Sold Out” text design*/ }

🔍 Change Sold Out banner design

.isp_sold_out_banner {/*Change the banner rotation and color*/ transform: (45deg); color: red; }

🔍 Change “Sold Out” banner rotation and font color

div.isp_quick_view_content_left div.isp_sold_out_banner_content::after, div.isp_quick_view_content_left div.isp_sold_out_banner_content::before, li.isp_grid_product div.isp_sold_out_banner_content::after, li.isp_grid_product div.isp_sold_out_banner_content::before { border-bottom: red solid 2px; border-top: red solid 2px; }

🔍 Change “Sold Out” banner border color

li.isp_grid_product div.isp_product_info { width: 33.1%; /* bigger ‘%’ = lass product per row */}

🔍 Change product width size / amount of product per row

11

Page 12: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

3.3 IS+ Search Results Page CSS Overrides ExamplesProducts

.isp_badge .isp_product_image_wrapper:after { background-size: 100%; background-position: bottom; }

🔍 Product badge position - stretched at the bottom of the product

.isp_badge_TAGNAME .isp_product_image_wrapper:after { bottom: 3px; top: unset; height: unset; content: "LOW STOCK"; background: (0,0,0,0.7); color: white; font-size: 0.7em; }

🔍 Specific product badge position - stretched at the bottom of the product

#isp_product_quick_view_model .isp_compare_at_price, li.isp_grid_product div.isp_product_info .isp_compare_at_price { color: #000 !important; font-style: italic !important; text-decoration: line-through !important; }

🔍 Change 'compare at price' design

12

Page 13: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

3.3 IS+ Search Results Page CSS Overrides ExamplesProducts

li.isp_grid_product span.isp_search_term_highlight { background: none !important; }

🔍 Remove search term highlighting

.isp_product_title:hover { color: #000 !important; }

🔍 Change product title color upon hover

.isp_grid_product { border: none !important; background-image: none !important; -webkit-box-shadow: none !important; -moz-box-shadow: none !important; box-shadow: none !important; }

🔍 Remove boxes from products

#isp_search_results_container li.isp_grid_product .isp_product_image {width: 200px !important; /* Custom width */ height: 200px !important; /* Custom height */ }

🔍 Change product image size

13

Page 14: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

3.3 IS+ Search Results Page CSS Overrides ExamplesProducts - Color swatches in the product and in the filters

.isp-product-color-swatch-gray { /* replace 'gray' with the color as named in your product variants, omitting non-word characters such as '/' */ background-color: #eeeeee; /* replace with the necessary color */ }

🔍 Customize color swatches for each color

.isp-product-color-swatch-plaid { /* replace 'plaid' with the color as named in your product variants, omitting non-word characters such as '/' */ background-image:URL("https://cdn-gae-ssldefault.akamaized.net/images/swatches/plaid.png"); /*replace with the URL of your own image (20x20 px) */}

🔍 If you want to use an image instead of a plain color, use:

.isp_product_color_swatch .product-color-swatch { width: 20px !important; height: 20px !important; border-radius: 0% !important; border: 1px solid #000 !important; }

🔍 Change the swatch shape to square:

.isp_product_color_swatch .product-color-swatch:hover { border: 3px solid #C97320; }

🔍 Highlight swatch on hover:

14

Page 15: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

3.3 IS+ Search Results Page CSS Overrides ExamplesProducts - Color swatches in the product and in the filters

span.extra_swatch_text {display: none !important;} span.isp_product_color_swatch_pop_up {display: block;opacity: 1 !important;} span.minimize_pop_up {display: none !important;}

🔍 Show all Color Swatches

div#single_swatch { visibility: visible !important; }

🔍 Show a single swatch (if the product has only one color variant)

15

Page 16: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

3.3 IS+ Search Results Page CSS Overrides Examples

'Add to cart' and 'Quick View' buttons

li.isp_grid_product input[type="submit"].isp_add_to_cart_btn {color: blue !important; /*text color*/ background: green !important; font-size: 12px !important; }

🔍 Change the colors of the 'add to cart' button

input.isp_add_to_cart_btn:hover { background: #000 !important; }

🔍 Change the colors of the 'add to cart' background – upon hover

#isp_search_results_container li.isp_grid_product a.isp_product_quick_view_button { color: #000 !important; background-color: (255,255,255,0.9) !important; }

🔍 Change the colors of the quick view button

#isp_search_results_container li.isp_grid_product a.isp_product_quick_view_button:hover { color: #000 !important; background-color: (255,255,255,0.9) !important; }

🔍 Change the colors of the quick view button - upon hover

16

Page 17: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

3.3 IS+ Search Results Page CSS Overrides Examples

'Add to cart' and 'Quick View' buttons

.isp_quick_view_add_to_cart_form input.isp_quick_view_add_to_cart_btn { -webkit-appearance: none !important; }

🔍 Apply quick view button CSS on iPhone (or other Apple products)

li.isp_grid_product form.isp_add_to_cart_form { display: block; /* Display "Add to Cart" button at all times */ }

div.isp_center_container ul#isp_search_results_container li.isp_grid_product { min-height: 435px; /* Make the grid product high enough so the "Add to Cart" button is visible. This is a custom height which might be different for each site */ }

🔍 Make the Add To Cart button always display

#isp_search_results_container li.isp_grid_product a.isp_product_quick_view_button {position: absolute !important; left: 10% !importantwidth: 10% !important; display: block !important; top: 0; }

🔍 Make the quick view button always display on the left corner of the product

17

Page 18: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

3.3 IS+ Search Results Page CSS Overrides Examples

Review Stars

<script> var __isp_options = { isp_serp_raty_reviews_option: { starType: 'i', // Font-based stars (instead of images)

starHalf: 'spr-icon spr-icon-star-half-alt’, starOff: 'spr-icon spr-icon-star-empty’, starOn: 'spr-icon spr-icon-star’ }

} </script>

<style> .isp_product_info i.spr-icon { font-size: 80% !important; color: #bfa349; } </style>

🔍 Changing review stars color, by switching to font-based stars (For more details: https://github.com/wbotelhos/raty)

.isp_related_wrapper .yotpo { display: inline-block !important; }

.isp_related_wrapper .yotpo-stars { display: block !important; }

.isp_related_wrapper .yotpo .pull-left { text-align: center !important; }

.isp_related_wrapper .yotpo .text-m { display: inline-block !important; }

🔍 Center align review stars to product titles

18

Page 19: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

3.3 IS+ Search Results Page CSS Overrides Examples

Search Filters

#isp_left_container_facets .isp_search_res_facets_container .isp_facet_value a { color: #000 !important; font-size: 13px !important; }

🔍 Changing the filters values (attribute values) design

.isp_single_facet_wrapper .isp_facet_title .isp_facet_title_name { color: #000 !important; }

🔍 Changing the filters titles (attributes) design

#isp_left_container_facets .isp_search_res_facets_container .isp_single_facet_wrapper { border-bottom: none !important; }

🔍 Removing the borders between the filters

#isp_left_container_facets .isp_search_res_facets_container .isp_facet_value { margin: 4px !important; }

🔍 Spacing out the left sidebar

span.isp_facet_value_counter { display: none !important; }

🔍 Avoid showing the filters counter

19

Page 20: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

3.3 IS+ Search Results Page CSS Overrides Examples

Search Filters

#isp_left_container_facets .isp_search_res_facets_container .isp_facet_show_hide_values { font-size: 0.75em !important; color: #707070 !important; }

🔍 Changing the ' + Show more' and ' - Show less' design

div#isp_search_results_filter_tags .isp_filter_removable_tag { background-color: #e8e8e8 !important; font-size: 0.8em !important; color: #000 !important; }

🔍 Changing the filters tags design

20

Page 21: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4. IS+ Advanced HTML Customization using JavaScript

You can customize the various look and feel HTML elements of the Search Results, Instant Dropdown and Product Recommendation using the below JavaScript object. The main vehicle is using the JavaScript Callback functions, which are called after the rendering of the InstantSearch+ results.

The JavaScript object should be plugged at the top of your theme HTML. Notice this requires web development expertise. Our examples are provided as is and requires web developer testing before implemented on your site.

21

Page 22: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

<script> var __isp_options = __isp_options || {}; __isp_options.isp_serp_callback = function(data, facets_only) {} // SERP rendered __isp_options.isp_serp_no_results_callback = function() {} // *no* results __isp_options.isp_serp_with_product_attributes = '1' // Include product attributes __isp_options.isp_add_to_cart_callback = function(product_id, form_id) {} // After cart quantity update __isp_options.isp_serp_quickview_callback = function() {} // QuickView opened __isp_options.isp_serp_look_a_like_txt = 'Related…' // Button text __isp_options.isp_serp_articles_tab_name = 'Blog Posts' // CMS tab name __isp_options.isp_serp_shopify_image_size = '206x309' // Change default image resolution __isp_options.isp_serp_disable_seo_schema = true // Remove itemscope div __isp_options.isp_dropdown_callback = function(li_element, item_data) {} // Dropdown item __isp_options.isp_dropdown_select_callback = function(event, ui) {} // Upon dropdown item click __isp_options.isp_dropdown_open_callback = function() {} // Upon dropdown render __isp_options.isp_dropdown_with_product_attributes = '1' // Include product attributes __isp_options.dropdown_align_inputbox = 'right' // Dropdown alignment __isp_options.keep_open_all_the_time = ‘1’ // Dropdown will remain open __isp_options.dropdown_narrow_by = [[]] // Filter by parameters (JSON) __isp_options.isp_serp_ajax_header_narrow_facets =[[]]] // Filter serp by parameters __isp_options.appendTo = 'div#search_header_id' // Optional element to attach the Dropdown HTML __isp_options.STAR_REVIEWS_POSITION = 1 // 1 above or 0 under price __isp_options.isp_turbo_link_in_new_tab = false // Turbo links in new tab or same window __isp_options.variant_color_attribute = ‘color’ // Attribute name for color swatches __isp_options.isp_serp_pre_filter_callback: function(event) { }, // Fired after a shopper selects a filter __isp_options.isp_serp_avoid_scroll_after_filter: true, //Avoid the scrolling after filter select. }; </script>

4.1 IS+ Options JavaScript definitions

Have your developer use these at the <head> tag of your theme:

The JavaScript SERP callback functions may run twice if the search results filters given the filters deferred load. Your code should address the fact that the callback might be triggered twice per a given search query.

22

Page 23: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

<script> var isp_related_options = isp_related_options || {}; isp_related_options.isp_related_callback = function() {} // Recommendations rendered isp_related_options.slider = options_slidesToShow: 4 // Max product recommendations isp_related_options.with_product_attributes = false // Include product attributes isp_related_options.DECIMALS_REMOVE_ON_ROUND_PRICES = true // Remove .00 from prices like $49.00 isp_related_options.LAZYLOAD = "progressive" // Load images in advance isp_related_options.PRICE_FROM_ALWAYS = true // Render from price wording isp_related_options.RANDOMIZE = true // Add extra randomization isp_related_options.STAR_REVIEWS_POSITION = 1 // 1 for above or 0 for under price isp_related_options.responsive: [{breakpoint: 1400, settings: { slidesToShow: 4, slidesToScroll: 3, infinite: false}}, {breakpoint: 1024, settings: { slidesToShow: 3, slidesToScroll: 2, infinite: false}}] </script>

4.1 IS+ Options JavaScript definitions

Have your developer use these at the <head> tag of your theme:

23

Page 24: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.2 ISP_PRODUCTS Documentation

ISP_PRODUCTS is a JavaScript object with the currently viewed products in the search results page. In most situations the web developer will use this Object to change the content of the search results page.

Property Description Type Example

id product identifier Integer id: ”175898317”

sku product SKU code String sku: ”P64”

l Title String l: ” Skinny Jeans”

d Description String d: ”High quality martial!”

p price Float p: ”34.99”

p_c compare at price Float p_c: ”0.00”

p_min variant minimum price Float p_min: ”34.99”

p_max variant maximum price Float p_max: ”37.99”

p_max_c compare at price max Float p_max_c: ”0.00”

p_min_c compare at price min Float p_min_c: ”0.00”

t product image url String t: “https://cdn.shopify.com/...”

v_c number of variants Integer v_c : 3

vra Object containing the list of the product Variants and their attributes and values

Object

vra: Array(3):0: (2) [12190016438396, Array(4)]1: (2) [28257466961, Array(5)]2: (2) [12191863013500, Array(4)]

att product attributes (if enabled) Object

att: Array(3)0: (2) ["Brand", Array(1)]1: (2) [“Shippable", Array(1)]2: (2) [“Fabric", Array(1)]

24

Page 25: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.3 IS+ Dropdown Examples

<script>function isp_add_to_cart(event, product_id) { document.getElementById('form_' + product_id).submit(); event.preventDefault(); event.stopPropagation(); event.stopImmediatePropagation(); return false; } var __isp_options = { isp_dropdown_callback: function(jquery_li_element, item) { var product_id = jquery_li_element.attr('isp_v_id'); if (!item.id || item.category || !item.product_url) { return jquery_li_element; } var addtocart_html = '<form name="form_' + product_id + '" id="form_' + product_id + '" action="/cart/add?id=' + product_id + '" enctype="multipart/form-data" method="post" style="float: right; margin-bottom: 0px;">'; addtocart_html += '<input name="product_id" type="hidden" value="' + product_id +'">'; addtocart_html += '<input name="action" type="hidden" value="add">'; addtocart_html += '<input type="hidden" id="quantity_' + product_id + '" name="qty[]" value="1">'; addtocart_html += '<input onclick="isp_add_to_cart(event, ' + product_id + ')" type="button" value="Buy!" name="button" style="padding: 0px 10px;">'; addtocart_html += '</form>'; return jquery_li_element.prepend(addtocart_html); } };</script>

🔍 Add an Add-to-Cart button in the instant suggestions dropdown (Shopify)

25

Page 26: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

<script> function isp_add_to_cart(event, product_id) { $.ajax({ url: '/cart/add?id=' + product_id, type: 'POST', beforeSend: function(result) { console.log('adding'); }, success: function(result) { console.log('success'); jQuery.getJSON('/cart.js', function(cart) { $('.cart-count').html(cart.item_count); }); }, error: function(result) { console.log('error'); } }); event.preventDefault(); event.stopPropagation(); event.stopImmediatePropagation(); return false; } var __isp_options = { isp_dropdown_callback: function(jquery_li_element, item) { var product_id = jquery_li_element.attr('isp_v_id'); var input_s = 'isp_add_to_cart(event, ' + product_id + '")'; if (!item.id || item.category || !item.product_url) { return jquery_li_element; } var addtocart_html = '<form name="form_' + product_id + '" id="form_' + product_id + '" action="/cart/add?id=' + product_id + '" enctype="multipart/form-data" method="post" style="float: right; margin-bottom: 0px;">'; addtocart_html += '<input name="product_id" type="hidden" value="' + product_id +'">'; addtocart_html += '<input name="action" type="hidden" value="add">'; addtocart_html += '<input type="hidden" id="quantity_' + product_id + '" name="qty[]" value="1">'; addtocart_html += '<input onclick="isp_add_to_cart(event, ' + product_id + ')" type="button" value="Buy" name="button" style="background-color: #808080; color: #ffffff; padding: 0px 10px;">'; addtocart_html += '</form>'; return jquery_li_element.prepend(addtocart_html); } };</script>

🔍 Add an Add-to-Cart button in the instant suggestions dropdown (Shopify – AJAX) )

4.3 IS+ Dropdown Examples

26

Page 27: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.3 IS+ Dropdown Examples

<script>function isp_add_to_cart(event, product_id) { document.getElementById('form_' + product_id).submit(); event.preventDefault(); event.stopPropagation(); event.stopImmediatePropagation(); return false; } var __isp_options = { isp_dropdown_callback: function(jquery_li_element, item) { var product_id = jquery_li_element.attr('isp_id'); if (!item.id || item.category || !item.product_url) { return jquery_li_element; } var addtocart_html = '<form name="form_' + product_id + '" id="form_' + product_id + '" action="/cart/add?id=' + product_id + '" enctype="multipart/form-data" method="post" style="float:right;">'; addtocart_html += '<input name="product_id" type="hidden" value="' + product_id +'">'; addtocart_html += '<input name="action" type="hidden" value="add">'; addtocart_html += '<input type="hidden" id="quantity_' + product_id + '" name="qty[]" value="1">'; addtocart_html += '<input onclick="isp_add_to_cart(event, ' + product_id + ')" type="button" value="Buy!" name="button">'; addtocart_html += '</form>'; return jquery_li_element.prepend(addtocart_html); } };</script>

🔍 Add an Add-to-Cart button in the instant suggestions dropdown (BigCommerce)

27

Page 28: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.3 IS+ Dropdown Examples

<script> var __isp_options = { isp_dropdown_callback: function(jquery_li_element, item) { var product_id = jquery_li_element.attr('isp_id'); var product_sku = item.sku; if (!item.id || item.category || !item.product_url) { return jquery_li_element; } var addtocart_html = "<form style='position:relative;float:right;z-index:2147483647;' name='form_" + product_id + "' id='form_" + product_id + "' class='isp_add_to_cart_form' enctype='multipart/form data' method='post'>"; addtocart_html += "<input name='product_id' type='hidden' value=" + product_id + ">"; addtocart_html += "<input name='action' type='hidden' value='add'>"; addtocart_html += "<input name='product_sku' type='hidden' value=" + product_sku + ">"; addtocart_html += "<input type='hidden' id='quantity_" + product_id + "' name='qty[]' value='1' min='1' autocomplete='off' type='number'>"; addtocart_html += "<input id='btn_" + product_id + "' onclick='isp_add_to_cart(event, " + product_id + ", " + "&#39;" + product_sku + "&#39;" + ")' type='submit' value='ADD' class='isp_add_to_cart_btn button button--primary'>"; addtocart_html += "</form>"; return jquery_li_element.prepend(addtocart_html); }} function isp_add_to_cart(event, product_u, product_id, product_sku) { var qty = parseInt($(".cart-quantity").text()); $jquery_isp.ajax({ url:"/cart.php?action=add&sku=" + product_sku, type:"POST", beforeSend: function(result) { console.log("sending"); $("#btn_" + product_id).attr("value", "ADDING"); }, success: function(result) { console.log("success"); $("#btn_" + product_id).attr("value", "ADD"); }, error: function(result) { console.log("error"); } }); event.preventDefault(); event.stopPropagation(); event.stopImmediatePropagation();}</script>

🔍 Add an Add-to-Cart button in the instant suggestions dropdown (BigCommerce – AJAX)

28

Page 29: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.3 IS+ Dropdown Examples

<script>

var __isp_options = {

isp_dropdown_callback: function(jquery_li_element, item) {

var product_id = jquery_li_element.attr('isp_id');

var product_sku = item.sku;

if (!item.id || item.category || !item.product_url) { return jquery_li_element; }

var addtocart_html = "<form style='position: absolute; right: 0; top: 50%; transform: translateY(-50%); z-index: 2147483647;' " +

"name='form_" + product_id + "' id='form_" + product_id + "' class='isp_add_to_cart_form' enctype='multipart/form data' method='post'>";

addtocart_html += "<input name='product_id' type='hidden' value=" + product_id + ">";

addtocart_html += "<input name='action' type='hidden' value='add'>";

addtocart_html += "<input name='product_sku' type='hidden' value=" + product_sku + ">";

addtocart_html += "<input type='hidden' id='quantity_" + product_id + "' name='qty[]' value='1' min='1' autocomplete='off' type='number'>";

addtocart_html += "<input style='padding: 0; width: 60px; height: 60px; background-size: 25px; background-position: center; background-repeat:

no-repeat;' " +

"id='btn_" + product_id + "' onclick='isp_add_to_cart(event, " + product_id + ")' type='submit' value='Add' class='isp_add_to_cart_btn'>";

addtocart_html += "</form>";

return jquery_li_element.prepend(addtocart_html);}}

function isp_add_to_cart(event, product_id) {

$jquery_isp.ajax({

url: "/cart/?add-to-cart=" + product_id + "&quantity=1",

type: "POST",

beforeSend: function(result) {

console.log("adding");

$("#btn_" + product_id).css("background-image", "url(https://storagehub.vmware.com/static/images/vmware/loading.gif)");

$("#btn_" + product_id).attr("value", "");

},

success: function(result) {

console.log("success");

$("#btn_" + product_id).css("background-image", "none");

$("#btn_" + product_id).attr("value", "Add");

},

error: function(result) {

console.log("error");

}});

event.preventDefault();

event.stopPropagation();

event.stopImmediatePropagation();}

</script>

🔍 Add an Add-to-Cart button in the instant suggestions dropdown (WooCommerce – AJAX)

29

Page 30: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.3 IS+ Dropdown Examples

<script> var __isp_options = {dropdown_align_inputbox:'right’ }</script>

🔍 Align dropdown to the right

<script> var __isp_options = { DROPDOWN_TOP_OFFSET: '10', // Extra top offset for dropdown DROPDOWN_LEFT_OFFSET: '10' // Extra left offset for dropdown }</script>

🔍 Change the dropdown position

<script> var __isp_options = { isp_dropdown_callback: function(jquery_li_element) { var product_id = jquery_li_element.attr('isp_id’); var is_category = jquery_li_element.attr('isp_category’); return jquery_li_element.find('.isp_price_compare_at_price_exist').append(' <input type="button“ onclick="alert(product_id)" value="push me"/>'); } };</script>

🔍 Change the features of the drop down

30

Page 31: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.3 IS+ Dropdown Examples

<script> var __isp_options = { dropdown_narrow_by: [], // Parameters to be filtered with AVOID_POP_PRODUCTS_PRELOAD: false }; </script>

🔍 Show filtered results in the instant search dropdown

<script> __isp_options.dropdown_narrow_by = [["Categories", "Girls"]]; </script>

1. Then, upon the user choosing a category, assign the narrow category:

<script>var __isp_options = {

dropdown_narrow_by: __isp_narrow_by_type["default"],isp_dropdown_callback: function(element_jquery, item_data) {

if (item_data != null) {var search_term = $('form input[name=q]:visible').val().toLowerCase();if(search_term.includes("donkey"))__isp_options.dropdown_narrow_by = ["Category"]["Donkey"]

}return element_jquery;

},}

</script>

🔍 Example to narrow in dropdown

31

Page 32: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.3 IS+ Dropdown Examples

<script> var __isp_options = { search_element_id: 'search_box_id',// Element ID of the search box in the Content/Hubspot site HOSTNAME: 'my-eCommerce-site.com ' // Your eCommerce store destination }; </script>

🔍 Install the IS+ Dropdown Widget on a 3rd party content site like HubSpot:

1. Copy the HTML Snippet from our Sync tab of our dashboard and place it in your Content/Hubspot template in the <head>

2. Copy the following HTML Snippet while adjusting the two parameters there

32

Page 33: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.3 IS+ Dropdown Examples

<script>var __isp_options = { isp_dropdown_callback: function(jquery_li_element_html, item_data) { if (jquery_li_element_html.find('.isp_product_dropdown_review').length === 0 && item_data.reviews_count) { var stars = item_data.review / 20; var starImage; var reviews = item_data.review; var reviewsContainer = $jquery_isp('<div class="isp_product_dropdown_review" title="Average Score: ' + stars + ' | Total reviews: ' + item_data.reviews_count + '"></div>'); jquery_li_element_html.find('.as_magento_product_section').append(reviewsContainer); for (var i = 1; i <= 5; i++) { if (reviews <= 0) { starImage = $jquery_isp('<img src=“/* Empty star image */" title="empty"/>'); reviews = reviews - 20; jquery_li_element_html.find('.isp_product_dropdown_review').append(starImage); } else if (reviews % 20 === 0) { starImage = $jquery_isp('<img src=“/* Full star image */" title="full"/>'); reviews = reviews - 20; jquery_li_element_html.find('.isp_product_dropdown_review').prepend(starImage); } else { starImage =$jquery_isp('<img src=“/* Half star image */" title="half"/>'); reviews = reviews - (reviews % 20); jquery_li_element_html.find('.isp_product_dropdown_review').prepend(starImage); } } jquery_li_element_html.find('.isp_product_dropdown_review').append('<span class="isp_product_dropdown_reviews_count">(' + item_data.reviews_count + ')</span>'); } return jquery_li_element_html; }};</script>

🔍 Add Star Reviews to dropdown

33

Page 34: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.3 IS+ Dropdown Examples

<script> var __isp_options = { isp_dropdown_with_product_attributes: '1' , isp_dropdown_callback: function(jquery_li_element_html, item_data) {

if (!item_data.att) { return jquery_li_element_html } var tag = item_data.att; var found = false; for (var i = 1; i < 20 ; i++) { if(tag[i][0] == "attributes name") { tag = tag [i][1]; found = true; break; } } if(found){ var product_price = jquery_li_element_html.find(".as_magento_price").text() + " /" + tag; jquery_li_element_html.find(".as_magento_price").text(product_price); } return jquery_li_element_html; }};

</script>

🔍 Add attributes to dropdown

34

Page 35: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.3 IS+ Dropdown Examples

<script> window.addEventListener("load", function() {

var custome_css =

`

.ui-autocomplete{display:block !important}

.ui-menu-item[isp_product]>a>.as_magento_suggest>.as_img_container>img.as_magento_img,

.ui-menu-item[isp_product]>a>.as_magento_suggest>.as_img_container {

max-width: 400px!important;

max-height: 400px!important;

margin: auto!important;

width: 100% !important;

height:100% !important;

}

ul.ui-autocomplete .ui-menu-item {height:100% !important; max-width:400px; padding-left:15px

!important}

`

$jquery_isp('head').append('<style type="text/css">'+custome_css+'</style>');

});

</script>

🔍 Change dropdown product size in Horizontal view

35

Page 36: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.4 IS+ Product Recommendation Examples

<script> var isp_related_options = { slider_options_slidesToShow: 4 } </script>

🔍 Change the number of products to be shown in the Product Recommendation widget

<script> var isp_related_options = { STAR_REVIEWS_POSITION: 1 } </script>

🔍 Review stars before price

<script> var isp_related_options = { DISABLE_EXEC_SLIDE: true } </script>

🔍 Control when to initialize the Product Recommendation Slider

<script> __isp_exec_slide(); </script>

🔍 Then, when you want to show the product recommendation:

<script> var isp_related_options = { custom_related_products_render: function (data) { } // handle the related products JSON in your own style }; </script>

🔍 Render recommendation JSON by yourself

36

Page 37: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.4 IS+ Product Recommendation Examples

<script> var isp_related_options = { LAZYLOAD: "progressive" } </script>

🔍 Load product recommendation images on widget initialization

<script> var isp_related_options = { PRICE_FROM_ALWAYS: true, DECIMALS_REMOVE_ON_ROUND_PRICES: false }; </script

🔍 Show decimals on products recommendations widget

<script> var isp_related_options = { RANDOMIZE: true }; </script>

🔍 Random order of products on the products recommendations widget, upon refresh

<script> var isp_related_options = { WOOCOMMERCE_IMAGE_SIZE = '147x300’ } </script>

🔍 Change the products recommendations widget image size (WooCommerce)

37

Page 38: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.5 IS+ Collections Examples

<a class="product-vendor vendor" href="https://www.revittle.com/collections/all-products?narrow=[[“Vendor”,”{{ product.vendor }}”]]&category_id=427319060&category_url=%2Fcollections%2Fall-products&disable_semantics=1">{{ product.vendor }}</a>

🔍 Set default collection links on Shopify by vendors (example from www.revittle.com)

<script> var __isp_options = { isp_serp_callback: function() { //Filter order var order = ["Categories" ,"Tags" ,"Price" ,"Color”, “Size”]; if (document.location.pathname.indexOf(!--Name of collection to apply filter order--!) != -1) { for (var i = order.length - 1; i > -1; i--) { $(".isp_facet_title_name").each(function(index) { if (order[i] == $(this).text()) { $(".isp_single_facet_wrapper").eq(index).prependTo( $(".isp_search_res_facets_container")); } }) } } } } </script>

🔍 Change filters order for specific collection

<script> var __isp_options = { isp_serp_callback: function() { $jquery_isp('.isp_single_facet_wrapper').each(function() { if ($jquery_isp(this).find('.isp_facet_value').length === 1) { $jquery_isp(this).remove(); }

}};</script>

🔍 Remove filters with only 1 option

38

Page 39: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.5 IS+ Collections Examples

{% if collection.handle == 'new-arrivals’ %} <script> var __isp_options = { isp_smart_nav_default_sort: 'creation_date' // 'relevency', 'creation_date’ } </script> {% endif %}

🔍 Change the Default sort order in Smart Navigation per the viewed Collection -

• IS+ Dashboard > Collections tab, set the Default Sort order to be Best Match.• In your theme’s Collection.Liquid file, add the following at the top:

{% if collection.handle != 'all’ %} /* Smart Navigation script taken from the IS+ Collections tab goes here...*/{% else %} /* Shopify Built-in Collection rendering goes here ...*/{% endif %}

🔍 Avoid having Smart Navigation on a specific collection• Follow the instructions in the script and paste it in the Collection.Liquid file• Replace ‘all’ with the name of the collection you wish to keep as Shopify collection

39

Page 40: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.6 IS+ Search Results Examples

<script> var __isp_options = { isp_add_to_cart_callback: function(product_id, form_id) {} } </script>

🔍 Perform a custom operation after a successful submission of Add-to-Cart from Search Results page

<script> var __isp_options = { isp_add_to_cart_callback: function(product_id, form_id) { document.location = " Cart location URL "; } } </script>

🔍 Redirect to the cart page after submission of Add-to-Cart from Search Results page

<script> var __isp_options = { isp_serp_callback: function() { if (ISP_LAST_SEARCH.search_term == 'XYZ’) { $jquery_isp('#isp_search_results_banner') .html('<discount>'); } } } </script>

🔍 Show a specific banner per a search query in the Search Results page

40

Page 41: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.6 IS+ Search Results Examples

<script> var __isp_options = { isp_serp_look_a_like_txt: 'Similar Products’ } </script>

🔍 Change the text of the look a like button

<script> var __isp_options = { isp_serp_articles_tab_name: 'Blog Posts’ } </script>

🔍 Change the word "Articles" to "Blog Posts" (Shopify)

<script> var __isp_options = { isp_serp_callback: function() { $jquery_isp('.isp_add_to_cart_form > input[type=submit]').attr('value', 'NEW_NAME’); } } </script>

🔍 Change the text on Add-to-Cart buttons in Search Results page

41

Page 42: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.5 IS+ Search Results Examples

<script> var __isp_options = { isp_serp_callback: function() { var query = ISP_LAST_SEARCH['search_term’]; $('title').html(query + ' - Your site title’); $('meta[name=description').attr('content', query + ' powered by InstantSearch+'); } </script>

🔍 Change the <title> and meta descriptions of the search results page

<script> $(".isp_product_price_wrapper").contents().filter(function () { return this.nodeType === 3; }).remove();</script>

🔍 Remove only the "from" from the product price wrapper

<script> var __isp_options = { isp_serp_callback: function() { $jquery_isp('.isp_facet_precio .money').each(function() { $jquery_isp(this).text($jquery_isp(this).text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")); }); } }; </script>

🔍 Add commas for price filters

42

Page 43: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.6 IS+ Search Results Examples

<script> var __isp_options = { isp_serp_callback: function() { $jquery_isp('.isp_facet_precio .money').each(function() { $jquery_isp(this).text($jquery_isp(this).text(). replace(/(\d)(?=(\d\d\d)+(?!\d))/g"$1,")); }); } }; </script>

🔍 Add a banner with title and description to top of Search Results Page

<script> var favorites = document.getElementsByClassName("isp_favorite"); for (var i = 0; i < favorites.length; i++) { var product_id =(favorites[i].parentNode.parentNode. parentNode.getAttribute("product_id")); favorites[i].childNodes[0].setAttribute("onclick", favorites[i]. childNodes[0]. getAttribute("onclick") + "; addFunction(" + product_id + ")") }function addFunction(product_id) { // Add function logic here } </script>

🔍 Add functionality to favorites icon (heart above item)

43

Page 44: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.6 IS+ Search Results Examples

<script> var __isp_options = { isp_serp_callback: function() { $('.isp_grid_product') .each(function(index) { var isp_variants_options = new Object; // key: option name| value: values list var p_id = $(this) .attr('product_id'); var variant_data = ISP_PRODUCTS[p_id].vra[0][1]; for (var i = 0; i < variant_data.length; i++) { var option_name = variant_data[i][0]; if (option_name == 'Price' || option_name == 'Sellable') { continue; } var option_vals = new Array(); for (var j = 0; j < variant_data[i][1].length; j++) { option_vals.push(variant_data[i][1][j]); } if (option_name in isp_variants_options) { for (v in option_vals) { if (!v in isp_variants_options[option_name]) { isp_variants_options[option_name].append(v); } } } else { isp_variants_options[option_name] = option_vals; } } $(this) .find('.isp_product_info') .html(''); for (var option_name in isp_variants_options) { $(this) .find('.isp_product_info') .append(option_name + ': ' + isp_variants_options[option_name] +

'<br>'); } }); } }</script>

🔍 Add product attributes in search results page

44

Page 45: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.6 IS+ Search Results Examples

<script> var __isp_options = { isp_serp_callback: function() { $('.isp_grid_product') .each(function(index) { var isp_variants_options = new Object; var p_id = $(this).attr('product_id'); var variant_data = ISP_PRODUCTS[p_id].vra[0][1]; for (var i = 0; i < variant_data.length; i++) { var option_name = variant_data[i][0]; if (option_name == 'Price' || option_name == 'Sellable') { continue; } var option_vals = new Array(); for (var j = 0; j < variant_data[i][1].length; j++) { option_vals.push(variant_data[i][1][j]); } if (option_name in isp_variants_options) { for (v in option_vals) { if (!v in isp_variants_options[option_name]) { isp_variants_options[option_name].append(v); } } } else { isp_variants_options[option_name] = option_vals; } } $(this).find('.isp_product_info').html(''); for (var option_name in isp_variants_options) { $(this).find('.isp_product_info’)

.append(option_name + ': ' + isp_variants_options[option_name] + '<br>'); } }); } }</script>

🔍 Show variant attribute information

45

Page 46: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.6 IS+ Search Results Examples

<script> var __isp_options = { isp_serp_callback: function() { $('.isp_grid_product') .each(function(index) { var isp_variants_options = new Object; var p_id = $(this) .attr('product_id'); var product_data = ISP_PRODUCTS[p_id]; if (product_data.iso && product_data.iso == true) {

// Out-of-stock item... if ($(this) .find('.sold-out') .length == 0) { $(this) .prepend('<span class="sold-out">Sold Out</span>'); } } if (product_data.p_c && product_data.p_c != "") {

// Compare at price... $(this) .find('.isp_product_price') .html('<span class="on_sale">On Sale</span> $’ +

product_data.p); } }); } }</script>

🔍 Add "on sale" and “Sold Out” stickers to products

<script>var __isp_options = { isp_serp_callback: function () { $jquery_isp('.isp_grid_product').each(function() { var sold_out = $jquery_isp(".isp_sold_out_banner_content").text("Be Back Soon");

}); }};</script>

🔍 Change “Sold Out” banner text to “Be Back Soon”

46

Page 47: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.6 IS+ Search Results Examples

<script>var __isp_options = { isp_serp_callback: function() { var search_term = ISP_LAST_SEARCH["search_term"]; fbq('track', 'Search', { search_string: search_term, content_ids: barcode_id, content_type: 'product', user_type: 'Customer', }); }}</script>

🔍 Add Facebook Pixel code

<script>var __isp_options = { isp_serp_callback: function() { $jquery_isp("body").on('DOMSubtreeModified', "/***cart counter class or id***/", function () { $jquery_isp("/***mini container class or id***/").load(location.href + " /***mini

container class or id***/ > *"); }); }}</script>

🔍 Update mini-cart content after adding product to main cart

<script>var __isp_options = { isp_serp_callback: function() { $jquery_isp('.isp_single_facet_wrapper').each(function() { if ($jquery_isp(this).find('.isp_facet_check_box_icon_checked').length == 0) { $jquery_isp(this).addClass('collapsed’); $jquery_isp(this).find('a').attr('tabIndex', '-1'); } }); }}</script>

🔍 Load filters collapsed

47

Page 48: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.6 IS+ Search Results Examples

<script> var __isp_options = { isp_serp_callback: function() { $('.isp_grid_product') .each(function(index) { var isp_variants_options = new Object; var p_id = $(this).attr('product_id'); var variant_data = ISP_PRODUCTS[p_id].vra[0][1]; for (var i = 0; i < variant_data.length; i++) { var option_name = variant_data[i][0]; if (option_name == 'Price' || option_name == 'Sellable') { continue; } var option_vals = new Array(); for (var j = 0; j < variant_data[i][1].length; j++) { option_vals.push(variant_data[i][1][j]); } if (option_name in isp_variants_options) { for (v in option_vals) { if (!v in isp_variants_options[option_name]) { isp_variants_options[option_name].append(v); } } } else { isp_variants_options[option_name] = option_vals; } } $(this).find('.isp_product_info').html(''); for (var option_name in isp_variants_options) { $(this).find('.isp_product_info').append(option_name + ': ‘ +

isp_variants_options[option_name] + '<br>'); } }); } }</script>

🔍 Display additional product data for all visitors, and display product's price for logged-in users only

48

Page 49: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.6 IS+ Search Results Examples

<script>var __isp_options = { isp_serp_callback: function() { $jquery_isp('.isp_grid_product').each(function () { var p_c, p = 0.00; var id = $jquery_isp(this).attr('product_id'); if ($jquery_isp(this).find("span.isp_product_price.isp_compare_at_price_exist").length > 0){ p_c = parseFloat($jquery_isp(this).find("span.isp_product_price.isp_compare_at_price_exist")

.text().replace("$","")); p = parseFloat($jquery_isp(this).find(".isp_compare_at_price").text().replace(/[^\d.-]/g,"")); } if (ISP_PRODUCTS[id] && $jquery_isp(this).find(".product_discount_p").length == 0 && p_c > 0) { var discount = 100- Math.round((p_c / p)*100); $jquery_isp(this).find("span.isp_product_price.isp_compare_at_price_exist.money").after( '<span class="product_discount_p">('+ discount +'% OFF!)</span>'); } }); }};</script>

🔍 Display discount in % near the product price

49

Page 50: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.6 IS+ Search Results Examples

<script> var __isp_options = { isp_serp_callback: function() { jQuery.each(ISP_PRODUCTS, function(id, el) { if (el.vra) { var size = jQuery.map(el.vra[0][1], function(a) { if (a[0] == "Size") { return a[1]} }); var year = jQuery.map(el.vra[0][1], function(a) { if (a[0] == "Year") { return a[1]} }); var price = jQuery.map(el.vra[0][1], function(a) { if (a[0] == "Price") { return a[1]} }); var item = jQuery('#search-results li.isp_grid_product[product_id=' + id + ']'); var desc = item.find('.isp_product_desc'); if (item.find('.isp_product_price2').length == 0 && $('.account-link').length > 0 &&!el.iso) { desc.after($('<br><div class="isp_product_price2"></div>').text(price)) } if (item.find('.isp_product_size').length == 0) { desc.after($('<br><div class="isp_product_size"></div>').text(size)) } if (item.find('.isp_product_year').length == 0) { desc.after($('<br><div class="isp_product_year"></div>').text(year)) } item.find('.isp_product_info').addClass('product-info inside'); item.find('.isp_product_price_wrapper');} }); $('.isp_product_price_wrapper').hide(); $.each($('.isp_product_info .isp_product_image_href'), function(i, el) { var title = $(el).find('.isp_product_title').clone(); var wr = $(el).closest('.isp_product_info'); $(el).remove(); wr.prepend(title).parent().find('.isp_product_image_href:first').append(wr); });}};</script>

🔍 Display product variant info on product hover

50

Page 51: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.6 IS+ Search Results Examples

<script>var __isp_options = { isp_serp_with_product_attributes: '1', isp_serp_callback: function () { $jquery_isp('.isp_grid_product').each(function() { var id = $jquery_isp(this).attr('product_id'); // Product ID

var attributes = ISP_PRODUCTS[id].att; // Product Attributes for (var i = 0; i < attributes.length; i++) { var attr = attributes.find(function(element) {

return element[0] == "Sale" // Attribute to check})[1];

if (attr.includes("Yes")) { $jquery_isp(this).addClass('sale'); // Add class or html to the product } } }); }}</script

🔍 Add badges for products based on attributes

<script>var __isp_options = { isp_serp_callback: function () { $jquery_isp('.isp_grid_product').each(function() { var id = $jquery_isp(this).attr('product_id'); if ($jquery_isp(this).find('.cart-add').length === 0) { var addToCart = $jquery_isp('<a href=' + '"https://www.tonerbuzz.com/cart.php?action=add&amp;product_id='+id+'" ' + 'class="cart-add">Add to Cart</a>'); addToCart.insertAfter($jquery_isp(this).find('.isp_product_info'));

} }); }}</script>

🔍 Replace IS+ “Add to Cart” button with BigCommerce native “Add to Cart” modal (BigCommerce)

51

Page 52: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.6 IS+ Search Results Examples

<script>var __isp_options = { isp_serp_callback: function() { if (location.href.indexOf('search') > -1) { $jquery_isp('#isp_search_results_banner').attr('style', 'background: url(/* Add background image URL */) no-repeat; background-size: contain; min-height: 100px;'); } }}</script>

🔍 Set a custom banner background image for search results page

<script> var __isp_options = { isp_serp_callback: function() { $('head').append('<meta name="robots" content="noindex">'); } }</script>

🔍 Set a rule to set a no-index instruction of IS+ pages by SEO

<script>var __isp_options = { isp_serp_callback: function() { $jquery_isp('.isp_grid_product').each(function(index) { $jquery_isp(this).find('.isp_product_price_wrapper span').text("");</script>

🔍 Remove prices from search result page / collections

52

Page 53: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.6 IS+ Search Results Examples

<script>var __isp_options = { isp_serp_callback: function() { $jquery_isp('.isp_grid_product').each(function(index) { //Hide All prices from any search result page $jquery_isp(this).find('.isp_product_price_wrapper span').text(""); //Add "Request Price" button var title = $jquery_isp(this).find('.isp_product_title').text(); $jquery_isp(this).find('.isp_product_title').after("&nbsp;") $jquery_isp(this).find('.isp_product_price_wrapper').replaceWith ('<button id="requestPriceBtn" type="button" class="btn" style=" border-radius: 5%; margin: auto; display:block">Request Price</button>'); $jquery_isp(this).find('.btn').click(function(){ //***Your request code here***// $(this).replaceWith('<div id= "requestSent " style= "color: green; ">Price request sent! A customer service agent will email you shortly.</div>'); }); }); }}</script>

🔍 Replace prices with a “Request Price” button

53

<script>window.addEventListener("load", function() {

$('form[action*=search]').on("submit", function() { search_term = $('form input[name=q]:visible').val().toLowerCase(); if(search_term.includes("human")) { //on homepage / collection (default) do: var hidden_input = $('<input class="isp_narrow_search" type="hidden" name="narrow">'); hidden_input.val('[Type][Human]'); $('form[action*=search]').append(hidden_input); //on Serp page / collections (ISP) do: __isp_options.isp_serp_ajax_header_narrow_facets = '[Type][Human]'; }

});});</script>

🔍 Narrow the results of the next search

Page 54: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.7 IS+ Facets Examples

<script>var __isp_options = {

isp_serp_callback: function () {

$jquery_isp('div#isp_left_container').before($jquery_isp('div#isp_search_results_filter_tags'));

},

isp_serp_pre_filter_callback: function() {

$jquery_isp('div#isp_left_container').before($jquery_isp('div#isp_search_results_filter_tags'));

}

};</script>

🔍 Move “Applied filters” to the top of the left container

54

Page 55: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.8 IS+ Quick View Examples

<script>var __isp_options = {

isp_serp_quickview_callback: function() {$('.isp_quick_view_description').html(""); var id = $(".isp_quick_view_title").attr("product_id");

var url = ISP_PRODUCTS[id].u; $.ajax({ url: url, success: function(data) { data = $(data).find('div.description'); $('.isp_quick_view_description').html(data); } }); } }</script>

🔍 Show exact (HTML structure) product description from product page on Quick View

<script>var __isp_options = { isp_serp_quickview_callback: function () { var sizes = ['XS', 'SM', 'MD', 'LG', 'XL', '2X', '3X']; var options = $jquery_isp('.isp_quick_view_variant_select option'); var arr = options.map(function(_, o) { return { t: $jquery_isp(o).text(), v: o.value }; }).get(); arr.sort(function(o1, o2) { return sizes.indexOf(o1.t) > sizes.indexOf(o2.t) ? 1 : sizes.indexOf(o1.t) < sizes.indexOf(o2.t) ? -1 : 0; }); options.each(function(i, o) { o.value = arr[i].v; $jquery_isp(o).text(arr[i].t); });}}</script>

🔍 Sort Quick View variant options according to size

55

Page 56: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.8 IS+ Quick View Examples

<script>var __isp_options = { isp_serp_quickview_callback: function() { $jquery_isp('.isp_quick_view_variant_select option').each(function() { var text = $jquery_isp(this).text(); var new_text = $jquery_isp(this).text(); if (text.indexOf('Barcode') === 0) { var divider_index = text.indexOf(' | ') + 3; new_text = text.replace(text.substring(0, divider_index), ''); } else if (text.indexOf('Barcode') > 0) { var barcode_index = text.indexOf('Barcode'); var divider_last_index = text.lastIndexOf('|'); if (barcode_index < divider_last_index) { var divider_index = text.lastIndexOf(' | ') + 3; new_text = text.replace(text.substring(barcode_index, divider_index), ''); } else { new_text = text.replace(text.substring(barcode_index - 3), ''); } } $jquery_isp(this).text(new_text); }); } }</script>

🔍 Remove Barcode from Quick View variant selector

var __isp_options = { isp_serp_currency_post_symbol: "" /* so currency code won't be showing */ };

🔍 Hide currency code (USD/CAD.. Etc) from the search results page

56

Page 57: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.8 IS+ Quick View Examples

<script>var __isp_options = { isp_serp_quickview_callback: function() { $jquery_isp('.isp_grid_product').each(function () { var p_c,p = 0.00; var id = $jquery_isp(".isp_quick_view_title").attr("product_id"); if ($jquery_isp(this).find("span.isp_product_price.isp_compare_at_price_exist").length > 0){ p_c = parseFloat($jquery_isp(this).find("span.isp_product_price.isp_compare_at_price_exist").text().replace("$","")) p = parseFloat($jquery_isp(this).find(".isp_compare_at_price").text().replace(/[^\d.-]/g,"")); } if (ISP_PRODUCTS[id] && $jquery_isp(this).find(".product_discount_p").length == 0 && p_c > 0 ) { var discount =100- Math.round((p_c / p)*100); $jquery_isp(this).find("span.isp_product_price.isp_compare_at_price_exist.money").after( '<span class="product_discount_p">*'+ discount +'% OFF!*</span>'); } }); }};</script>

🔍 Display discount in % in the product Quick View

<script>var __isp_options = { isp_serp_callback: function() { $jquery_isp('.isp_product_quick_view_button').text('View Details'); });

</script>

🔍 Change all Quick View button text to “View Details”

57

Page 58: 3 InstantSearch+ Customizing- Table of Contents 4cdn.instantsearchplus.com/docs/IS++Customization+Guide.pdf · use the rules examples on this document, or create your own CSS rule

4.9 IS+ No Results Example

<script>var __isp_options = { isp_serp_no_results_callback: function() { for (var i = 0; i < Object.keys(ISP_PRODUCTS).length; i++) { (function(i) { var id = Object.keys(ISP_PRODUCTS)[i]; $jquery_isp.getJSON(ISP_PRODUCTS[id].u, {id: id}, function(data) { ISP_PRODUCTS[id].secondImage = data.product.images[1].src; }); })(i); } }}</script>

🔍 Enable 2nd image rollover on no results page

<script>var __isp_options = { isp_serp_no_results_callback: function() { $jquery_isp('.isp_no_results_title').text('New Title'); });

</script>

🔍 Change “no result” title in no result page

58