Created
November 12, 2020 15:33
-
-
Save shyamvkansagra/903c236d5ab9ab978c74a33395ae280b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Change script src (e.g. "//swymv3pro-01.azureedge.net/code/swym.js"), and pid values as per your store.