Skip to content

Instantly share code, notes, and snippets.

@shyamvkansagra
Created November 12, 2020 15:33
Show Gist options
  • Save shyamvkansagra/903c236d5ab9ab978c74a33395ae280b to your computer and use it in GitHub Desktop.
Save shyamvkansagra/903c236d5ab9ab978c74a33395ae280b to your computer and use it in GitHub Desktop.
<script type="text/javascript" src="YOUR_SCRIPT_URL"></script>
<script type="text/javascript">
var swymJSObject = {
pid: "YOUR_PID_VALUE"
};
window.swymJSCCLoad = function(){
if(!window._swat) {
console.log("swymJSCCLoad", "if");
(function (s, w, r, e, l, a, y) {
r['SwymRetailerConfig'] = s;
r[s] = r[s] || function (k, v) {
r[s][k] = v;
};
})('_swrc', '', window);
_swrc('RetailerId', swymJSObject.pid);
_swrc('Callback', function(){initSwymCC();});
}else if(window._swat.postLoader){
console.log("swymJSCCLoad", "else if", swymJSObject);
_swrc = window._swat.postLoader;
_swrc('RetailerId', swymJSObject.pid);
_swrc('Callback', function(){initSwymCC();});
}else{
console.log("swymJSCCLoad", "else");
initSwymCC();
}
}
window.initSwymCC = function() {
var swat = window._swat;
var swymPageData = {"et": 0};
var regid = swat.getSwymRegistrationId();
if(!regid) {
swat.refresh(initUI(), function() { console.log("Swym - Failed to create regid"); });
return;
} else {
initUI();
}
function initUI() {
// Your UI code and API calls go here
}
window.swymJSCCLoad();
</script>
@shyamvkansagra
Copy link
Author

Change script src (e.g. "//swymv3pro-01.azureedge.net/code/swym.js"), and pid values as per your store.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment