Discount Ninja
  • Discount Ninja Developer Hub
    • Storefront API
      • Promotion Engine
        • Enable
        • JavaScript API
          • Functions
          • Events
          • Objects
      • Widgets
        • Guiding principles
          • Accessibility
          • Localization
          • Integration
          • Style
        • Announcement Bar
        • Notification
        • Offer Rules Popup
        • Product Banner
        • Promotion Summary
        • Promotion Code Field
        • Promotional Badge
    • Integration
    • Theme edits
      • App blocks
        • Product Page Banner
        • Promo Code Field
        • Promotion Summary
      • Code edits
        • Product Detail Page (PDP)
          • Price
          • Banner
          • Badge
        • Product List Page (PLP) and Collections
          • Attributes
          • Price
            • Searchanise Search & Filter
            • Globo Smart Product Filter & Search (aka SPF)
            • AI Search & Product Filter (Ultimate Search)
            • Boost AI Search & Filter (aka PFS)
          • Badge
          • Pagination
          • Quick View
        • Cart
          • Root
          • Cart item
          • Promo Code Field
          • Promotion Summary
          • Subtotal
        • Gift With Purchase
Powered by GitBook
On this page
  • Version 0
  • Version 1
  • HTML Template
  • JavaScript
  • Version 2
  • HTML Template
  • JavaScript
  • QuickView
  • Search suggestions
  • Version 3
  • BuildDataTags function

Was this helpful?

  1. Discount Ninja Developer Hub
  2. Theme edits
  3. Code edits
  4. Product List Page (PLP) and Collections
  5. Price

Boost AI Search & Filter (aka PFS)

PreviousAI Search & Product Filter (Ultimate Search)NextBadge

Last updated 8 months ago

Was this helpful?

Version 0

  • Find the file bc-sf-filter.js

  • Find the var bcSfFilterTemplate variable.

  • Add {{discountNinjaDataTags}} where the data tags should be placed

  • And add the class where the collection badge should be displayed

  • And <span class="la-dn-price">…</span> around the price section (if present), typically {{itemPrice}}

  • Add before the BCSfFilter.prototype.buildProductGridItem function.

    • IMPORTANT: prices will be multiplied by 100

    • Avoid this by making the following change in the function: change var pricesAreCents = false; to var pricesAreCents = true;

  • Before the end of each of the BCSfFilter.prototype.buildProductGridItem function, add the following code:

//Discount Ninja integration       
itemHtml = itemHtml.replace(/{{discountNinjaDataTags}}/g, buildDiscountNinjaDataTags(data));

Version 1

HTML Template

See V2

JavaScript

  • Find the file boost-pfs-filter.js

  • Find the var boostPFSTemplate variable.

  • Add {{discountNinjaDataTags}} where the data tags should be placed

  • And <span class="la-dn-price">…</span> around the price section (if present), typically {{itemPrice}}

  • Before the end of each of the compileTemplate functions for the gridView (ProductListItem.prototype.compileTemplate) and the listView (ProductGridItem.prototype.compileTemplate), add the following code:

//Discount Ninja integration       
itemHtml = itemHtml.replace(/{{discountNinjaDataTags}}/g, buildDiscountNinjaDataTags(data));

Version 2

HTML Template

  • Find the file boost-pfs-filter-html.liquid

  • Find the productGridItemHtml and productListItemHtml sections

  • Add {{discountNinjaDataTags}} where the data tags should be placed

  • And <span class="la-dn-price">…</span> around the price section (if present), typically {{itemPrice}}

JavaScript

  • Find the file boost-pfs-filter.js

  • Before the end of each of the compileTemplate functions for the gridView (ProductListItem.prototype.compileTemplate) and the listView (ProductGridItem.prototype.compileTemplate), add the following code:

//Discount Ninja integration       
itemHtml = itemHtml.replace(/{{discountNinjaDataTags}}/g, buildDiscountNinjaDataTags(data));
  • Find the end of the Filter.prototype.afterRender function

  • Add the following code:

//Discount Ninja integration 
document.dispatchEvent(new CustomEvent('la:dn:collection:productsadded'));

QuickView

  • Find the product.boost-pfs-quickview.liquid file

  • Add the following to the div with class boost-pfs-quickview-right product-details:

data-la-dn-product-handle="{{ product.handle }}" data-la-dn-product-quickview
  • Add the following to the div with class boost-pfs-quickview-price

