var couponapp_domain = "https://coupon-x.premio.io/", fullpathName = window.location.href, path_name = window.location.pathname, path_name = path_name.substr(1), shopurl = Shopify.shop, couponapp_html = "", couponapp_settings = '', updatecount = 0, country_name = "", currentCountryCount = 0, couponapp_storeid = 0, isowner = 'no', is_updatevisitor = 0, couponapp, is_clipboard = 0, clipboard, myReferer='', unique_code='', is_page_scroll_index = -1; var ab_widges_arr = []; var timeInterval=''; var isCXMobile; var is_trigger_cart = false; (function(){ var loadScript = function(url, callback){ var script = document.createElement("script"); script.type = "text/javascript"; // If the browser is Internet Explorer. if (script.readyState){ script.onreadystatechange = function(){ if (script.readyState == "loaded" || script.readyState == "complete"){ script.onreadystatechange = null; callback(); } }; // For any other browser. } else { script.onload = function(){ callback(); }; } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); }; var CouponAppJavaScript = function(jQuery, show_widget = false){ var shopify_coupon_domain = window.location.hostname; var customerId = window.ShopifyAnalytics.meta.page.customerId; if ( typeof customerId == 'undefined' ) { if (typeof Shopify.checkout != 'undefined' ) { customerId = Shopify.checkout.customer_id; } if ( typeof customerId == 'undefined' ) { customerId = 0; } } var origin_landing_page = window.location.href; if (document.referrer) { myReferer = document.referrer; } // Temporary close for flow execution 22/12/2022 if (jQuery('link#couponx-front-css').length == 0 ) { jQuery('head').append(''); //jQuery('head').append(''); jQuery('head').append(''); } isCXMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ? true : false; var isbotuser = 'no'; var botPattern = "(googlebot\/|bot|Googlebot-Mobile|Googlebot-Image|Google favicon|Mediapartners-Google|bingbot|slurp|java|wget|curl|Commons-HttpClient|Python-urllib|libwww|httpunit|nutch|phpcrawl|msnbot|jyxobot|FAST-WebCrawler|FAST Enterprise Crawler|biglotron|teoma|convera|seekbot|gigablast|exabot|ngbot|ia_archiver|GingerCrawler|webmon |httrack|webcrawler|grub.org|UsineNouvelleCrawler|antibot|netresearchserver|speedy|fluffy|bibnum.bnf|findlink|msrbot|panscient|yacybot|AISearchBot|IOI|ips-agent|tagoobot|MJ12bot|dotbot|woriobot|yanga|buzzbot|mlbot|yandexbot|purebot|Linguee Bot|Voyager|CyberPatrol|voilabot|baiduspider|citeseerxbot|spbot|twengabot|postrank|turnitinbot|scribdbot|page2rss|sitebot|linkdex|Adidxbot|blekkobot|ezooms|dotbot|Mail.RU_Bot|discobot|heritrix|findthatfile|europarchive.org|NerdByNature.Bot|sistrix crawler|ahrefsbot|Aboundex|domaincrawler|wbsearchbot|summify|ccbot|edisterbot|seznambot|ec2linkfinder|gslfbot|aihitbot|intelium_bot|facebookexternalhit|yeti|RetrevoPageAnalyzer|lb-spider|sogou|lssbot|careerbot|wotbox|wocbot|ichiro|DuckDuckBot|lssrocketcrawler|drupact|webcompanycrawler|acoonbot|openindexspider|gnam gnam spider|web-archive-net.com.bot|backlinkcrawler|coccoc|integromedb|content crawler spider|toplistbot|seokicks-robot|it2media-domain-crawler|ip-web-crawler.com|siteexplorer.info|elisabot|proximic|changedetection|blexbot|arabot|WeSEE:Search|niki-bot|CrystalSemanticsBot|rogerbot|360Spider|psbot|InterfaxScanBot|Lipperhey SEO Service|CC Metadata Scaper|g00g1e.net|GrapeshotCrawler|urlappendbot|brainobot|fr-crawler|binlar|SimpleCrawler|Livelapbot|Twitterbot|cXensebot|smtbot|bnf.fr_bot|A6-Indexer|ADmantX|Facebot|Twitterbot|OrangeBot|memorybot|AdvBot|MegaIndex|SemanticScholarBot|ltx71|nerdybot|xovibot|BUbiNG|Qwantify|archive.org_bot|Applebot|TweetmemeBot|crawler4j|findxbot|SemrushBot|yoozBot|lipperhey|y!j-asr|Domain Re-Animator Bot|AddThis)"; var re = new RegExp(botPattern, 'i'); var userAgent = navigator.userAgent; if ( re.test(userAgent) ) { isbotuser = 'yes'; } var $style = ''; var couponappurl = couponapp_domain + 'front/couponxappfront?fullpathName='+encodeURI(fullpathName); /* Count App */ var countcouponapp = readCouponappCookie('countcouponapp'); if (countcouponapp != 'dismiss'){ updatecount = 1; } var traffic_source = readCouponappCookie('traffic_source'); /* Get all cookies of browesr and filter coupon cookies*/ var cookies = document.cookie.split(';').reduce( (cookies, cookie) => { const [name, val] = cookie.split('=').map(c => c.trim()); cookies[name] = val; return cookies; }, {}); var unique_codes = {}; jQuery.each(cookies, function (key,val) { key = jQuery.trim(key); if (key.indexOf('couponx_unique-') == 0) { unique_codes[key] = val; } }); unique_code = unique_codes; /* Check is Owner*/ var couponappisowner = jQuery('#admin-bar-iframe').html(); if(couponappisowner !== undefined){ isowner = 'yes'; createCouponappCookie('couponappisowner', 'yes', 1000); } /* Check App Owner Cookie */ var couponappisownerCookie = readCouponappCookie('couponappisowner'); if (couponappisownerCookie == 'yes'){ isowner = 'yes'; } if(isbotuser == 'no'){ var previous_cart_items = ''; if ( localStorage.getItem( 'CX_shopify_cart_response' ) != '' ) { previous_cart_items = localStorage.getItem( 'CX_shopify_cart_response' ); } var CX_shopify_show_widget = ''; if ( localStorage.getItem( 'CX_shopify_show_widget' ) != '' ) { CX_shopify_show_widget = localStorage.getItem( 'CX_shopify_show_widget' ); } jQuery.get( 'https://'+shopify_coupon_domain+"/cart.json", function( cart_response ) { var coupon_ab_widgets = readCouponappCookie('couponx_ab_widget'); if ( cart_response.items != '') { var cart_items_ids = []; jQuery.each(cart_response.items, function(index, value) { cart_items_ids.push(value.product_id); localStorage.setItem( 'CX_shopify_cart_response', JSON.stringify(cart_items_ids)); }); } jQuery.ajax({ type: "POST", url: couponappurl, data: { 'shop_url' : shopurl, 'isCXMobile' : isCXMobile, 'pathName' : path_name, 'updatecount' : updatecount, 'isowner' : isowner, 'cart_data' : cart_response, 'customerId' : customerId, 'origin_landing_page' : origin_landing_page, 'HTTP_REFERER' : myReferer, 'traffic_source' : traffic_source, 'is_unique_code' : (unique_code) ? unique_code : array(), 'is_ab_widges' : ( coupon_ab_widgets != '' ) ? coupon_ab_widgets : '', 'previous_cart_items' : previous_cart_items, 'show_widget' : CX_shopify_show_widget, }, dataType: "JSON", success: function (response) { jQuery('.tab-box.tab-front-box ').remove(); if(response.trigger_cart == true ) { is_trigger_cart = true; } /* if ( response == '') { return true; } */ if( typeof response.couponapp_widgets != 'undefined' && response.couponapp_widgets.length > 0) { couponx_loadGoogleFonts(jQuery); couponapp_settings = response; var page_scroll_index; var local_widget_ids = []; for( currentCountryCount = 0 ; currentCountryCount < response.couponapp_widgets.length ; currentCountryCount++ ) { var widget_id = response.couponapp_widgets[currentCountryCount].widget_id; if ( response.couponapp_widgets[currentCountryCount].cart_targeting == true ) { local_widget_ids.push(widget_id); localStorage.setItem( 'CX_shopify_show_widget', JSON.stringify(local_widget_ids)); if ( response.couponapp_widgets[currentCountryCount].dont_show == true ) { continue; } } var discount_code = response.couponapp_widgets[currentCountryCount].unique_code; if ( discount_code != '') { createCouponappCookie('couponx_unique-'+widget_id, discount_code, 365); } if ( couponapp_settings.couponapp_widgets[currentCountryCount].is_traffic_source !='' && traffic_source == null ) { createCouponappCookie('traffic_source', couponapp_settings.couponapp_widgets[currentCountryCount].is_traffic_source, 1); } var couponapp_scroll = sessionStorage.getItem(currentCountryCount + 'couponapp_scroll'); var couponapp_show = sessionStorage.getItem(currentCountryCount + 'couponapp_show'); if ( couponapp_settings.couponapp_widgets[currentCountryCount].page_scroll === 'yes' && couponapp_scroll != 'yes' && couponapp_show != 'yes' ) { page_scroll_functions( jQuery,currentCountryCount ); } if ( couponapp_settings.couponapp_widgets[currentCountryCount].time_delay === 'yes' && couponapp_show != 'yes' && show_widget == false) { var trigger_sec = couponapp_settings.couponapp_widgets[currentCountryCount].time_delay_sec * 1000; if ( trigger_sec == 0 ) { trigger_sec = 100; } page_scroll_index = currentCountryCount; check_for_widget_data(jQuery,page_scroll_index); var show_widget_after_some_time = function(page_scroll_index, jQuery){ var tab_id = 'tab-box-front-' + page_scroll_index; var widget_tab = 'tab-box-front-' + widget_id; var widget_tab_class = 'tab-box-front-wid-' + widget_id; if(!isCXMobile && jQuery("#"+tab_id).hasClass("couponapp-desktop")){ jQuery( '#' + tab_id ).show(); }else if(isCXMobile && jQuery("#"+tab_id).hasClass("couponapp-mobile")){ jQuery( '#' + tab_id ).show(); }else{ jQuery( '#' + tab_id ).hide(); } sessionStorage.setItem( page_scroll_index + 'couponapp_show', 'yes'); /* Hide Tab after conversation */ if ( localStorage.getItem(widget_tab + '-couponapp_tab_hide') == 'yes' && jQuery( '#' + tab_id ).hasClass( 'couponapp-tab-hide' ) ) { jQuery( '.' + widget_tab_class ).hide(); } }; setTimeout(show_widget_after_some_time, trigger_sec, page_scroll_index, jQuery); } else { check_for_widget_data(jQuery,currentCountryCount); var tab_id = 'tab-box-front-' + currentCountryCount; var widget_tab = 'tab-box-front-' + widget_id; var widget_tab_class = 'tab-box-front-wid-' + widget_id; /* Date: 03/01/2023 This script condition hide for the reason of conflit with trigger targeting event */ // if(!isCXMobile && jQuery("#"+tab_id).hasClass("couponapp-desktop")){ // jQuery( '#' + tab_id ).show(); // }else if(isCXMobile && jQuery("#"+tab_id).hasClass("couponapp-mobile")){ // jQuery( '#' + tab_id ).show(); // } if ( show_widget == true || couponapp_show == 'yes') { createCouponappCookie('couponx-exist-'+ widget_id, 'yes' , 1); if(!isCXMobile && jQuery("#"+tab_id).hasClass("couponapp-desktop")){ jQuery( '#' + tab_id ).show(); }else if(isCXMobile && jQuery("#"+tab_id).hasClass("couponapp-mobile")){ jQuery( '#' + tab_id ).show(); } } /* Hide Tab after conversation */ if ( localStorage.getItem(widget_tab + '-couponapp_tab_hide') == 'yes' && jQuery( '#' + tab_id ).hasClass( 'couponapp-tab-hide' ) ) { jQuery( '.' + widget_tab_class ).hide(); } } } } } }); }); /* End Cart json */ } }; var couponx_loadGoogleFonts = function(jQuery) { var fontFamilyObject={"'Aclonica'":"Aclonica","'Alef'":"Alef","'Allan'":"Allan","'Allerta Stencil'":"Allerta Stencil","'Allerta'":"Allerta","'Amaranth'":"Amaranth","'Amatica SC'":"Amatica SC","'Annie Use Your Telescope'":"Annie Use Your Telescope","'Anonymous Pro'":"Anonymous Pro","'Anton'":"Anton","'Architects Daughter'":"Architects Daughter","'Arimo'":"Arimo","'Artifika'":"Artifika","'Arvo'":"Arvo","'Asap'":"Asap","'Asset'":"Asset","'Assistant'":"Assistant","'Astloch'":"Astloch","'Bangers'":"Bangers","'Bentham'":"Bentham","'Bevan'":"Bevan","'Bigshot One'":"Bigshot One","'Bowlby One SC'":"Bowlby One SC","'Bowlby One'":"Bowlby One","'Brawler'":"Brawler","'Cabin'":"Cabin","'Calligraffitti'":"Calligraffitti","'Candal'":"Candal","'Cantarell'":"Cantarell","'Cardo'":"Cardo","'Carter One'":"Carter One","'Caudex'":"Caudex","'Cedarville Cursive'":"Cedarville Cursive","'Cherry Cream Soda'":"Cherry Cream Soda","'Chewy'":"Chewy","'Coda'":"Coda","'Coming Soon'":"Coming Soon","'Copse'":"Copse","'Corben'":"Corben","'Cousine'":"Cousine","'Covered By Your Grace'":"Covered By Your Grace","'Crafty Girls'":"Crafty Girls","'Crimson Text'":"Crimson Text","'Crushed'":"Crushed","'Cuprum'":"Cuprum","'Damion'":"Damion","'Dancing Script'":"Dancing Script","'David Libre'":"David Libre","'Dawning of a New Day'":"Dawning of a New Day","'Didact Gothic'":"Didact Gothic","'DM Sans'":"DM Sans","'Dosis'":"Dosis","'Droid Sans'":"Droid Sans","'Droid Sans Mono'":"Droid Sans Mono","'Droid Serif'":"Droid Serif","'DM Serif Display'":"DM Serif Display","'EB Garamond'":"EB Garamond","'Exo'":"Exo","'Expletus Sans'":"Expletus Sans","'Fontdiner Swanky'":"Fontdiner Swanky","'Forum'":"Forum","'Francois One'":"Francois One","'Frank Ruhl Libre'":"Frank Ruhl Libre","'Geo'":"Geo","'Give You Glory'":"Give You Glory","'Goblin One'":"Goblin One","'Goudy Bookletter 1911'":"Goudy Bookletter 1911","'Gravitas One'":"Gravitas One","'Gruppo'":"Gruppo","'Hammersmith One'":"Hammersmith One","'Heebo'":"Heebo","'Holtwood One SC'":"Holtwood One SC","'Homemade Apple'":"Homemade Apple","'Inconsolata'":"Inconsolata","'Indie Flower'":"Indie Flower","'IM Fell DW Pica'":"IM Fell DW Pica","'IM Fell DW Pica SC'":"IM Fell DW Pica SC","'IM Fell Double Pica'":"IM Fell Double Pica","'IM Fell Double Pica SC'":"IM Fell Double Pica SC","'IM Fell English'":"IM Fell English","'IM Fell English SC'":"IM Fell English SC","'IM Fell French Canon'":"IM Fell French Canon","'IM Fell French Canon SC'":"IM Fell French Canon SC","'IM Fell Great Primer'":"IM Fell Great Primer","'IM Fell Great Primer SC'":"IM Fell Great Primer SC","'Irish Grover'":"Irish Grover","'Irish Growler'":"Irish Growler","'Istok Web'":"Istok Web","'Josefin Sans'":"Josefin Sans","'Josefin Slab'":"Josefin Slab","'Judson'":"Judson","'Jura'":"Jura","'Just Another Hand'":"Just Another Hand","'Just Me Again Down Here'":"Just Me Again Down Here","'Kameron'":"Kameron","'Kenia'":"Kenia","'Kranky'":"Kranky","'Kreon'":"Kreon","'Kristi'":"Kristi","'La Belle Aurore'":"La Belle Aurore","'Lato'":"Lato","'League Script'":"League Script","'Lekton'":"Lekton","'Libre Baskerville'":"Libre Baskerville","'Limelight'":"Limelight","'Lobster'":"Lobster","'Lobster Two'":"Lobster Two","'Lora'":"Lora","'Love Ya Like A Sister'":"Love Ya Like A Sister","'Loved by the King'":"Loved by the King","'Luckiest Guy'":"Luckiest Guy","'Maiden Orange'":"Maiden Orange","'Mako'":"Mako","'Maven Pro'":"Maven Pro","'Meddon'":"Meddon","'MedievalSharp'":"MedievalSharp","'Megrim'":"Megrim","'Merriweather'":"Merriweather","'Metrophobic'":"Metrophobic","'Michroma'":"Michroma","'Miltonian Tattoo'":"Miltonian Tattoo","'Miltonian'":"Miltonian","'Miriam Libre'":"Miriam Libre","'Modern Antiqua'":"Modern Antiqua","'Molengo'":"Molengo","'Monofett'":"Monofett","'Montserrat'":"Montserrat","'Mountains of Christmas'":"Mountains of Christmas","'Muli'":"Muli","'Neucha'":"Neucha","'Neuton'":"Neuton","'News Cycle'":"News Cycle","'Nixie One'":"Nixie One","'Nobile'":"Nobile","'Nova Cut'":"Nova Cut","'Nova Flat'":"Nova Flat","'Nova Mono'":"Nova Mono","'Nova Oval'":"Nova Oval","'Nova Round'":"Nova Round","'Nova Script'":"Nova Script","'Nova Slim'":"Nova Slim","'Nova Square'":"Nova Square","'Nunito:light'":"Nunito:light","'Nunito'":"Nunito","'Nunito Sans'":"Nunito Sans","'OFL Sorts Mill Goudy TT'":"OFL Sorts Mill Goudy TT","'Old Standard TT'":"Old Standard TT","'Open Sans'":"Open Sans","'Open Sans Condensed:300'":"Open Sans Condensed","'Open Sans Hebrew'":"Open Sans Hebrew","'Orbitron'":"Orbitron","'Oswald'":"Oswald","'Over the Rainbow'":"Over the Rainbow","'Pacifico'":"Pacifico","'Patrick Hand'":"Patrick Hand","'Paytone One'":"Paytone One","'Permanent Marker'":"Permanent Marker","'Philosopher'":"Philosopher","'Play'":"Play","'Playfair Display'":"Playfair Display","'Podkova'":"Podkova","'Poppins'":"Poppins","'PT Sans'":"PT Sans","'PT Sans Narrow'":"PT Sans Narrow","'PT Sans Narrow:regular,bold'":"PT Sans Narrow:regular,bold","'PT Serif'":"PT Serif","'PT Serif Caption'":"PT Serif Caption","'Puritan'":"Puritan","'Quattrocento'":"Quattrocento","'Quattrocento Sans'":"Quattrocento Sans","'Quicksand'":"Quicksand","'Radley'":"Radley","'Raleway'":"Raleway","'Redressed'":"Redressed","'Reenie Beanie'":"Reenie Beanie","'Rock Salt'":"Rock Salt","'Rokkitt'":"Rokkitt","'Roboto'":"Roboto","'Rubik'":"Rubik","'Ruslan Display'":"Ruslan Display","'Schoolbell'":"Schoolbell","'Secular One'":"Secular One","'Shadows Into Light'":"Shadows Into Light","'Shanti'":"Shanti","'Sigmar One'":"Sigmar One","'Six Caps'":"Six Caps","'Slackey'":"Slackey","'Smythe'":"Smythe","'Source Sans Pro'":"Source Sans Pro","'Special Elite'":"Special Elite","'Stardos Stencil'":"Stardos Stencil","'Sue Ellen Francisco'":"Sue Ellen Francisco","'Suez One'":"Suez One","'Sunshiney'":"Sunshiney","'Swanky and Moo Moo'":"Swanky and Moo Moo","'Syncopate'":"Syncopate","'Tangerine'":"Tangerine","'Tenor Sans'":"Tenor Sans","'Terminal Dosis Light'":"Terminal Dosis Light","'The Girl Next Door'":"The Girl Next Door","'Tinos'":"Tinos","'Ubuntu'":"Ubuntu","'Ultra'":"Ultra","'Unkempt'":"Unkempt","'UnifrakturCook:bold'":"UnifrakturCook:bold","'UnifrakturMaguntia'":"UnifrakturMaguntia","'Varela'":"Varela","'Varela Round'":"Varela Round","'Vibur'":"Vibur","'Vollkorn'":"Vollkorn","'VT323'":"VT323","'Waiting for the Sunrise'":"Waiting for the Sunrise","'Wallpoet'":"Wallpoet","'Walter Turncoat'":"Walter Turncoat","'Wire One'":"Wire One","'Yanone Kaffeesatz'":"Yanone Kaffeesatz","'Yeseva One'":"Yeseva One","'Zeyada'":"Zeyad","'Zilla Slab'":"Zilla Slab"}; var fontFamilyArray = Object.keys(fontFamilyObject); var all_fonts = ''; for (let index = 0; index < fontFamilyArray.length; index++) { this_font = fontFamilyArray[index].replace(/['"]+/g, '').replace(/ /g, '+'); if(this_font != 'Open+Sans+Hebrew'){ if(index != 0) {all_fonts += '|'}; all_fonts += this_font; } } jQuery('head').append(''); } var check_for_widget_data = function (jQuery, index) { activeIndexID = index; if( couponapp_settings.couponapp_widgets[index].maxvisitor && jQuery('link#custom-google-fonts-css').length == 0){ jQuery('head').append(''); jQuery('body').append(couponapp_settings.couponapp_widgets[index].maxvisitormessage); couponapp_storeid = couponapp_settings.couponapp_widgets[index].storeid; } if( index < couponapp_settings.couponapp_widgets.length ) { couponapp = {google_analytics:couponapp_settings.couponapp_widgets[index].google_analytics}; if ( typeof couponapp_settings.couponapp_widgets[index].countries !== 'undefined' && couponapp_settings.couponapp_widgets[index].countries.length > 0) { if(country_name == "") { var $ipurl = 'https://www.cloudflare.com/cdn-cgi/trace'; jQuery.get($ipurl, function (cloudflaredata) { var currentCountry = cloudflaredata.match("loc=(.*)"); if (currentCountry.length > 1) { currentCountry = currentCountry[1]; if (currentCountry) { currentCountry = currentCountry.toUpperCase(); country_name = currentCountry; if (jQuery.inArray(currentCountry, couponapp_settings.couponapp_widgets[index].countries) != -1) { set_widget_data(jQuery,index); } } } }); } else { if (jQuery.inArray(country_name, couponapp_settings.couponapp_widgets[index].countries) != -1) { set_widget_data(jQuery,index); } } } else { set_widget_data(jQuery,index); } } } var set_widget_data = function (jQuery,activeIndexID) { /* Check CTA Hide after First Click/Hover */ var tab_id = 'tab-box-front-' + activeIndexID; var widget_id = couponapp_settings.couponapp_widgets[activeIndexID].widget_id; var widget_tab = 'tab-box-front-wid-'+widget_id; /* Remove Session Storage if always open class*/ if ( couponapp_settings.couponapp_widgets[activeIndexID].show_cta === 'always' ) { sessionStorage.removeItem(tab_id + 'couponapp_close'); } if (couponapp_settings.couponapp_widgets[activeIndexID].html != '' && check_for_time(activeIndexID)){ if ( couponapp_settings.couponapp_widgets[activeIndexID].widget_save == 1 ) { localStorage.removeItem(tab_id + 'couponapp_close_widget'); sessionStorage.removeItem(tab_id + 'couponapp_close'); sessionStorage.removeItem(tab_id + 'couponapp_pending_message'); sessionStorage.removeItem(tab_id + 'couponapp_open'); } var coupon_widget = couponapp_settings.couponapp_widgets[activeIndexID].html; var exit_intent = couponapp_settings.couponapp_widgets[activeIndexID].exit_intent; var time_delay = couponapp_settings.couponapp_widgets[activeIndexID].time_delay; var page_scroll = couponapp_settings.couponapp_widgets[activeIndexID].page_scroll; /* *** AB Testing *** */ if( couponapp_settings.couponapp_widgets[activeIndexID].is_ab == 1 ){ var ab_widget_frm_cookie = readCouponappCookie('couponx_ab_widget'); if( ab_widget_frm_cookie != '' && couponapp_settings.couponapp_widgets[activeIndexID].widget_id != ab_widget_frm_cookie ){ ab_widges_arr.push( couponapp_settings.couponapp_widgets[activeIndexID].widget_id ); createCouponappCookie( 'couponx_ab_widget', ab_widges_arr, 30 ); get_ab_widget_count( jQuery , activeIndexID); } } /* *** End AB Testing *** */ if ( localStorage.getItem(tab_id + 'couponapp_close_widget') == 'yes' ) { coupon_widget = coupon_widget.replace("couonapp-active", ""); } /* Append Widget */ jQuery('body').append(coupon_widget); /* Add Style property */ setCustomStyle(jQuery, activeIndexID, tab_id); /* end style property */ var widget_id = jQuery('#' + tab_id).data("widgetid"); var widget_tab = 'tab-box-front-' + widget_id; var widget_tab_class = 'tab-box-front-wid-' + widget_id; var exist_popup = readCouponappCookie('couponx-exist-'+ widget_id); var couponapp_show = sessionStorage.getItem(activeIndexID + 'couponapp_show'); //if ( ( exit_intent == 'yes' && exist_popup == null) || ( ( page_scroll == '' && time_delay == '' ) || couponapp_show != 'yes' )) { if ( exist_popup == null && ( exit_intent == 'yes' || page_scroll == '' && time_delay == '' || couponapp_show != 'yes' ) ) { jQuery( '#' + tab_id ).hide(); } /* Hide Tab after conversation */ if ( localStorage.getItem(widget_tab + '-couponapp_tab_hide') == 'yes' && jQuery( '#' + tab_id ).hasClass( 'couponapp-tab-hide' ) ) { jQuery( '.' + widget_tab_class ).hide(); } jQuery( '.tab-box.tab-front-box').each(function () { var main_width = jQuery(this).find( '.tab-box-email-content .form-wrap').outerWidth(); var button_width = jQuery(this).find( '.coupon-button.coupon-email-button').outerWidth(); if ( ( typeof main_width !== 'undefined' && main_width != 0 ) && ( typeof button_width !== 'undefined' && button_width != 0) ) { //jQuery(this).find('.coupon-code-email-text').width( main_width - button_width - 37 ); jQuery(this).find('.coupon-code-email-text').width( '100%' ); } }) if ( readCouponappCookie(tab_id + 'show_coupon_code') == 'yes') { jQuery( '#' + tab_id + ' .tab-box-content.tab-box-email-content').remove(); jQuery( '#' + tab_id + ' .tab-box-content.tab-box-couponcode-content').show(); jQuery( '#' + tab_id ).addClass( 'open-coupon-code'); } var coupon_pending_message = sessionStorage.getItem(tab_id + 'couponapp_pending_message'); if ( coupon_pending_message === 'yes' || jQuery('#' + tab_id ).hasClass( 'couponapp-open-state-open' ) ) { jQuery('#' + tab_id + ' .coupon-pending-message').remove(); } if ( jQuery('#' + tab_id ).hasClass( 'couponapp-open-state-open' ) ) { jQuery('#' + tab_id + ' .tab-text').hide(); } if (jQuery('#' + tab_id ).hasClass( 'couponapp-open-state-open' ) && localStorage.getItem(tab_id + 'couponapp_close_widget') == 'yes' && jQuery( '#' + tab_id ).hasClass( "couponapp-open-always" ) ) { jQuery('#' + tab_id + ' .tab-text').show(); } var couponapp_open = sessionStorage.getItem(tab_id + 'couponapp_open'); if ( couponapp_open === 'yes' || jQuery('#' + tab_id ).hasClass( 'couponapp-open-state-open' ) ) { jQuery('#' + tab_id).removeClass (function (index, className) { if ( jQuery('#tab-box-front-' + index).data('animation-effect') == 'hide_attention_effect' ){ return (className.match (/(^|\s)couponapp-\S+-animation/g) || []).join(' '); } else { return; } }); } var isCXMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ? true : false; if ( isCXMobile === true ) { jQuery( '#' + tab_id ).removeClass( "couponapp-open-state-hover" ); var widget_id = jQuery('#' + tab_id + ' .tab-icon').data('widget-id'); var shop_id = jQuery('#' + tab_id + ' .tab-icon').data('shop-id'); var coupon_open = widget_id +'-'+shop_id; var is_updatecouponopen = localStorage.getItem( 'is_updatecouponopen' + coupon_open); if ( is_updatecouponopen == 'yes' ) { jQuery( '#' + tab_id ).removeClass( "couponapp-open-state-open" ); } jQuery( '#' + tab_id ).addClass( "couponapp-open-state-click" ); } var IsUpdatevisitor = localStorage.getItem( 'is_updatevisitor'); /* Update Visitor */ if( updatecount == 1 && isowner == 'no' && is_updatevisitor == 0 && IsUpdatevisitor != 'yes' ){ updatecouponvisitor(jQuery,activeIndexID); is_updatevisitor = 1; localStorage.setItem( 'is_updatevisitor', 'yes'); } /* Update Open Widget */ var widget_id = jQuery('#' + tab_id + ' .tab-icon').data('widget-id'); var shop_id = jQuery('#' + tab_id + ' .tab-icon').data('shop-id'); var coupon_open = widget_id +'-'+shop_id; var is_updatecouponopen = localStorage.getItem( 'is_updatecouponopen' + coupon_open); if ( jQuery( '#' + tab_id ).hasClass( "couonapp-active" ) && is_updatecouponopen != 'yes' ) { updatecouponopen( jQuery,widget_id, shop_id); localStorage.setItem( 'is_updatecouponopen' + coupon_open, 'yes'); } if ( jQuery( '#' + tab_id ).hasClass( "couonapp-active" ) ){ setCountDownTimer(jQuery); } var session_tab = sessionStorage.getItem(tab_id + 'couponapp_close'); if ( session_tab === 'close' ) { jQuery('#' + tab_id + ' .tab-text').hide(); } /* Large Copy Button */ if ( jQuery('#' + tab_id + ' .tab-box-couponcode-content .couponx-large-btn').length > 0) { jQuery('#' + tab_id + ' .tab-box-couponcode-content .couponx-large-btn .button.coupon-button').addClass( 'coupon-large-button' ); let coupon_button = jQuery('#' + tab_id + ' .tab-box-couponcode-content .couponx-large-btn .button.coupon-button'); jQuery('#' + tab_id + ' .tab-box-couponcode-content .couponx-large-btn').after(coupon_button); } /* Large Email Button */ if ( jQuery('#' + tab_id + ' .tab-box-email-content .couponx-large-email-btn').length > 0) { jQuery('#' + tab_id + ' .tab-box-email-content .couponx-large-email-btn button.coupon-button.coupon-email-button').addClass( 'coupon-large-button' ); let coupon_button = jQuery('#' + tab_id + ' .tab-box-email-content .couponx-large-email-btn button.coupon-button.coupon-email-button'); jQuery('#' + tab_id + ' .tab-box-email-content .couponx-large-email-btn').after(coupon_button); jQuery('#' + tab_id + ' .tab-box-email-content .couponx-large-email-btn .coupon-code-email-text.coupon-code-email-field').css('width', '100%'); } if (couponapp_settings.couponapp_widgets[activeIndexID].font_family){ let font_family = couponapp_settings.couponapp_widgets[activeIndexID].font_family; font_family = font_family.replace(/\s+/g, '-').toLowerCase(); if (jQuery('link#custom-google-fonts-'+ font_family +'-css').length == 0) { jQuery('head').append(''); } } } } var setCustomStyle = function ( jQuery, activeIndexID, tab_id ) { var tab_size = couponapp_settings.couponapp_widgets[activeIndexID].tab_size; var tab_height = couponapp_settings.couponapp_widgets[activeIndexID].tab_height; var icon_size = couponapp_settings.couponapp_widgets[activeIndexID].icon_size; var bottom_spacing = couponapp_settings.couponapp_widgets[activeIndexID].bottom_spacing; var side_spacing = couponapp_settings.couponapp_widgets[activeIndexID].side_spacing; var call_to_action = couponapp_settings.couponapp_widgets[activeIndexID].call_to_action; var cta_text_color = couponapp_settings.couponapp_widgets[activeIndexID].cta_text_color; var cta_action_bg_color = couponapp_settings.couponapp_widgets[activeIndexID].cta_action_bg_color; var font_family = couponapp_settings.couponapp_widgets[activeIndexID].font_family; var tab_color = couponapp_settings.couponapp_widgets[activeIndexID].tab_color; var icon_color = couponapp_settings.couponapp_widgets[activeIndexID].icon_color; var background_color = couponapp_settings.couponapp_widgets[activeIndexID].background_color; var headline_text_color = couponapp_settings.couponapp_widgets[activeIndexID].headline_text_color; var coupon_text_color = couponapp_settings.couponapp_widgets[activeIndexID].coupon_text_color; var coupon_color = couponapp_settings.couponapp_widgets[activeIndexID].coupon_color; var coupon_textsize = couponapp_settings.couponapp_widgets[activeIndexID].coupon_textsize; var coupon_textfontfamily = couponapp_settings.couponapp_widgets[activeIndexID].coupon_textfontfamily; var email_text_color = couponapp_settings.couponapp_widgets[activeIndexID].email_text_color; var email_color = couponapp_settings.couponapp_widgets[activeIndexID].email_color; var button_text_color = couponapp_settings.couponapp_widgets[activeIndexID].button_text_color; var button_color = couponapp_settings.couponapp_widgets[activeIndexID].button_color; var email_button_text_color = couponapp_settings.couponapp_widgets[activeIndexID].email_button_text_color; var email_button_color = couponapp_settings.couponapp_widgets[activeIndexID].email_button_color; var description_text_color = couponapp_settings.couponapp_widgets[activeIndexID].description_text_color; var email_background_color = couponapp_settings.couponapp_widgets[activeIndexID].email_background_color; var email_headline_text_color = couponapp_settings.couponapp_widgets[activeIndexID].email_headline_text_color; var couponInputSize = couponapp_settings.couponapp_widgets[activeIndexID].couponInputSize; var couponInputFontFamily = couponapp_settings.couponapp_widgets[activeIndexID].couponInputFontFamily; var email_description_text_color = couponapp_settings.couponapp_widgets[activeIndexID].email_description_text_color; var consent_text_color = couponapp_settings.couponapp_widgets[activeIndexID].consent_text_color; var coupon_field_border_color = couponapp_settings.couponapp_widgets[activeIndexID].coupon_field_border_color; var email_field_border_color = couponapp_settings.couponapp_widgets[activeIndexID].email_field_border_color; var email_field_border_color = couponapp_settings.couponapp_widgets[activeIndexID].email_field_border_color; var custom_css = couponapp_settings.couponapp_widgets[activeIndexID].custom_css; let custom_style = ''; custom_style += '#' + tab_id +'.tab-box.couponapp-tab-shape-hexagon .tab-icon,#' +tab_id +'.tab-box .tab-icon{width: '+tab_size+'px;height: '+tab_height+'px;cursor: pointer;}'; custom_style += '#'+ tab_id +'.tab-box .tab-icon svg{width: ' + icon_size + 'px; height: ' + icon_size + 'px;top: calc(50% - ' + icon_size/2 + 'px); left:calc(50% - ' + icon_size/2 + 'px);}'; custom_style += '#' + tab_id +',#' + tab_id +' h4,#' + tab_id +' .coupon-button{ font-family: ' + font_family + '}'; custom_style += '#' + tab_id +'.couponapp-position-custom.couponapp-position-left {bottom: ' + bottom_spacing + 'px; left: ' + side_spacing + 'px;}'; custom_style += '#' + tab_id +'.couponapp-position-custom.couponapp-position-right {bottom: ' + bottom_spacing + 'px;right: ' +side_spacing + 'px;}'; custom_style += '#' + tab_id +' .tab-text{ color: ' + cta_text_color + '; background-color: ' + cta_action_bg_color + ';}'; custom_style += '#' + tab_id +'.couponapp-position-right .tab-text:after{ border-left-color: ' + cta_action_bg_color + ';border-right-color:transparent; ' + ( ( call_to_action == '') ? 'display:none;' : '' ) + '}'; custom_style += '#' + tab_id +'.couponapp-position-left .tab-text:after{ border-right-color: ' + cta_action_bg_color + ';border-left-color:transparent; ' + ( ( call_to_action == '') ? 'display:none;' : '' ) + '}'; custom_style += '#' + tab_id +' .tab-icon, #' + tab_id +' .tab-icon .hexagon-after, #' + tab_id +' .tab-icon .hexagon-before{ background-color: ' + tab_color + ';}'; custom_style += '#' + tab_id +' .tab-icon svg{fill: ' + icon_color +' !important;}'; custom_style += '#' + tab_id +' .tab-box-content.tab-box-couponcode-content { background-color:' + background_color + ';}'; custom_style += '#' + tab_id +' .tab-box-content.tab-box-couponcode-content h4{ color:' + headline_text_color + ';}'; custom_style += '#' + tab_id +' .tab-box-content .coupon-code-text{ color: ' + coupon_text_color +'; background-color: ' + coupon_color + '; font-size: ' + coupon_textsize + '; font-family:' + coupon_textfontfamily +'; min-width:100px }'; custom_style += '#' + tab_id +' .tab-box-content.tab-box-couponcode-content .coupon-code-email-field input{ color: ' + email_text_color + '; background-color: ' + email_color +';}'; custom_style += '#' + tab_id +' .tab-box-content.tab-box-couponcode-content .coupon-button{ color: ' + button_text_color+ ';background-color: ' + button_color + ';}'; custom_style += '#' + tab_id +' .tab-box-content.tab-box-couponcode-content .coupon-button.coupon-email-button { color: ' + email_button_text_color + '; background-color: ' + email_button_color + ';}'; custom_style += '#' + tab_id +' .tab-box-content.tab-box-couponcode-content .coupon-description{color: ' + description_text_color + ';}'; custom_style += '#' + tab_id +' .tab-box-content.tab-box-email-content { background-color: ' + email_background_color + ';}'; custom_style += '#' + tab_id +' .tab-box-content.tab-box-email-content h4{ color: ' + email_headline_text_color +';}'; custom_style += '#' + tab_id +' .tab-box-content.tab-box-email-content .coupon-code-email-field input{ color: ' + email_text_color +'; background-color: ' + email_color + '; font-size: ' + couponInputSize + '; font-family: ' + couponInputFontFamily + ';}'; custom_style += '#' + tab_id +' .tab-box-content.tab-box-email-content .coupon-code-email-field input:-ms-input-placeholder, #' + tab_id +' .tab-box-content.tab-box-email-content .coupon-code-email-field input::-ms-input-placeholder, #' + tab_id +' .tab-box-content.tab-box-email-content .coupon-code-email-field input::placeholder{ color: ' + email_text_color + ';}'; custom_style += '#' + tab_id +' .tab-box-content.tab-box-email-content .coupon-button{ color: ' + email_color + '; background-color: ' + email_text_color + ';}'; custom_style += '#' + tab_id +' .tab-box-couponcode-content a.button.btn.btn-blue.show-button{ color: ' + button_text_color + '; background-color: ' + button_color + ';}'; custom_style += '#' + tab_id +' .tab-box-content.tab-box-email-content .coupon-button.coupon-email-button { color: ' + email_button_text_color + '; background-color: ' + email_button_color + ';}'; custom_style += '#' + tab_id +' .tab-box-content.tab-box-email-content .coupon-description{ color: ' + email_description_text_color + ';}'; custom_style += '#' + tab_id +' .tab-box-content.tab-box-email-content .email-content-checkbox{ color: ' + consent_text_color + ';}'; custom_style += '#' + tab_id +'.tab-box-content.couponapp-email-code-option .form-wrap, #' + tab_id +'.tab-box.couponapp-style-1 .tab-box-couponcode-content .form-wrap, #' + tab_id +'.tab-box.couponapp-style-2 .tab-box-couponcode-content .form-wrap{ border-color: ' + coupon_field_border_color + '}'; custom_style += '#' + tab_id +' .tab-box-email-content .form-wrap{ border-color:' + email_field_border_color + '}'; custom_style += '@media screen and (min-width: 769px) { #' + tab_id +'.tab-box.tab-front-box.couponapp-desktop{ display: block;} } @media screen and (max-width: 768px) { #' + tab_id +'.tab-box.tab-front-box.couponapp-mobile{ display:block}}'; custom_style += custom_css; jQuery('#' + tab_id ).append( ''); } var setCountDownTimer = function ( jQuery ) { jQuery('.count-down-timer-box').each(function(){ var timezone = ''; var divId = jQuery(this); var timer_coundown_form = jQuery(this).data("countdown"); var timer_template = jQuery(this).data("timer-template"); var widget_id = jQuery(this).data("widgetid"); var shop_plan = jQuery(this).data("plan-type"); var disable_coupon_code = jQuery(this).data("disable-coupon-code"); if( shop_plan == 'Free' ){ return; } divId.attr('id','coundown_box_'+widget_id); if(timer_coundown_form != 'popup'){ timezone = jQuery(this).data("zone"); var year = jQuery(this).data("id").substring(0,4); var month = jQuery(this).data("id").substring(5,7) - 1; var day = jQuery(this).data("id").substring(8,10); var hour = jQuery(this).data("id").substring(11,13); var min = jQuery(this).data("id").substring(14,16); var second = jQuery(this).data("id").substring(18,20); var expiredDateTime = new Date(year,month,day,hour,min,second); } else{ var expiredDateTime = new Date(); var counter_hours = jQuery(this).data("houre"); var counter_minute = jQuery(this).data("min"); var counter_second = jQuery(this).data("second"); var expire_time = readCouponappCookie('couponx-countdowntime-'+ widget_id); if( expire_time != null ) { expiredDateTime = new Date(expire_time); } else { createCouponappCookie('couponx-countdowntime-'+ widget_id, expiredDateTime, 1); } var current_hourse = expiredDateTime.getHours(); var current_minute = expiredDateTime.getMinutes(); var current_second = expiredDateTime.getSeconds(); current_hourse = current_hourse + parseInt(counter_hours); current_minute = current_minute + parseInt(counter_minute); current_second = current_second + parseInt(counter_second) + 2; expiredDateTime.setHours(current_hourse); expiredDateTime.setMinutes(current_minute); expiredDateTime.setSeconds(current_second); } if( timer_template == 'timer_left_template' ){ var timerBoxId = divId.attr('id'); var renderTimerBox = "#"+timerBoxId; var id = "coundown_left_"+widget_id; var bgColor = jQuery(this).data("coundown-bgcolor"); var txtColor = jQuery(this).data("coundown-txtcolor"); var data = []; data["expired_date_time"] = expiredDateTime; data["timezone"] = timezone; data["bgcolor"] = jQuery(this).data("coundown-bgcolor"); data["txtcolor"] = jQuery(this).data("coundown-txtcolor"); data["labelcolor"] = jQuery(this).data("label-color"); data["timer_form"] = timer_coundown_form; data["disable_coupon_code"] = disable_coupon_code; data["renderTimerBox"] = renderTimerBox; countdown(id,data,jQuery); var htmlLefttimer = '
'+ response.errors +'
'); setTimeout(function () { jQuery('#' + coupon_widget_id + ' .tab-box-email-content p.coupon-email-error').slideUp("slow"); }, 5000); } if ( response.show_coupon === true ) { jQuery( '#' + coupon_widget_id + ' .tab-box-email-content').fadeOut(500); if(jQuery("#"+coupon_widget_id).hasClass("couponapp-style-5")){ jQuery( '#'+coupon_widget_id+' .tab-box-content.tab-box-couponcode-content.tab-announcement').delay(500).fadeIn(1000); }else{ var discount_code = response.discount_code; var coupon_code_text = jQuery( '#' + coupon_widget_id + ' .tab-box-couponcode-content .coupon-code-text').html().replace("uniquecode", discount_code); jQuery( '#' + coupon_widget_id + ' .tab-box-couponcode-content .coupon-code-text').html( coupon_code_text.replace("uniquecode", discount_code)); createCouponappCookie('couponx_unique-'+widget_id, discount_code, 365); jQuery( '#' + coupon_widget_id + ' .tab-box-couponcode-content').delay(500).fadeIn(1000); } jQuery( '#' + coupon_widget_id ).addClass('couponapp-email-coupon-code-show'); var show_widget_coupon_code = function(coupon_widget_id){ jQuery( '#' + coupon_widget_id + ' .tab-box-email-content').remove();//remove email screen setCountDownTimer(jQuery); }; setTimeout(show_widget_coupon_code, 600, coupon_widget_id); createCouponappCookie(coupon_widget_id + 'show_coupon_code' , 'yes', 30); } } }); return false; } else { if ( consent == 1 && jQuery('#' + consent_id).prop("checked") == false && jQuery('#' + consent_id).attr('required') == 'required') { return true; } if ( email == '' ) { return true; } if ( email_name == '' ) { return true; } } return false; }); jQuery(document).on( "click touch", ".couponapp-open-state-open .tab-icon" , function(e){ var id = jQuery(this).parent().parent().attr( 'id' ); if ( isCXMobile === true ) { jQuery( '#' + id ).removeClass( "couponapp-open-state-open" ); } if ( jQuery( '#' + id ).hasClass( "couonapp-active" ) ) { jQuery( '#' + id ).removeClass( "couonapp-active" ) sessionStorage.setItem( id + 'couponapp_pending_message', 'yes'); localStorage.setItem( id + 'couponapp_close_widget', 'yes'); jQuery('#' + id + ' .coupon-pending-message').remove(); if ( jQuery( '#' + id ).hasClass( "couponapp-open-always" ) ) { jQuery('#' + id + ' .tab-text').show(); } } else { jQuery( '#' + id ).addClass( "couonapp-active" ) } }); jQuery(document).on( "click touch", "#coupon_ownerpopup .coupon_ownerpopupclose" , function(e){ if (jQuery(this).hasClass('coupon_riskabovefourdays') && !jQuery(this).hasClass('coupon_eventsopen')) { jQuery(this).addClass('coupon_eventsopen'); jQuery("body .formappownerpopup .coupon_content, body .formappownerpopup .coupon_footer").hide(); jQuery("body .formappownerpopup .coupon_content.coupon_reskmoreevents").show(); } else if (jQuery(this).hasClass('coupon_eventsopen')) { coupon_ownerevent(jQuery,'dont_remind_me'); jQuery("body #coupon_ownerpopup").hide(); } else { jQuery("body #coupon_ownerpopup").hide(); coupon_ownerevent(jQuery,'click_on_x'); } }) jQuery(document).on( "click touch", ".coupon_ownerremind .coupon_remind" , function(e){ coupon_ownerevent(jQuery,'clicked_on_remind_me'); jQuery("body #coupon_ownerpopup").hide(); }), jQuery(document).on( "click touch", ".coupon_ownerremind .coupon_dontremind" , function(e){ coupon_ownerevent(jQuery,'dont_remind_me'); jQuery("body #coupon_ownerpopup").hide(); }), jQuery(document).on( "click touch", ".coupon_upgradenow" , function(e){ coupon_ownerevent(jQuery,'click_on_upgrade'); jQuery("body #coupon_ownerpopup").hide(); }) jQuery(document).mouseleave(function (e) { var top = e.clientY; var right = document.body.clientWidth - e.pageX; var bottom = jQuery(window).height() - e.clientY; var left = e.pageX; if(right > 0 && bottom > 0 && top <=0){ jQuery('.tab-front-box.couponapp-desktop').each(function(i, val) { var is_exit = jQuery(this).data('isexit'); var widget_id = jQuery(this).data("widgetid"); if(is_exit == 'yes'){ var exist_popup = readCouponappCookie('couponx-exist-'+ widget_id); if( exist_popup == null ) { var id = jQuery(this).attr( 'id' ); var shop_id = jQuery(this).data( 'shop_id' ); crearteCouponUniqueCode(jQuery, widget_id, shop_id, id); setCountDownTimer(jQuery); jQuery(this).show(); jQuery(this).addClass('couonapp-active'); jQuery(this).addClass('couponapp-open-state-click'); createCouponappCookie('couponx-exist-'+ widget_id, 'yes' , 1); if ( jQuery( this ).hasClass( "coupon-pending-message" )) { sessionStorage.setItem( id + 'couponapp_pending_message', 'yes'); jQuery('#' + id + ' .coupon-pending-message').remove(); } jQuery( '#' + id ).removeClass (function (index, className) { if ( jQuery('#tab-box-front-' + index).data('animation-effect') == 'hide_attention_effect' ){ return (className.match (/(^|\s)couponapp-\S+-animation/g) || []).join(' '); } else { return; } }); /* Save Close in Session Storage */ var session_tab = sessionStorage.getItem(id + 'couponapp_close'); if ( session_tab === 'close' ) { jQuery('#' + id + ' .tab-text').hide(); } if ( jQuery( '#' + id ).hasClass( "couponapp-open-first" ) ) { sessionStorage.setItem( id + 'couponapp_close', 'close'); jQuery('#' + id + ' .tab-text').hide(); } sessionStorage.setItem( id + 'couponapp_open', 'yes'); sessionStorage.setItem( i + 'couponapp_show', 'yes'); var main_width = jQuery(this).find( '.tab-box-email-content .form-wrap').outerWidth(); var button_width = jQuery(this).find( '.coupon-button.coupon-email-button').outerWidth(); if ( typeof main_width !== 'undefined' && typeof button_width !== 'undefined') { //jQuery(this).find('.coupon-code-email-text').width( main_width - button_width - 37 ); jQuery(this).find('.coupon-code-email-text').width( '100%' ); jQuery(this).find('.couponx-large-email-btn .coupon-code-email-text.coupon-code-email-field').width('100%' ); } } } }); } }); /* Show Coupon Code when the user click on Claim button*/ jQuery(document).on( "click touch", ".couponx-coupon-claim-form-wrap button.coupon-claim-button" , function(e){ jQuery(".couponx-coupon-form-wrap, .coupon-button.copy-to-clipboard.coupon-large-button").show(); jQuery(".couponx-coupon-claim-form-wrap").hide(); let widget_id = jQuery(this).parents( '.couponapp-coupon-claim.tab-front-box').data( 'widgetid' ); let shop_id = jQuery(this).parents( '.couponapp-coupon-claim.tab-front-box').data( 'shop_id' ); let id = jQuery(this).parents( '.couponapp-coupon-claim.tab-front-box').attr( 'id' ); if ( jQuery(this).parents( '.couponapp-coupon-claim.tab-front-box').hasClass( 'couponapp-coupon-claim' ) ) { jQuery(this).parents( '.couponapp-coupon-claim.tab-front-box').removeClass( 'couponapp-coupon-claim' ) } crearteCouponUniqueCode(jQuery, widget_id, shop_id, id); }) }); } /* Load jQuery Script */ if ((typeof jQuery === 'undefined') || (parseFloat(jQuery.fn.jquery) < 1.7)) { loadScript('//ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js', function(){ var COUPONAPPS = jQuery.noConflict(true); COUPONAPPS(document).ready(function() { CouponAppJavaScript(COUPONAPPS); CouponAppReadyJavaScript(COUPONAPPS); }); }); } else { CouponAppJavaScript(jQuery); CouponAppReadyJavaScript(jQuery); } function shopifylanguageRoute() { var shopify_lang_route = "/"; if ( typeof Shopify !== 'undefined' && Shopify.routes && Shopify.routes.root ) { shopify_lang_route = Shopify.routes.root; } return shopify_lang_route; } (function(ns, fetch) { if (typeof fetch !== 'function') return; ns.fetch = function() { const response = fetch.apply(this, arguments); response.then(res => { var shopify_lang_route = shopifylanguageRoute(); if ([ `${window.location.origin}`+ shopify_lang_route+ `cart/add.js`, `${window.location.origin}`+ shopify_lang_route+ `cart/add`, //`${window.location.origin}`+ shopify_lang_route+ `cart/update.js`, //`${window.location.origin}`+ shopify_lang_route+ `cart/update`, `${window.location.origin}`+ shopify_lang_route+ `cart/change.js`, `${window.location.origin}`+ shopify_lang_route+ `cart/change`, `${window.location.origin}`+ shopify_lang_route+ `cart/clear.js`, `${window.location.origin}`+ shopify_lang_route+ `cart/clear`, ].includes(res.url)) { if ( is_trigger_cart == true ) { if ( typeof jQuery !== 'undefined' ) { res.clone().json().then(data => CouponAppJavaScript(jQuery, true)); } else { res.clone().json().then(data => CouponAppJavaScript(COUPONAPPS, true)); } } } }); return response; } }(window, window.fetch)) })(); function close_couponx() { var loadScript_widget = function(url, callback){ var script = document.createElement("script"); script.type = "text/javascript"; // If the browser is Internet Explorer. if (script.readyState){ script.onreadystatechange = function(){ if (script.readyState == "loaded" || script.readyState == "complete"){ script.onreadystatechange = null; callback(); } }; // For any other browser. } else { script.onload = function(){ callback(); }; } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); }; loadScript_widget('//ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js', function(){ COUPONAPPS = jQuery.noConflict(true); COUPONAPPS('.tab-box.tab-front-box').removeClass('couonapp-active'); COUPONAPPS('.tab-box.tab-front-box').each(function(){ COUPONAPPS(this).removeClass('couonapp-active'); }); }); } var get_ab_widget_count = function ( jQuery,IndexID) { var widget_id = couponapp_settings.couponapp_widgets[IndexID].widget_id; var shop_id = couponapp_settings.couponapp_widgets[IndexID].shop_id; url = couponapp_domain + 'front/getabwidgetscount'; jQuery.ajax({ type: "POST", url: url, data: {'shop_url': shopurl,'widget_id':widget_id,"shop_id":shop_id}, success: function (response) { } }); } function launch_couponx( widget_no = 1 ) { launch_coupon_x( widget_no ); } function launch_coupon_x( widget_no = 1 ) { var count = 1; var loadScript_widget = function(url, callback){ var script = document.createElement("script"); script.type = "text/javascript"; // If the browser is Internet Explorer. if (script.readyState){ script.onreadystatechange = function(){ if (script.readyState == "loaded" || script.readyState == "complete"){ script.onreadystatechange = null; callback(); } }; // For any other browser. } else { script.onload = function(){ callback(); }; } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); }; loadScript_widget('//ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js', function(){ COUPONAPPS = jQuery.noConflict(true); COUPONAPPS('.tab-box.tab-front-box').removeClass('couonapp-active'); COUPONAPPS('.tab-box.tab-front-box').each(function(){ if ( widget_no == count) { COUPONAPPS(this).addClass('couonapp-active'); var widgetid = COUPONAPPS(this).attr( 'id' ); var widget_id = COUPONAPPS('#' + widgetid + ' .tab-box-wrap .tab-icon').data('widget-id'); var shop_id = COUPONAPPS('#' + widgetid + ' .tab-box-wrap .tab-icon').data('shop-id'); var coupon_code_option = COUPONAPPS('#' + widgetid + ' .tab-box-wrap .tab-icon').data('coupon-code-option'); var discoun_code = COUPONAPPS('#' + widgetid + ' .tab-box-wrap .tab-icon').data('discoun-code'); unique_code = ''; var nameEQ = escape('couponx_unique') + "="; 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) unique_code = unescape(c.substring(nameEQ.length, c.length)); } var couponapp_email = COUPONAPPS( '#' + widgetid + ' .coupon-code-email-text input[name="couponapp-email"]' ).length; if ( unique_code == '' && couponapp_email != '1' ) { var couponappurl = couponapp_domain + 'front/checkcouponcode?fullpathName='+encodeURI(fullpathName); COUPONAPPS( '#' + widgetid + ' .tab-box-couponcode-content .coupon-code-text').hide(); COUPONAPPS.ajax({ type: "POST", url: couponappurl, data: { 'widget_id' : widget_id, 'shop_id' : shop_id, 'shop_url': shopurl }, dataType: "JSON", success: function (response) { if ( response.show_coupon === true ) { var discount_code = response.discount_code; var coupon_code_text = COUPONAPPS( '#' + widgetid + ' .tab-box-couponcode-content').html().replace("uniquecode", discount_code); COUPONAPPS( '#' + widgetid + ' .tab-box-couponcode-content').html( coupon_code_text.replace("uniquecode", discount_code)); name = 'couponx_unique'; value = discount_code; days = 365; if (days) { var expiry = new Date(); expiry.setTime(expiry.getTime()+(days*24*60*60*1000)); var expires = "; expires=" + expiry.toGMTString(); } else { var expires = ""; } document.cookie = escape(name) + "=" + escape(value) + expires + "; path=/; SameSite=Lax"; COUPONAPPS( '#' + widgetid + ' .tab-box-couponcode-content .coupon-code-text').show(); } } }); } var coupon_open = widget_id +'-'+shop_id; var is_updatecouponopen = localStorage.getItem( 'is_updatecouponopen' + coupon_open); if ( is_updatecouponopen != 'yes' ) { url = couponapp_domain + 'front/updatecouponopen'; COUPONAPPS.ajax({ type: "POST", url: url, data: {'shop_url': shopurl,'widget_id':widget_id,"shop_id":shop_id}, success: function (response) { } }); localStorage.setItem( 'is_updatecouponopen' + coupon_open, 'yes'); } return false; } count++; }); }); } function couponx_expired( coupon_code, jQuery) { jQuery.ajax({ type: "POST", url: couponapp_domain + 'couponapp_front/expiredcouponcode', data: { 'coupon_code': coupon_code, 'shop_url': shopurl, }, dataType: "JSON", success: function (response) { } }); }