Skip to content

Instantly share code, notes, and snippets.

@blaswan
Created January 16, 2017 11:39
Show Gist options
  • Select an option

  • Save blaswan/9a6f066084080a5675fd567602cb0d8c to your computer and use it in GitHub Desktop.

Select an option

Save blaswan/9a6f066084080a5675fd567602cb0d8c to your computer and use it in GitHub Desktop.
<!-- Channel Plugin Scripts -->
<script>
window.channelPluginSettings = {
"plugin_id": "YOUR_PLUGIN_ID"
};
<!--{if $smarty.session.customer.customer_id}-->
window.channelPluginSettings.user = {
"id": "<!--{$smarty.session.customer.customer_id}-->",
"name": "<!--{$smarty.session.customer.name01}--> <!--{$smarty.session.customer.name02}-->",
"mobileNumber": "<!--{$smarty.session.customer.cell01}--><!--{$smarty.session.customer.cell02}--><!--{$smarty.session.customer.cell03}-->",
"meta": {
"email": "<!--{$smarty.session.customer.email}-->",
"gender": "<!--{$smarty.session.customer.sex}-->",
"job": "<!--{$smarty.session.customer.job}-->",
"note": "<!--{$smarty.session.customer.note}-->",
"status": "<!--{$smarty.session.customer.status}-->"
}
};
var birth_date = '<!--{$smarty.session.customer.birth}-->';
if (birth_date !== '') {
window.channelPluginSettings.user.meta.birth_date = new Date(birth_date);
}
var first_buy_date = '<!--{$smarty.session.customer.first_buy_date}-->';
if (first_buy_date !== '') {
window.channelPluginSettings.user.meta.first_buy_date = new Date(first_buy_date);
}
var last_buy_date = '<!--{$smarty.session.customer.last_buy_date}-->';
if (last_buy_date !== '') {
window.channelPluginSettings.user.meta.last_buy_date = new Date(last_buy_date);
}
var buy_times = '<!--{$smarty.session.customer.buy_times}-->';
if (buy_times !== '' && !isNaN(buy_times)) {
window.channelPluginSettings.user.meta.buy_times = Number(buy_times);
}
var buy_total = '<!--{$smarty.session.customer.buy_total}-->';
if (buy_total !== '' && !isNaN(buy_total)) {
window.channelPluginSettings.user.meta.buy_total = Number(buy_total);
}
var point = '<!--{$smarty.session.customer.point}-->';
if (point !== '' && !isNaN(point)) {
window.channelPluginSettings.user.meta.point = Number(point);
}
<!--{/if}-->
(function() {
var node = document.createElement('div');
node.id = 'ch-plugin';
document.body.appendChild(node);
var async_load = function() {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = '//cdn.channel.io/plugin/ch-plugin-web.js';
s.charset = 'UTF-8';
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
};
if (window.attachEvent) {
window.attachEvent('onload', async_load);
} else {
window.addEventListener('load', async_load, false);
}
})();
</script>
<!-- End Channel Plugin -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment