(function(){// window.CQuotient is provided on the page by the Analytics code:var cq = window.CQuotient;if (cq && (‘function’ == typeof cq.getCQUserId)&& (‘function’ == typeof cq.getCQCookieId)&& (‘function’ == typeof cq.getCQHashedEmail)&& (‘function’ == typeof cq.getCQHashedLogin)) {var recommender = ‘[["quik-pdp-"]]’;// removing any leading/trailing square brackets and escaped quotes:recommender=recommender.replace(/[|]|"/g,”);var separator = ‘|||’;var slotConfigurationUUID = ‘e67f710624183796089ccd583c’;var contextAUID = ‘ABJX400445’;var contextSecondaryAUID = ”;var contextAltAUID = ”;var contextType = ”;var anchorsArray = [];var contextAUIDs = contextAUID.split(separator);var contextSecondaryAUIDs = contextSecondaryAUID.split(separator);var contextAltAUIDs = contextAltAUID.split(separator);var contextTypes = contextType.split(separator);var slotName = ‘PDP-predictive-recommendation’;var slotConfigId = ‘pdp-predictive-recomendations’;var slotConfigTemplate = ‘slots/recommendation/responsive-product-slot.isml’;if (contextAUIDs.length == contextSecondaryAUIDs.length){for (i = 0; i < contextAUIDs.length; i++) {anchorsArray.push({id: contextAUIDs[i], sku: contextSecondaryAUIDs[i], type: contextTypes[i], alt_id: contextAltAUIDs[i]});}} else {anchorsArray = [{id: contextAUID, sku: contextSecondaryAUID, type: contextType, alt_id: contextAltAUID}];}var urlToCall = '/on/demandware.store/Sites-BB-US-Site/en_US/CQRecomm-Start';var params = {userId: cq.getCQUserId(),cookieId: cq.getCQCookieId(),emailId: cq.getCQHashedEmail(),loginId: cq.getCQHashedLogin(),anchors: anchorsArray,slotId: slotName,slotConfigId: slotConfigId,slotConfigTemplate: slotConfigTemplate,ccver: '1.03'};if (cq.getRecs) {cq.getRecs(cq.clientId, recommender, params, cb);} else {cq.widgets = cq.widgets || [];cq.widgets.push({recommenderName: recommender,parameters: params,callback: cb});}};function cb(parsed) {var arr = parsed[recommender].recs;if (arr && 0 < arr.length) {var filteredProductIds = '';for (i = 0; i < arr.length; i++) {filteredProductIds = filteredProductIds + 'pid' + i + '=' + encodeURIComponent(arr[i].id) + '&';}filteredProductIds = filteredProductIds.substring(0, filteredProductIds.length – 1);//to remove the trailing '&'var formData = 'auid=' + encodeURIComponent(contextAUID)+ '&scid=' + slotConfigurationUUID+ '&' + filteredProductIds;var request = new XMLHttpRequest();request.open('POST', urlToCall, true);request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');request.onreadystatechange = function() {if (this.readyState === 4) {// Got the product data from DW, showing the products now by changing the inner HTML of the DIV:var divId = 'cq_recomm_slot-' + slotConfigurationUUID;document.getElementById(divId).innerHTML = this.responseText;//find and evaluate scripts in response:var scripts = document.getElementById(divId).getElementsByTagName('script');if (null != scripts) {for (var i=0;i<scripts.length;i++) {//not combining script snippets on purposevar srcScript = document.createElement('script');srcScript.text = scripts[i].innerHTML;srcScript.asynch = scripts[i].asynch;srcScript.defer = scripts[i].defer;srcScript.type = scripts[i].type;srcScript.charset = scripts[i].charset;document.head.appendChild( srcScript );document.head.removeChild( srcScript );}}}};request.send(formData);request = null;}};})();
Reviews
There are no reviews yet.