const clientId="11d773d6-5a44-4c48-8e69-72590241bb4b";//each integrator will have an unique clientIdconst countryCode="RO";//country for which the plugin is usedconst langCode="ro";//language of the pluginconst city="Craiova";//User's default city to be displayed at startconst county="Dolj";//User's default county to be displayed at startconst favLockerId=143;//User's favorite delivery point which will be pre-selected at start. If favourite delivery point exists, city and county will be negligible.const favType=0;//User's favorite delivery point type, 0 for lockers and 1 for pudos.const theme="light";//theme of the plugin: light, darkconst apiUsername="myLmUsername";//integrator LM Usernameconst filters=[{"showLockers": true},{"showPudos": true}];//default filters for lockersconst initialMapCenter="City";//Where the map will be initially centered. Leave undefined to center on the user's favorite delivery point, if it exists.window.LockerPlugin.init({
clientId: clientId,
countryCode: countryCode,
langCode: langCode,
city: city,
county: county,
favLockerId: favLockerId,
favType: favType,
theme: theme
apiUsername: apiUsername
filters: filters
initialMapCenter: initialMapCenter
}); var pluginInstance = window.LockerPlugin.getInstance();Info: Multiple calls for either init() or getInstance() function won't affect the flow since LockerPlugin is implemented as singleton and will always return the same instance
Step 3
Use subscribe, open and close plugin functions
//myCustomFunction is your callback function to be executed when locker plugin pushes a post message with selected lockerpluginInstance.subscribe(myCustomFunction); //display the modal iframe windowpluginInstance.open(); Below is just an example of myCustomFunction implementation, but you can do whatever you want in callback function
function myCustomFunction(msg) { console.log("I received this msg from locker plugin:", msg);//I received this msg from locker plugin: {"lockerId":1413,"oohType":0,"name":"easybox Grozavesti","address":"str. Slt. Alexandru Borneanu nr. 20C","cityId":6,"city":"Sectorul 6","countyId":1,"county":"Bucuresti","postalCode":"061079"}//close the modal iframe windowpluginInstance.close();
}
Reinitialize Plugin Reinitialize the Locker Plugin with different options
If you need to change any of the options that you first started the plugin with, you can use the reinitializePlugin method to do so.
pluginInstance.reinitializePlugin({
clientId: clientId,
countryCode: countryCode,
langCode: langCode,
city: city,
county: county,
favLockerId: favLockerId,
favType: favType,
theme: theme
apiUsername: apiUsername
filters: filters
initialMapCenter: initialMapCenter
}); //optionally, you can also open the plugin right after reinitializationpluginInstance.open();
Favorite Locker: Get user's favorite delivery point id and type by subscribing to subscribeToFavouriteLocker method
! Precondition: Announce sameday in advance in order to enable this feature for your clientId, otherwise it won't work
//myCustomFunction2 is your callback function to be executed when locker plugin pushes a post message with new user's favorite locker action detailspluginInstance.subscribeToFavouriteLocker(myCustomFunction2); //myCustomFunction2 example:
function myCustomFunction2(favLockerMsg) { console.log("I received this msg about fav locker:", favLockerMsg);//I received this msg about fav locker: {lockerId: 199, type: 0}//If user removed his favorite locker, then received msg is: {}
}