var FreeShippingApp = { init: function () { if (IdeaCart.priceWithDiscount === undefined) { IdeaCart.priceWithDiscount = IdeaCart.totalPrice } if (this.position.includes("bottom")) { jQuery("body").append(this.appContent); }else{ jQuery("body").prepend(this.appContent); } this.createBar(); this.evenListener(); }, position: 'top', appContent : $('\u003Cstyle\u003E\n\u0020\u0020\u0020\u0020\u0023free\u002Dshipping\u002Dapp.top\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020top\u003A\u00200\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020width\u003A\u0020100\u0025\u003B\n\u0020\u0020\u0020\u0020\u007D\n\n\u0020\u0020\u0020\u0020\u0023free\u002Dshipping\u002Dapp.bottom\u0020\u007B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020bottom\u003A\u00200\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020width\u003A\u0020100\u0025\u003B\n\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020position\u003A\u0020absolute\u003B\n\u0020\u0020\u0020\u0020\u007D\n\u003C\/style\u003E\n\n\n\u003Cdiv\u0020id\u003D\u0022free\u002Dshipping\u002Dapp\u0022\u0020class\u003D\u0022top\u0022\u003E\n\u003C\/div\u003E'), minimumCargoPrice: parseFloat('750'), barHtml: "", createBar: function () { if (document.getElementById('freeShippingBar') !== null) { return; } this.barHtml = ""; if (this.getCookie("freeshipping_bar_showed")) { return; } let freeShippingSettings = '\u007B\u0022id\u0022\u003A1616,\u0022user\u0022\u003Anull,\u0022name\u0022\u003A\u0022Ideasoft\u0020\\u00d6rnek\u0020\\u015eablonu\u0022,\u0022conditionLessThanContent\u0022\u003A\u0022\u003Cp\u003E\u003Cspan\u0020style\u003D\\\u0022color\u003A\u0020\u0023000000\u003B\u0020font\u002Dsize\u003A\u002014pt\u003B\\\u0022\u003E\u003Cstrong\u003ESEPET\\u0130N\\u0130ZE\u0020\u007Bkalan_tutar\u007D\u0020TL\u0020\u0027L\\u0130K\u0020DAHA\u0020\u0026Uuml\u003BR\u0026Uuml\u003BN\u0020EKLEY\\u0130N,\u0020KARGO\u0020\u0026Uuml\u003BCRET\\u0130\u0020\u0026Ouml\u003BDEMEY\\u0130N\u0021\u003C\\\/strong\u003E\u003C\\\/span\u003E\u003C\\\/p\u003E\u0022,\u0022conditionLessThanHtml\u0022\u003A\u0022\u003Cdiv\u0020id\u003D\\\u0022freeShippingBar\\\u0022\u0020style\u003D\\\u0022background\u002Dcolor\u003A\u0023f3d512\u003B\u0020height\u003A50px\u003Bdisplay\u003A\u0020flex\u003Bjustify\u002Dcontent\u003A\u0020center\u003Balign\u002Ditems\u003A\u0020center\u003B\\\u0022\u003E\u007Bicerik\u007D\u003C\\\/div\u003E\u0022,\u0022conditionGreaterThanContent\u0022\u003A\u0022\u003Cp\u003E\u003Cspan\u0020style\u003D\\\u0022color\u003A\u0020\u0023000000\u003B\u0020font\u002Dsize\u003A\u002014pt\u003B\\\u0022\u003E\u003Cstrong\u003ETEBR\\u0130KLER\u0021\u0020ALI\\u015eVER\\u0130\\u015e\\u0130N\\u0130ZDE\u0020KARGO\u0020\u0026Uuml\u003BCRETS\\u0130Z\u0021\u003C\\\/strong\u003E\u003C\\\/span\u003E\u003C\\\/p\u003E\u0022,\u0022conditionGreaterThanHtml\u0022\u003A\u0022\u003Cdiv\u0020id\u003D\\\u0022freeShippingBar\\\u0022\u0020style\u003D\\\u0022background\u002Dcolor\u003A\u0023e10505\u003B\u0020height\u003A50px\u003Bdisplay\u003A\u0020flex\u003Bjustify\u002Dcontent\u003A\u0020center\u003Balign\u002Ditems\u003A\u0020center\u003B\\\u0022\u003E\u007Bicerik\u007D\u003C\\\/div\u003E\u0022,\u0022conditionEmptyContent\u0022\u003A\u0022\u003Cp\u003E\u003Cspan\u0020style\u003D\\\u0022color\u003A\u0020\u0023000000\u003B\u0020font\u002Dsize\u003A\u002014pt\u003B\\\u0022\u003E\u003Cstrong\u003E\u007Bkargo_fiyati\u007D\u0020VE\u0020\u0026Uuml\u003BZER\\u0130\u0020ALI\\u015eVER\\u0130\\u015e\\u0130N\\u0130ZDE\u0020\u0026Uuml\u003BCRETS\\u0130Z\u0020KARGO\u0021\u003C\\\/strong\u003E\u003C\\\/span\u003E\u003C\\\/p\u003E\u0022,\u0022conditionEmptyHtml\u0022\u003A\u0022\u003Cdiv\u0020id\u003D\\\u0022freeShippingBar\\\u0022\u0020style\u003D\\\u0022background\u002Dcolor\u003A\u0023089118\u003B\u0020height\u003A50px\u003Bdisplay\u003A\u0020flex\u003Bjustify\u002Dcontent\u003A\u0020center\u003Balign\u002Ditems\u003A\u0020center\u003B\\\u0022\u003E\u007Bicerik\u007D\u003C\\\/div\u003E\u0022,\u0022conditionEmptyBarIsShow\u0022\u003Afalse,\u0022conditionLessThanBarIsShow\u0022\u003Atrue,\u0022conditionGreaterThanBarIsShow\u0022\u003Atrue,\u0022position\u0022\u003A\u0022top\u0022,\u0022status\u0022\u003Atrue,\u0022createdAt\u0022\u003A\u00222022\u002D05\u002D31T19\u003A03\u003A43\u002B03\u003A00\u0022,\u0022updatedAt\u0022\u003A\u00222024\u002D04\u002D03T15\u003A16\u003A50\u002B03\u003A00\u0022\u007D'; freeShippingSettings = JSON.parse(freeShippingSettings); if (IdeaCart.itemCount < 1 && freeShippingSettings.conditionEmptyBarIsShow) { this.barHtml = FreeShippingApp.changeHtml(freeShippingSettings.conditionEmptyHtml, freeShippingSettings.conditionEmptyContent); } else if (IdeaCart.itemCount > 0 && IdeaCart.priceWithDiscount < this.minimumCargoPrice && freeShippingSettings.conditionLessThanBarIsShow) { this.barHtml = FreeShippingApp.changeHtml(freeShippingSettings.conditionLessThanHtml, freeShippingSettings.conditionLessThanContent); } else if (IdeaCart.itemCount > 0 && IdeaCart.priceWithDiscount >= this.minimumCargoPrice && freeShippingSettings.conditionGreaterThanBarIsShow) { this.barHtml = FreeShippingApp.changeHtml(freeShippingSettings.conditionGreaterThanHtml, freeShippingSettings.conditionGreaterThanContent); } this.appendBar(); }, changeHtml: function (conditionHtml, conditionContent) { var barHtml = conditionHtml; barHtml = barHtml.replace('{icerik}', conditionContent) barHtml = barHtml.replaceAll('{kargo_fiyati}', Number(this.minimumCargoPrice.toFixed(2))); barHtml = barHtml.replaceAll('{sepet_tutari}', IdeaCart.priceWithDiscount ? Number(IdeaCart.priceWithDiscount.toFixed(2)) : 0); barHtml = barHtml.replaceAll('{kalan_tutar}', Number((this.minimumCargoPrice - IdeaCart.priceWithDiscount).toFixed(2))); return barHtml; }, appendBar: function () { if (this.barHtml === ""){ return; } let barHtmlObject = $(this.barHtml)[0]; barHtmlObject.innerHTML += '
'; document.getElementById('free-shipping-app').append(barHtmlObject); }, closeBar: function () { let barElements = jQuery('#freeShippingBar'); if (barElements.length > 0) { this.setCookie('freeshipping_bar_showed', true, 30); } barElements.remove(); document.body.style.paddingTop = 0; }, setCookie: function (name, value, days) { var expires = ""; if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60)); expires = "; expires=" + date.toUTCString(); } document.cookie = name + "=" + (value || "") + expires + "; path=/"; }, getCookie: function (name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; }, evenListener: function () { $("#freeshipping-bar-close").on('click', function () { FreeShippingApp.closeBar(); }); let postPersist = IdeaCart.listeners.postPersist; IdeaCart.listeners.postPersist = function () { let bar = document.getElementById("freeShippingBar"); if (bar !== null){ bar.remove(); } FreeShippingApp.createBar(); return postPersist.apply(postPersist, arguments); } let postFlush = IdeaCart.listeners.postFlush; IdeaCart.listeners.postFlush = function () { let bar = document.getElementById("freeShippingBar"); if (bar !== null){ bar.remove(); } FreeShippingApp.createBar(); return postFlush.apply(postFlush, arguments); } let postRemove = IdeaCart.listeners.postRemove; IdeaCart.listeners.postRemove = function () { let bar = document.getElementById("freeShippingBar"); if (bar !== null){ bar.remove(); } FreeShippingApp.createBar(); return postRemove.apply(postRemove, arguments); } let postUpdate = IdeaCart.listeners.postUpdate; IdeaCart.listeners.postUpdate = function () { let bar = document.getElementById("freeShippingBar"); if (bar !== null){ bar.remove(); } FreeShippingApp.createBar(); return postUpdate.apply(postUpdate, arguments); } } }; FreeShippingApp.init();