Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bva/recommendations

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bva/recommendations

JS recommendations widget using Shopify native recommendations API

  • 0.0.1
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
2
Weekly downloads
 
Created
Source

Recommendations

Not in NPM yet. Will be soon

Installation

If you're using Node you can install this package in the following ways:

Yarn

yarn add @bva/recommendations

NPM

npm install @bva/recommendations

If you're not using Yarn or NPM, see below in Usage for more info on adding the minified file directly to your projects.

Usage

Recommendations is a simple widget using Shopify's native recommendations API that can be included on any Shopify website. Check out how easy it is to implement using ES6 modules:

import Recommendations from '@bva/recommendations';

const options = {
  productId: 10590155084,
  limit: 5,
};
const recommendation = new Shopify.Recommendations(options);
recommendation.initialize();

If you're not using NPM and ES6 import/export syntax, you can also grab the minified dist/recommendations.min.js and include it in your HTML before your custom JS. Its equally simple:

<body>
  ...
  <script src="recommendations.min.js"></script>
  <script>
    var options = {
      productId: 10590155084,
      limit: 6
    };
    var recommendation = new Shopify.Recommendations(options);
    recommendation.initialize();
  </script>

Perfect for your new slate projects

Options

  • hiddenTag - Tag that hides specific products
  • insertion - HTML element that the reviews will be inserted into
  • limit - The amount of products that will be displayed (max 10)
  • template - Template literal of the HTML for a single product

Template

A template is the HTML that is displayed for each product in the recommendations widget. Pass in a template literal to your options object and write out whatever JS works for your project. To dynamically add in product data, there are a few tags you'll want to use throughout your template and they use a format that is very similar to the Liquid code you're used to writing:

  • {& product_featured_image &}: Replaced by the product's featured image
  • {& product_title &}: Replaced by the product's title
  • {& product_price &}: Replaced by the product's price in USD
  • {& product_url &}: Replaced by the url to the product's PDP
  • {& product_handle &}: Replaced by the product's handle
  • {& product_id &}: Replacced by the product's ID
  • {& product_tags &}: Replaced by a comma separated list of the product's tags
  • {& product_images &}: Replaced by a comma separated list of the product's images
  • {& product_description &}: Replaced by the product's description
  • {& product_compare_at_price &}: Replaced by the product's compare at price in (USD)
  • {& product_type &}: Replaced by the product's type

The default template looks like:

<div class="recommendation__product" data-recommendations-product-id="{& product_id &}">
  <a href="{& product_url &}" class="recommendation__wrapper">
    <div class="recommendation__product-image-wrapper">
      <img class="recommendation__product-image" src="{& product_featured_image &}" alt="{& product_title &} image" />
    </div>
    <div class="recommendation__product-details">
      <h3 class="recommendation__product-title">{& product_title &}</h3>
      <span class="recommendation__product-price">{& product_price &}</span>
    </div>
  </a>
</div>

Events

  • recommendations.initialized: Fires when a recommendation instance is initialized. The callback you will find the product data in event.detail.data and the current instance in event.detail.context.

FAQs

Package last updated on 12 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc