Setting up Storefront SDK
To setup the SDK, you should follow below steps:
- Check if the SDK has already been loaded
- If yes, you can start initializing & using the SDK directly.
- If no, you should listen to the
onAppExtensionSDKLoaded
event. On event trigger, you can start initializing & using the SDK.
- Initialize the SDK
- 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();
});
}
Updated 3 days ago