window.onload = () => { setTimeout(() => { const liquid_search_input_lg = document.getElementById("cx_1630815321671_search_input_lg"); const cx_1630815321671_search_input_md_sm = document.getElementById("cx_1630815321671_search_input_md_sm"); liquid_search_input_lg?.removeAttribute("placeholder"); cx_1630815321671_search_input_md_sm?.removeAttribute("placeholder"); timeout_var = null; function typeWriter(selector_target, text_list, placeholder = false, i = 0, text_list_i = 0, delay_ms = 110) { if (!i) { if (placeholder) { document.querySelector(selector_target).placeholder = ""; } else { document.querySelector(selector_target).innerHTML = ""; } }; txt = text_list[text_list_i]; if (i < txt.length) { if (placeholder) { document.querySelector(selector_target).placeholder += txt.charAt(i); } else { document.querySelector(selector_target).innerHTML += txt.charAt(i); } i++; setTimeout(typeWriter, delay_ms, selector_target, text_list, placeholder, i, text_list_i); } else { text_list_i++; if (typeof text_list[text_list_i] === "undefined") { setTimeout(typeWriter, (delay_ms * 5), selector_target, text_list, placeholder); } else { i = 0; setTimeout(typeWriter, (delay_ms * 3), selector_target, text_list, placeholder, i, text_list_i); } } }; text_list = [ "Search By Products Name", "Example 1 : Electric Hot Water Bag", "Example 2 : Pregnancy Test Cassette Device Kit ", "Example 3 : Compressor Nebulizer Machine", "Example 4 : Blood Pressure Monitor" ]; typeWriter("#cx_1630815321671_search_input_lg", text_list, true); typeWriter("#cx_1630815321671_search_input_md_sm", text_list, true); // add all products button in navbar const cx_1630815321671_header_nav = document.querySelector(".cx_1630815321671_header_nav"); const allProductMneuWrapper = elementMaker("div", ["allProductMneuWrapper"]); cx_1630815321671_header_nav.appendChild(allProductMneuWrapper); const allProductMenu = elementMaker("span", ["allProductMenu", "cx_1630815321671_main_nav_link"]); allProductMenu.textContent = `Products`; allProductMneuWrapper.appendChild(allProductMenu); allProductMneuWrapper.addEventListener("click", function () { typeof handleNavigate == "function" && handleNavigate("/items"); }); // buy now button on item page let myEventfunction = () => { setTimeout(() => { const cx_1632983997891_product_details_quantity_content_wrap = document.querySelector(".cx_1632983997891_product_details_quantity_content_wrap"); const buy_now_button_wrapper = elementMaker("div", ["buy_now_button_wrapper"]); const buy_now_button = elementMaker("button", ["buy_now_button", "cx_1632983997891_product_details_cart_btn"]); buy_now_button.textContent = `Buy Now`; buy_now_button_wrapper.appendChild(buy_now_button); let childNodesLength = cx_1632983997891_product_details_quantity_content_wrap?.childNodes?.length; if (childNodesLength == 3) { cx_1632983997891_product_details_quantity_content_wrap.appendChild(buy_now_button_wrapper); } buy_now_button_wrapper.addEventListener("click", async function () { document.getElementById("cx_1632983997891_add_to_cart").click(); setTimeout(() => { typeof handleNavigate == "function" && handleNavigate("/cart"); }, 500); }); }, 1200); }; // link change watcher let previousHistory = ''; setInterval(() => { if (window.location.href !== previousHistory) { previousHistory = window.location.href; myEventfunction(); } }, 100); }, 1200); /* setTimeout(() => { const contact_us_main_wrapper = document.querySelector(".contact_us_main_wrapper"); console.log("contact_us_main_wrapper", contact_us_main_wrapper); const tradeLisence = elementMaker("li", ["add_trade_lisence"]); tradeLisence.textContent = `ই-ট্রেড লাইসেন্স - TRAD/DSCC t033477t2022`; contact_us_main_wrapper.appendChild(tradeLisence); }, 2000); */ // const body_container = document.querySelector(".body_container"); const body_container = document.querySelector("body"); const circuleButton_wrapper = elementMaker("div", ["circuleButton_wrapper"], "circuleButton_wrapper_id"); const topIcon = elementMaker("div", ["topIcon"]); topIcon.innerHTML = ` `; circuleButton_wrapper.appendChild(topIcon); body_container.appendChild(circuleButton_wrapper); window.onscroll = function () { scrollFunction() }; function scrollFunction() { if (document.body.scrollTop > 40 || document.documentElement.scrollTop > 40) { circuleButton_wrapper.style.display = "block"; // circuleButton_wrapper.style.transform = `translateX(0)`; } else { circuleButton_wrapper.style.display = "none"; // circuleButton_wrapper.style.transform = `translateX(100px)`; } } const circuleButton_wrapper_id = document.getElementById("circuleButton_wrapper_id"); circuleButton_wrapper_id.addEventListener("click", function () { document.documentElement.scrollTop = 0; }); function elementMaker(name, className, id) { try { let element = document.createElement(name); className && (element.className = className.join(" ")); id && (element.id = id); return element; } catch (err) { console.log(err.message); }; }; function setAttributes(elementName, allAttributes) { for (let key in allAttributes) { elementName.setAttribute(key, allAttributes[key]); }; }; } window.onload = () => { setTimeout(() => { let myEventfunction = () => { setTimeout(() => { const ItemLocation = window.location.href; let checkoutPage = ItemLocation.includes("/checkout"); if (checkoutPage) { const _choose_address__buttons_f0umj_18 = document.querySelector("._choose_address__buttons_f0umj_18"); _choose_address__buttons_f0umj_18.children[0].classList.add("_active_f0umj_38"); _choose_address__buttons_f0umj_18.children[0].click(); const content__text = document.querySelector(".content__text"); content__text.innerText = `অর্ডার করতে নিচের ফর্মটি পূরণ করুন `; } }, 1200); }; // link change watcher let previousHistory = ''; setInterval(() => { if (window.location.href !== previousHistory) { previousHistory = window.location.href; myEventfunction(); } }, 100); }, 1000); function elementMaker(name, className, id) { try { let element = document.createElement(name); className && (element.className = className.join(" ")); id && (element.id = id); return element; } catch (err) { console.log(err.message); }; }; function setAttributes(elementName, allAttributes) { for (let key in allAttributes) { elementName.setAttribute(key, allAttributes[key]); }; }; } // Datalayer Variable of Soppiya window.onload = () => { setTimeout(() => { const BUSINESS_ID = "63d0a044cfaa2ba2bb9810af"; // hafsaexpress business ID const LoadDataFunction = async (url) => { try { let response = await fetch(url, { method: "get", headers: { "businessid": `${BUSINESS_ID}` } }); response = await response.json(); if (response.Error) { return console.log(response.Error) }; return response; } catch (e) { return }; }; // item item page event let myEventfunction = () => { setTimeout(async () => { const ItemLocation = window.location.href; let checkItemPage = ItemLocation.includes("/item"); if (checkItemPage) { const itemName = window.location.href; let url_pathname = itemName; let urlInfo = url_pathname.split("/"); let itemNamePathID = urlInfo[4]; // console.log("itemNamePathID", itemNamePathID); const getItemData = await LoadDataFunction(`https://api.soppiya.com/v2.1/widget/item/info/${itemNamePathID}`); // console.log("getItemData", getItemData); const basePrice = getItemData.basePrice; // console.log("basePrice", basePrice); let discount = 0; if (getItemData.flashPrice) { const FlashPrice = getItemData.flashPrice; console.log("FlashPrice", FlashPrice); discount = basePrice - FlashPrice; console.log("discount", discount); } let MainPrice = basePrice - discount; // console.log("MainPrice", MainPrice); dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object. dataLayer.push({ event: "view_item", ecommerce: { currency: "BDT", value: `${MainPrice}`, items: [ { item_id: `${getItemData._id}`, item_name: `${getItemData.name}`, discount: `${discount}`, price: `${getItemData.basePrice}`, } ] } }); } // Check Out start google taq code const cartPage = window.location.href; const checkCartPage = cartPage.includes("/cart"); if (checkCartPage) { const _checkout_button_170q6_31 = document.querySelector("._checkout_button_170q6_31 "); _checkout_button_170q6_31.addEventListener("click", async function () { const cartData = await handleCartCompilation(); console.log("cart page Cart All Item", cartData); dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object. dataLayer.push({ event: "begin_checkout", ecommerce: { currency: "BDT", value: `${cartData.summary.totalAmount}`, items: [...cartData.details], quantity: `${cartData.summary.totalCount}` } }); }); } // auto select checkout page Home option select const checkOutPageLocation = window.location.href; let checkoutPage = checkOutPageLocation.includes("/checkout"); if (checkoutPage) { const _choose_address__buttons_f0umj_18 = document.querySelector("._choose_address__buttons_f0umj_18"); _choose_address__buttons_f0umj_18.children[0].classList.add("_active_f0umj_38"); _choose_address__buttons_f0umj_18.children[0].click(); const content__text = document.querySelector(".content__text"); content__text.innerText = `Fill out the form below to order`; } }, 1000); }; // link change watcher let previousHistory = ''; setInterval(() => { if (window.location.href !== previousHistory) { previousHistory = window.location.href; myEventfunction(); } }, 100); }, 1000); function elementMaker(name, className, id) { try { let element = document.createElement(name); className && (element.className = className.join(" ")); id && (element.id = id); return element; } catch (err) { console.log(err.message); }; }; function setAttributes(elementName, allAttributes) { for (let key in allAttributes) { elementName.setAttribute(key, allAttributes[key]); }; }; }