Documentation for loadStorefrontScript

Function Declaration

loadStorefrontScript(brandingProfileID, styling, options)

Function Overview

The loadStorefrontScript function is designed to dynamically load and execute specific storefront scripts and styles based on a given group ID. It also allows us to update all storefronts at once when new features are added or existing ones are updated. Options that are frequently requested can be set using the options parameter.

Parameters

groupID (number)

The identifier for the specific script group to be loaded. This determines which module and styles to import.

styling (StylingParameter) (optional)

An optional object to customize the CSS variables used for styling different parts of the storefront. The properties include:

options (OptionsParameter) (optional)

An optional object to customize various display options for the storefront. The properties include:

Usage

Here is an example of how to use the loadStorefrontScript function:

          
          <!-- You should include this script tag in the head of your HTML file. You can set this in the branding profile. -->
          <script src="https://main--vividstorefronts.netlify.app/dist/main.js"></script>

          const groupID = 66;

          const styling = {
              navbarBackground: '#333',
              navbarTextColor: '#fff',
              navbarHoverColor: '#555',
          
              loginbarBackground: '#222',
              loginbarTextColor: '#ccc',
              loginbarHoverColor: '#444',
          
              primaryBackground: '#f1f1f1',
              primaryTextColor: '#000',
              primaryHoverColor: '#ddd',
          
              secondaryBackground: '#e1e1e1',
              secondaryTextColor: '#111',
              secondaryHoverColor: '#bbb',
          };

          const options = {
              hideHomeLink: true,
              hideCompanyShipTo: false,
              hideAddressBook: false,
          };
      
          loadStorefrontScript(groupID, styling, options);