Setting up Storefront SDK

To setup the SDK, you should follow below steps:

  1. Check if the SDK has already been loaded
    1. If yes, you can start initializing & using the SDK directly.
    2. If no, you should listen to the onAppExtensionSDKLoaded event. On event trigger, you can start initializing & using the SDK.
  2. Initialize the SDK
  3. Start using the SDK functions

Below is the example script of the above flow:

var appId = ''; // Your app ID function useSDK() { // Initialize the SDK const sdk = window.shopline.appExtension.init({ appId }); // Start using the SDK functions ... } // Check if the SDK has already been loaded if (window.shopline.appExtension.isSDKLoaded()) { useSDK(); } else { // Listen to SDK loaded event window.addEventListener('onAppExtensionSDKLoaded', () => { useSDK(); }); }