$(() => {
shopby.naverInflow = {
useCPA: false,
authenticationKey: '',
appendScriptTag: (scriptTag, type = 'head') => {
const range = document.createRange().createContextualFragment(scriptTag);
document[type].append(range);
},
setLogScript: () => {
const scriptTag = '';
shopby.naverInflow.appendScriptTag(scriptTag);
},
setNaverShoppingConfiguration: ({ supportsNaverShopping, authenticationKey, agreedToCollectingCPAOrder } = {}) => {
shopby.naverInflow.useCPA = agreedToCollectingCPAOrder;
shopby.naverInflow.authenticationKey = authenticationKey;
if (!supportsNaverShopping) return;
const { hostname } = location;
const scriptTag = ``;
shopby.naverInflow.appendScriptTag(scriptTag);
},
setNaverWebmaster: naverWebmaster => {
if (!naverWebmaster) return;
const scriptTag = ``;
shopby.naverInflow.appendScriptTag(scriptTag);
shopby.naverInflow.setLogScript();
},
async initiate() {
this.wcsDo();
},
setExecuteScript: () => {
const $wcsDo = document.querySelector('#wcsDoScript');
if ($wcsDo) return;
const scriptTag = ``;
shopby.naverInflow.appendScriptTag(scriptTag, 'body');
},
wcsDo() {
const currentPath = location.pathname;
if (!currentPath.includes('/pages/order/order-complete.html')) {
if (!window.wcs_add) {
window.wcs_add = {};
}
window.wcs_add['wa'] = shopby.naverInflow.authenticationKey;
window.wcs.inflow(location.host.replace('www.', ''));
window.wcs_do();
}
},
wcsDoCPA: function (cpaOrder, goodsPrice) {
if (!window.wcs_add) {
window.wcs_add = {};
}
window.wcs_add['wa'] = shopby.naverInflow.authenticationKey;
window.wcs.inflow(location.host.replace('www.', ''));
const _nao = {};
if (window.wcs.isCPA && shopby.agreeCPA === 'Y') {
_nao['chn'] = 'AD';
_nao['order'] = JSON.stringify(cpaOrder);
window.wcs.CPAOrder(_nao);
}
const _nasa = {};
_nasa['cnv'] = window.wcs.cnv('1', goodsPrice);
window.wcs_do(_nasa);
},
};
shopby.start.entries.push(shopby.naverInflow.initiate.bind(shopby.naverInflow));
});