Using the SDK functions
Accessing Utils Functions from 'sdk.utils'
Below is the sample function for ref.
sdk = window.shopline.appExtension.init({ appId: 'your app id'});
// Utils
utils = sdk.utils;
// Example
const currentPage = await utils.getCurrentPageIdentifier();
console.log(currentPage);
// Expected output: String
// product_detail
Initialising the SDK first to get access utils functions
Utils functions are part of the initialised SDK object! Can only access the utils functions after initialising the SDK
All functions in utils are async functions
Below is the sample function for ref.
sdk = window.shopline.appExtension.init({ appId: 'your app id'});
// Utils
utils = sdk.utils;
await utils.getCurrentPageIdentifier();
await utils.getCurrentThemeKey();
await utils.getLoadedLanguage();
...
Due to the async nature, always use 'await' when calling Utils functions!
Updated over 1 year ago