Despite the integration, informations from the customer's store (Shoper) are not sent to the edrone system
complete
Dariusz Pawlak
so is it ok?
This post was marked as
complete
This post was marked as
complete
Dariusz Pawlak
z pdf wszystko kopiuje sie w jednej lini
<script> window._edrone = window._edrone || {}; _edrone.isInitialized = false; function edrone(){ if (!_edrone.isInitialized) { _edrone.isInitialized = true;window.customerPrivacy.onMarketingConsentGranted(function () { (function (srcjs) { _edrone.app_id = 'YOUR_APP_ID'; _edrone.version = '4.0.0'; _edrone.platform = 'shoper'; frontAPI.getBasketInfo(basketInfo => { var basketCount = localStorage.getItem('edrone_basket_count') ? parseInt(localStorage.getItem('edrone_basket_count')) : 0; var basketFlag = basketInfo.basket.count > basketCount; var basketProduct = null; if (basketFlag) { basketProduct = basketInfo.products.pop(); } localStorage.setItem('edrone_basket_count', basketInfo.basket.count); frontAPI.getUser(userdata => { if (!userdata.error_description) { _edrone.email = userdata.email; _edrone.first_name = userdata.firstname; _edrone.last_name = userdata.lastname; } if (basketFlag && basketProduct) { _edrone.product_ids = basketProduct.product_id; _edrone.product_titles = basketProduct.name; _edrone.product_images = window.location.origin + '/environment/cache/images/0_0_productGfx_' + basketProduct.image_filename; } _edrone.action_type = basketFlag ? 'add_to_cart' : 'other';frontAPI.getDefaults(function (defaults) { _edrone.platform_version = defaults.shop_version; }) var category_id = document.querySelector('body').id.split('shop_category')[1]; if (category_id) { _edrone.product_category_ids = category_id; frontAPI.getCategory((category) => { _edrone.product_category_ids = category ? category.category_id : null _edrone.product_category_names = category ? category.translation.name : null }, {id: category_id}); } if (userdata.billing_address && !Boolean(userdata.error_description)) { _edrone.country = userdata.billing_address.country_code; _edrone.city = userdata.billing_address.city; } }); }) var newsletterForm = document.querySelectorAll('form[action*="newsletter/sign"]'); if (newsletterForm.length !== 0) { newsletterForm.forEach(function (form, index, array) { var emailInput = form.querySelector('input[name="email"]'); if (emailInput) { form.addEventListener('submit', function () { _edrone.email = emailInput.value; _edrone.customer_tags = 'Subscription';_edrone.action_type = 'subscribe'; _edrone.init(); }) } }) } //ADD_TO_CART function addToCartAction() { setTimeout(function(){ var frontstoreBasket = JSON.parse(localStorage.getItem('frontstoreBasket')); var products = JSON.parse(localStorage.getItem("frontstoreBasket")).products; var product = products[products.length-1]; var product_id = product.product_id; var main_image = frontAPI.getProducts({ ids: [product_id] }); localStorage.removeItem("productAddedToCart", ''); localStorage.setItem('edrone_basket_count', frontstoreBasket.basket.count); _edrone.product_ids = product_id; _edrone.product_titles = encodeURIComponent(product.name); _edrone.product_images = window.location.origin + '/environment/cache/images/0_0_productGfx_' + main_image.list[0].main_image_filename; _edrone.product_urls = product.url; _edrone.product_category_ids = product.category.category_id; _edrone.product_category_names = product.category.translation.name;_edrone.product_brand_ids = product.producer !== undefined ? product.producer.producer_id : ''; _edrone.product_brand_names = product.producer !== undefined ? product.producer.name : ''; _edrone.action_type = 'add_to_cart'; _edrone.init(); }, 2000); } function addToCartAjax() { shoper.addEvent('cart:add:ajax', function () { localStorage.setItem("productAddedToCart", "ajax"); if (localStorage.getItem("productAddedToCart") === "ajax") { addToCartAction(); } }); } if (window.shoper) { addToCartAjax(); } else { window.addEventListener('skin:initialized', function() { addToCartAjax(); }); } var addToBasketBtn = document.querySelectorAll('.addtobasket'); if(addToBasketBtn) { for (var i = 0; i < addToBasketBtn.length; i++) { addToBasketBtn[i].addEventListener('click', function() { localStorage.setItem("productAddedToCart", "add");}) } } if (localStorage.getItem("productAddedToCart") === "add") { addToCartAction(); } //END ADD_TO_CART var doc = document.createElement('script'); doc.type = 'text/javascript'; doc.async = true; doc.src = ('https:' == document.location.protocol ? 'https:' : 'http:') + srcjs; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(doc, s); _edrone.isInitialized = true; })("//d3bo67muzbfgtl.cloudfront.net/edrone_2_0.js"); //PRODUCT_VIEW (function () { function findProductIdOnProductPage() { var regex = /(\/c\/)/g; if (regex.exec(window.location.pathname) !== null) { return false; } //check for category page var body_id = document.querySelector('body').id; var id_from_input = document.querySelector('[name^="product_id"]') ? document.querySelector('[name^="product_id"]').value : false; if (~body_id.indexOf('shop_product')) { var id_from_body = body_id.split('shop_product')[1]; }var product_id = (id_from_input || (!isNaN(id_from_body) ? id_from_body : false)); return product_id; } function edroneProductView() { if (document.querySelectorAll("body")[0].id !== undefined) { var product_id = findProductIdOnProductPage(); if (product_id) { window._edrone = window._edrone || {}; window._edrone_send_handler = function () { _edrone.first_run = false; frontAPI.getProduct(function (product) { _edrone.product_ids = product_id; _edrone.product_titles = encodeURIComponent(product.name); _edrone.product_category_ids = product.category.id; _edrone.product_category_names = product.category.name; _edrone.product_images = window.location.origin + '/environment/cache/images/0_0_productGfx_' + product.main_image_filename; _edrone.product_urls = product.url; _edrone.product_brand_ids = product.producer !== undefined ? product.producer.id : ''; _edrone.product_brand_names = product.producer !== undefined ? product.producer.name : ''; _edrone.action_type = 'product_view'; _edrone.init(); }, { id: product_id });}; } } } findProductIdOnProductPage() ? edroneProductView() : window.addEventListener('load', edroneProductView); }()); //CATEGORY_VIEW (function () { function findCategoryId() { var regex = /(\/c\/)/g; if (regex.exec(window.location.pathname) !== null) { return document.querySelector('body').id.split('shop_category')[1]; } return false } function findCategoryPath(id, array) { frontAPI.getCategory((category) => { array.ids.unshift(category.category_id) array.names.unshift(category.translation.name) if(!category.root) { findCategoryPath(category.parent_id, array) } else { _edrone.product_category_ids = array.ids.join("~") _edrone.product_category_names = array.names.join("~") _edrone.action_type = 'category_view'; _edrone.init(); return} }, { id: id }); } function edroneCategoryView() { if (document.querySelector('body').id.split('shop_category')[1] !== undefined) { const category_id = findCategoryId(); let array = { ids: [], names: [] } if (category_id) { window._edrone = window._edrone || {}; window._edrone_send_handler = function () { _edrone.first_run = false; findCategoryPath(category_id, array) }; } } } findCategoryId() ? edroneCategoryView() : window.addEventListener('load', edroneCategoryView); }()); }) } } if (window.frontAPI) {edrone(); } else { document.addEventListener('frontAPIReady', () => { edrone(); }); } </script>