limoniapps-discountninja-productprice limoniapps-discountninja-productprice-dynamic

Search suggestions

Currently not supported. No template in Liquid files.

Version 3

With Version 3 the app doesn’t add any assets to the theme so we’ll have to use the CSS selectors approach.

  • Go to Discount ninja > Settings > Dynamic pricing > Theme Configuration and enable Mix mode:

  • It’ll unlock the second tab ‘ Live Theme ‘, go to this tab and enable ‘Custom’ option for Collection pages

  • Now go to Collection page and enable ‘Custom CSS selector’ and add the following classes:

    • Price (desktop) : [[WRAP]].boost-sd__product-price-wrapper, .boost-sd__suggestion-queries-item-price

    • Card: .boost-sd__product-item, .boost-sd__suggestion-queries-item

    • Handle: [[HANDLE:href]]a.boost-sd__product-link

BuildDataTags function

//Discount Ninja integration
function buildDiscountNinjaDataTags(data) {
    function buildTags(tags) {
      try {
        if (typeof tags === 'undefined' || tags === null) return '';
        
        if (typeof tags === 'string') {
            return tags ? tags.replace(/"/g, "&quot;") : '';
        }
        else if (Array.isArray(tags)) {
            return tags.join(',').replace(/"/g, "&quot;");
        }
        else {
            console.error('Boost PFS buildTags failed, unexpected data type of tags', e);
            return '';
        }
      }
      catch(e) {
          console.error('Boost PFS buildTags failed', e);
          return '';
      }  
    }
  
    try {
        var pricesAreCents = false;
        var pricesMultiplicator = pricesAreCents ? 1 : 100;    
        var discountNinjaItemHandle = data.handle;
        var discountNinjaItemCollectionHandles = '';
        var discountNinjaItemCollectionIds = '';
        if (data.collections && data.collections.length > 0) {
          for (var i = 0; i < data.collections.length; i++) {
              discountNinjaItemCollectionHandles += data.collections[i].handle + ","; 
              discountNinjaItemCollectionIds += data.collections[i].id + ","; 
          }
        }
        var discountNinjaItemAvailable = data.available;
        var firstAvailableVariant = null;
        for (var i = 0; i < data.variants.length; i++) {
            var variant = data.variants[i];
            if (variant.available) {
               firstAvailableVariant = variant;
               break;
            }
        }
        if (firstAvailableVariant === null) firstAvailableVariant = data.variants[0];
        var discountNinjaItemPrice = firstAvailableVariant && firstAvailableVariant.price > 0 ? firstAvailableVariant.price * pricesMultiplicator : 0;
        var discountNinjaItemCompareAtPrice = firstAvailableVariant && firstAvailableVariant.compare_at_price > 0 ? firstAvailableVariant.compare_at_price * pricesMultiplicator : 0;
        var discountNinjaItemPriceVaries = data.price_min != data.price_max;
        var discountNinjaItemPriceMin = data.price_min ? data.price_min * pricesMultiplicator : 0;
        var discountNinjaItemTags = buildTags(data.tags);
        return 'data-limoniapps-discountninja-product-handle="' + discountNinjaItemHandle + '" data-limoniapps-discountninja-product-collections="' + discountNinjaItemCollectionHandles + '" data-limoniapps-discountninja-product-collectionids="' + discountNinjaItemCollectionIds + '" data-limoniapps-discountninja-product-available="' + discountNinjaItemAvailable + '" data-limoniapps-discountninja-product-price="' + discountNinjaItemPrice + '" data-limoniapps-discountninja-product-compareatprice="' + discountNinjaItemCompareAtPrice + '" data-limoniapps-discountninja-product-pricevaries="' + discountNinjaItemPriceVaries + '" data-limoniapps-discountninja-product-pricemin="' + discountNinjaItemPriceMin + '" data-limoniapps-discountninja-product-tags="' + discountNinjaItemTags + '"';
    }
    catch(e) {
    	console.error('Boost PFS buildDiscountNinjaDataTags failed', e);
        return '';
    }
}

And add the where the collection badge should be displayed

Add before the compileTemplate functions.

And add the where the collection badge should be displayed

Add before the compileTemplate functions. (under “BUILD PRODUCT LIST”)

Below the block add the

collection badge class
collection badge class
product banner
collection badge
this function
this function
this function
Mark price section
Add tags to HTML
Mark product price and tags
Add tags to HTML
Dispatch event
Mixed mode
Custom mode of PLP
CSS selectors