////console.log("code enter time:"+new Date().getTime()); jsonproperties=[]; var mlvedapropertiesmap=new Map(); var mlvedaproperties={}; var image_id_array = new Array(); var left_image_src = new Array(); var var_id = new Array(); var storename = "make-memento.myshopify.com"; var ml_one_time_call =false; var mlvedastore="www.makememento.com"; if(storename != 'jack-jumpers.myshopify.com'){console.log("mllllll:"+mlvedastore);} var mlveda_change="Change"; var mlveda_update="Update"; var mlveda_cancel="Cancel"; var mlveda_version="free"; var mlvedaPrice="Price"; var flag_ajax=false; ////console.log("code start ajax time:"+new Date().getTime()); $m.ajax({ url:"https://"+mlvedastore+"/apps/EditCart/FetchVersion", type:"post", data:{store:storename}, success:function(mlveda_data){ var d = new Date(); ////console.log("time start:"+d.getTime()); var mlveda_data=JSON.parse(mlveda_data); ////console.log(mlveda_data); if(mlveda_data.cssvalues.italic == true){ $m("").appendTo("head"); } if(mlveda_data.cssvalues.underline == true){ $m("").appendTo("head"); } if(mlveda_data.cssvalues.bold == true){ $m("").appendTo("head"); } if(mlveda_data.cssvalues.color != ""){ $m("").appendTo("head"); } $m("").appendTo("head"); mlveda_version=mlveda_data.plan; //console.log(mlveda_version); if(mlveda_version == "premium"){ //console.log(mlveda_version); mlveda_update=mlveda_data.textvalues.update; mlveda_change=mlveda_data.textvalues.change; mlveda_cancel=mlveda_data.textvalues.cancel; if(mlveda_data.textvalues.price){mlvedaPrice=mlveda_data.textvalues.price;}} $m('.mlveda-div a').html(mlveda_change); flag_ajax=true; if(storename == "elquidinbulk.myshopify.com"){ $m('.mlveda-div').css('display','inline-block'); } else{ $m('.mlveda-div').css('display','block'); } var d = new Date(); ////console.log("time end jax:"+d.getTime()); } }); ////console.log(mlveda_change); ////console.log('mlvedastore'+storename); window.click_flag = false; //////console.log("$m4:"+$m.fn.jquery); $m( document ).ready(function() { $m('body').addClass('mlveda_cart'); //liquid code $m("").appendTo("head"); //$m('.cart__remove').attr('style','width:100%; float:left;'); //$m('.cart-item__remove').attr('style','float:left;'); //$m(' #cart-form .content').attr('style','position:relative;'); var ml_flag_onetime=false; if(storename == "thefilmposter.myshopify.com"){ $m('.cart--open-right').click(function (){ ml_flag_onetime=true; mlveda_ajax_change(); }); $m('.header--mobile--cart').click(function (){ ml_flag_onetime=true; mlveda_ajax_change(); }); }else if(storename == "puppybedz.myshopify.com"){$m('.header--cart-link').click(function (){ ml_flag_onetime=true; mlveda_ajax_change(); });} else if(storename == "craftcentralcompany.myshopify.com"){$m('#product-add-to-cart').click(function (){ ml_flag_onetime=true; mlveda_ajax_change(); });$m('a[title="Cart Icon"]').click(function (){ ml_flag_onetime=true; mlveda_ajax_change(); });}else if(storename == "yayaskitchen.myshopify.com"){$m('.cart-count').click(function (){ ml_flag_onetime=true; mlveda_ajax_change(); });$( document ).ajaxComplete(function( event, xhr, settings ) { if ( settings.url === "/cart/add.js") { ml_flag_onetime=true; mlveda_ajax_change(); } });}else if(storename == "taynie.myshopify.com"){$('.header-cart').find('a[href="/cart"]').click(function(){mlveda_ajax_change();});$( document ).ajaxComplete(function( event, xhr, settings ) { if ( undefined != typeof settings.url && (settings.url === "/cart/add.js" || settings.url === "/cart/change.js") ) { ml_flag_onetime=true; setTimeout(function() {mlveda_ajax_change();}, 600); } });}else if(storename == "liveshoppingza.myshopify.com"){$m('.js-mini-cart-trigger').click(function (){ ml_flag_onetime=true; mlveda_ajax_change(); });} function mlveda_ajax_change(){ console.log(''); var list = $m( "div, p, td" ); var list1 =$m("small, p , div"); $m.ajax({ url:"https://"+mlvedastore+"/apps/EditCart/EditCartData", type:"post", data:{store:storename}, success:function(mlvedaliquiddata){ mlvedaliquiddata=JSON.parse(mlvedaliquiddata); //console.log(mlvedaliquiddata); window.mlvedamap= new Map(); for(var i=0;i

"; $m('form[action*="/cart"]:not("#ls_custom_product-form"),form[action*="/checkout"],.cart-dropdown__body,.has-items').find('a[href*="products"]').each(function() { if(!$m(this).parents("#theme-ajax-cart").hasClass("jsAjaxCart")){; if($m(this).attr('href').indexOf('lssrc=upsell') == -1){ var handle=$m(this).attr('href').split("/")[($m(this).attr('href').split("/").length-1)].substring(0,$m(this).attr('href').split("/")[($m(this).attr('href').split("/").length-1)].indexOf("?")); handle=decodeURI(handle); //////console.log(handle); //////console.log(mlvedamap); if(handle != ""){ if(mlvedamap[handle].variants.length ===1 && mlvedamap[handle].variants[0].title==="Default Title"){ } else{ if(!$m(this).has('img').length){ //////console.log("cart call"); if($m(this).parent().find(list1).first().length>0){ //////console.log("if called"); //insert change link after product title if($m(this).css('background-image')=="none"){ ////console.log("change link start:"+new Date().getTime()); if($m(this).parent().find('.mlveda-div').length == 0){ if($m('form[action*="/cart"]').hasClass('mlcartpencil')){ $m(change_link).insertAfter($m(this).parent().find('.mlcartpencilvariant')); } else{ $m(change_link).insertAfter($m(this).parent().find(list1).first()); if($m(this).parent().siblings('.mlveda-div').length > 0){ $m(this).parent().siblings('.mlveda-div').remove(); $m(this).parent().siblings('#select_id').remove(); $m(this).parent().siblings('br').remove(); }} if(flag_ajax==true){ if(storename == "elquidinbulk.myshopify.com"){ $m('.mlveda-div').css('display','inline-block'); } else{ $m('.mlveda-div').css('display','block'); } } } var mlveda_div_a = $m(this).parent().find('.mlveda-div').find('a'); var mlveda_div_select = $m(this).parent().find('#select_id'); //////console.log(mlveda_div_a); //get variant id from href var itemId = $m(this).attr('href').split('=')[1]; //get product handle from href var phandle = $m(this).attr('href').split('?')[0]; var Phandle = phandle.substring(10,phandle.length); var mlveda_div_span=$m(this).parent().find('.mlveda-div').find('span'); //Set attributes of change link and select box $m(mlveda_div_a).attr('id',itemId); $m(mlveda_div_a).attr('class',Phandle ); $m(mlveda_div_span).attr('onclick','changeVariant('+itemId+')'); $m(mlveda_div_select).attr('class',itemId+'selectbox'); }} else{ //////console.log("else called"); //for debute theme //insert change link after product title if($m(this).parent().siblings(".mlveda-div").length == 0){ ////console.log("change link start:"+new Date().getTime()); if(storename == "thefilmposter.myshopify.com"){ $m(change_link).insertAfter($m(this).parent().parent().siblings('div').last().find('.mlvarariant')); } else{ if(storename == "elquidinbulk.myshopify.com" ){ $m(change_link).insertAfter($m(this).parent()); } else if(storename== "uniform-ware-house.myshopify.com"){$m(change_link).insertAfter($m(this).parent().find('.mlve'));} else if(storename== "yayaskitchen.myshopify.com"){$m(change_link).appendTo($m(this).parent());} else{ $m(change_link).insertAfter($m(this).parent().siblings().first()); } } if(flag_ajax==true){ if(storename == "elquidinbulk.myshopify.com"){ $m('.mlveda-div').css('display','inline-block'); } else{ $m('.mlveda-div').css('display','block'); } } } if($m(this).closest('td').find('.mlveda-div').find('a').length > 0){ mlveda_div_get = $m(this).closest('td'); } else { mlveda_div_get=$m(this).parent().parent(); } if(typeof $ == 'undefined'){window.$= $m;}if($(mlveda_div_get).find('.mlveda-div').find('a').length == 0){ var mlveda_div_a=$(mlveda_div_get).siblings().find('.mlveda-div').find('a'); var mlveda_div_select = $(mlveda_div_get).siblings().find('#select_id'); ////console.log(mlveda_div_select); //get variant id from href var itemId = $m(this).attr('href').split('=')[1]; //get product handle from href var phandle = $m(this).attr('href').split('?')[0]; var Phandle = phandle.substring(10,phandle.length); if(phandle.indexOf("collections") != -1){ var try_href=phandle.substring(phandle.indexOf("products/"),phandle.length); Phandle=try_href.split('/')[1]; //console.log(Phandle); } var mlveda_div_span=$m(mlveda_div_get).siblings().find('.mlveda-div').find('span'); //Set attributes of change link and select box $m(mlveda_div_a).attr('id',itemId); $m(mlveda_div_a).attr('class',Phandle); $m(mlveda_div_span).attr('onclick','changeVariant('+itemId+')'); $m(mlveda_div_select).attr('class',itemId+'selectbox'); } else{ var mlveda_div_a=$m(mlveda_div_get).find('.mlveda-div').find('a'); var mlveda_div_select = $m(mlveda_div_get).find('#select_id'); //////console.log(mlveda_div_select); //get variant id from href var itemId = $m(this).attr('href').split('=')[1]; //get product handle from href var phandle = $m(this).attr('href').split('?')[0]; var Phandle = phandle.substring(10,phandle.length); var mlveda_div_span=$m(mlveda_div_get).find('.mlveda-div').find('span'); //Set attributes of change link and select box $m(mlveda_div_a).attr('id',itemId); $m(mlveda_div_a).attr('class',Phandle); $m(mlveda_div_span).attr('onclick','changeVariant('+itemId+')'); $m(mlveda_div_select).attr('class',itemId+'selectbox'); } } } } }}}}); $m('form[action*="/cart"],form[action*="/checkout"],.cart-dropdown__body,.has-items').addClass("mlvedacartlinkadded"); } }); } if(storename == "elquidinbulk.myshopify.com"){ flag=true; (function () { const send = XMLHttpRequest.prototype.send; XMLHttpRequest.prototype.send = function() { this.addEventListener('load', function() { ////console.log('global handler', this) if((this._url.indexOf("cart.js") != -1 && this._url.indexOf("cart.json") == -1) || this._url.indexOf("change.js") != -1 ){ var cartData = JSON.parse(this.responseText); ////console.log(cartData); if(flag){ ////console.log("hnk"); flag=false if(this._url.indexOf("cart") != -1){ if(!ml_one_time_call){ ////console.log(new Date().getTime()); var temp=setInterval(function(){ if( $m('form[action*="/cart"] a[href*="products"],form[action*="/checkout"] a[href*="products"]').length == 0 ) { ////console.log("Waiting for cart to load.."); } else { clearInterval(temp); mlveda_ajax_change(); } }, 250); }}} } // add your global handler here flag=true; }) return send.apply(this, arguments) } // if(storename == "thefilmposter.myshopify.com"){ })(); } else if(storename == "sportzzheads.myshopify.com"){ flag=true; (function () { const send = XMLHttpRequest.prototype.send; XMLHttpRequest.prototype.send = function() { this.addEventListener('load', function() { ////console.log('global handler', this) if( this.responseURL.indexOf("cart.js") != -1 && this.responseURL.indexOf("cart.json") == -1 ){ var cartData = JSON.parse(this.responseText); ////console.log(cartData); if(flag){ ////console.log("hnk"); flag=false if(this.responseURL.indexOf("cart") != -1){ if(!ml_one_time_call){ ////console.log(new Date().getTime()); var temp=setInterval(function(){ if( $m('form[action*="/cart"]:not(.mlvedacartlinkadded) a[href*="products"],form[action*="/checkout"]:not(.mlvedacartlinkadded) a[href*="products"]').length == 0 ) { ////console.log("Waiting for cart to load.."); } else { clearInterval(temp); mlveda_ajax_change(); } }, 250); }}} } // add your global handler here flag=true; }) return send.apply(this, arguments) } // if(storename == "thefilmposter.myshopify.com"){ })(); } else if(storename == "coffee-sweat.myshopify.com"){ flag=true; (function () { const fetch = window.fetch; window.fetch = function(){ var e = arguments; return fetch.apply(this, Array.prototype.slice.call(arguments)).then(function(t) { if (!t.ok) return t; try { if( undefined != typeof t.url && t.url.indexOf('cart.js' )!= -1 && t.url.indexOf('cart.json') == -1) { if(flag){ ////console.log(\ hnk\ ); flag=false if(t.url.indexOf('cart') != -1){ if(!ml_one_time_call){ ////console.log(new Date().getTime()); var temp=setInterval(function(){ if( $m('form[action*="/cart"]:not(.mlvedacartlinkadded) a[href*="products"],form[action*="/checkout"]:not(.mlvedacartlinkadded) a[href*="products"],.has-items a[href*="products"],.cart-dropdown__body a[href*="products"]').length == 0 ) { ////console.log(\ Waiting for cart to load..\ ); } else { clearInterval(temp); mlveda_ajax_change(); } }, 250); }}} } }catch (e) { console && console.warn && console.warn("[shop_events_listener] Error in handleFetchRequest: " + e.message); } flag=true; return t }) } // if(storename == "thefilmposter.myshopify.com"){ })(); $m('.navlink--cart').click(function(){setTimeout(function(){console.log("entered"); if($m('.is-open').length!=0){console.log("hello1");mlveda_ajax_change();}},1000)});} else{ flag=true; (function () { const send = XMLHttpRequest.prototype.send; XMLHttpRequest.prototype.send = function() { this.addEventListener('load', function() { ////console.log('global handler', this) if(this._url.indexOf("cart.js") != -1 && this._url.indexOf("cart.json") == -1 ){ var cartData = JSON.parse(this.responseText); ////console.log(cartData); if(flag){ ////console.log("hnk"); flag=false if(this._url.indexOf("cart") != -1){ if(!ml_one_time_call){ ////console.log(new Date().getTime()); var temp=setInterval(function(){ if( $m('form[action*="/cart"]:not(.mlvedacartlinkadded) a[href*="products"],form[action*="/checkout"]:not(.mlvedacartlinkadded) a[href*="products"]').length == 0 ) { ////console.log("Waiting for cart to load.."); } else { clearInterval(temp); mlveda_ajax_change(); } }, 250); }}} } // add your global handler here flag=true; }) return send.apply(this, arguments) } // if(storename == "thefilmposter.myshopify.com"){ })(); $m('a[href="/cart"]').click(function(){if($m('body').has('cart-drawer').length > 0){setTimeout(function(){console.log("hello1");mlveda_ajax_change();},1000)}});; flag=true; (function () { const fetch = window.fetch; window.fetch = function(){ var e = arguments; return fetch.apply(this, Array.prototype.slice.call(arguments)).then(function(t) { if (!t.ok) return t; try { if( undefined != typeof t.url && (t.url.indexOf('add')!= -1 && t.url.indexOf('cart.json') == -1 || t.url.indexOf('change' )!= -1) ) { if(flag){ ////console.log(\ hnk\ ); $m('form[action*="/cart"]').removeClass("mlvedacartlinkadded"); flag=false if(t.url.indexOf('cart') != -1){ if(!ml_one_time_call){ ////console.log(new Date().getTime()); var temp=setInterval(function(){ if( $m('form[action*="/cart"]:not(.mlvedacartlinkadded) a[href*="products"],form[action*="/checkout"]:not(.mlvedacartlinkadded) a[href*="products"],.has-items a[href*="products"],.cart-dropdown__body a[href*="products"]').length == 0 ) { ////console.log(\ Waiting for cart to load..\ ); } else { clearInterval(temp); mlveda_ajax_change(); } }, 250); }}} } }catch (e) { console && console.warn && console.warn("[shop_events_listener] Error in handleFetchRequest: " + e.message); } flag=true; return t }) } })(); } }); function SelectElement(valueToSelect) { //set selected attribute when variant will change $m("#mlProductSelect option").removeAttr("selected"); $m('#mlProductSelect option[value*='+valueToSelect+']').attr("selected","selected"); } var variant_first=null; //cp_selectCallback will trigger when variant will change var cp_selectCallback = function (variant, selector) { if(variant){ //get product price $m('.cancel_button').css('padding-left', '0px'); var variant_price = variant.price; //get variant ID window.new_variant = variant.id; if(variant_first==null){ variant_first=variant.id; } //display price and compare price of selected variant if(variant.compare_at_price!= null && variant.price < variant.compare_at_price){ $m('#price_'+variant_first).html(mlvedaPrice+':' + Shopify.formatMoney(variant.price,'£{{amount}}') + '' + ' ' + Shopify.formatMoney(variant.compare_at_price,'£{{amount}}') + ''); }else{$m('#price_'+variant_first).html(mlvedaPrice+':' + Shopify.formatMoney(variant.price,'£{{amount}}') + '' );} //get variant quantity if(variant.inventory_management!=null && variant.inventory_policy == "deny" && variant.inventory_quantity<1){ //if variant is not available //disable update button and display soldout $m('.update_button').attr('disabled',true); $m('.update_link').css('pointer-events','none'); $m('.update_button').text("Sold Out"); } else {//if variant is available //active update button and display update $m('.update_button').attr('disabled',false); $m('.update_link').css('pointer-events','auto'); $m('.update_button').text(mlveda_update); } var i,n; //get all image id and image src of product for (n = 0; n < cp_response_product.images.length; n++) { left_image_src[n] = ("https:").concat(cp_response_product.images[n]); } var v_img_id,v_img_src; var k,l,i; //get image_src of selected variant and change its image for(k=0;k 0){ if($m('a[href*='+variantId+'], div[data-id*='+variantId+']').find('img').attr('srcset')=== undefined){ $m('a[href*='+variantId+'], div[data-id*='+variantId+']').find('img').attr('src',v_img_src);} else{$m('a[href*='+variantId+'], div[data-id*='+variantId+']').find('img').attr('srcset',v_img_src);} } else{ $m('a[href*='+variantId+'], div[data-id*='+variantId+']').find('.cart-img').css('background-image','url('+v_img_src.substring(v_img_src.indexOf(":")+1,v_img_src.length)+')'); } SelectElement(variant.id); } } if( typeof Currency !== "undefined" && typeof Currency.moneyFormats !== "undefined" && typeof mlvedaload !== "undefined" ) { mlvedaload(); } if( typeof ACSCurrency !== "undefined" && typeof ACSCurrency.moneyFormats !== "undefined" && typeof mlvedaload !== "undefined" ) { mlvedaload(); } } else{ $m('.update_button').attr('disabled',true); $m('.update_link').css('pointer-events','none'); $m('.cancel_button').css('padding-left', '31px'); $m('.update_button').text("Unavailable"); } //added on 5th april if(storename == "elquidinbulk.myshopify.com"){ $m('.mlveda-main').attr('style','display:inline-block;'); $m('.update_link').attr('style','width:auto!important;'); $m('.cancel_button').attr('style','padding-left: 5px!important;'); } $m('.mlveda-main .selector-wrapper').attr('style','display:inline-block;margin-right:10px;'); $m('.mlveda-main .selector-wrapper select').attr('style','-webkit-appearance: none;-moz-appearance: none;appearance: none;background-position: right center;background-repeat: no-repeat;background-position: right 10px center;padding-right: 28px;text-indent: 0.01px;text-overflow:"";cursor: pointer;max-width:100%!important;opacity:1;width: auto;height:auto;display: block;'); $m('.mlveda-main .selector-wrapper select').css('background-image','url(//cdn.shopify.com/s/files/1/1343/4997/t/2/assets/ico-select.svg?17215262782595962318)'); };//End of select callback //Hide label append manually by us if option selection also append label for that variant. var mlveda_observer = new MutationObserver(function(mutations){ mutations.forEach(function(mutation) { //////console.log('abcd'); if(mutation.addedNodes[0] && mutation.addedNodes[0].childNodes[0] && mutation.addedNodes[0].childNodes[0].tagName === "LABEL" ){ window.mlveda_label = mutation.addedNodes[0].childNodes[0]; $m('.labelTag').hide(); } }); }); var div2 = document.querySelector('body'); mlveda_observer.observe(document, { childList: true , subtree : true}); window.updateVariant = function(var_id){ $m.ajax({ url:"https://"+mlvedastore+"/apps/EditCart/UpdateClick", type:"post", data:{store:storename}, success:function(mlvedaa_data){ //console.log(mlvedaa_data); }}); $m.ajax({ url:"https://www.mlveda.com/ShopifyApps/EditCart/GetAllUpdateClicks", type:"post", data:{store:storename}, success:function(){ //console.log("data update updated"); }}); var variant_id; $m('.update_link').css('pointer-events','none'); $m('.update_link').css('opacity','0.5'); if($m('.'+var_id+'selectbox').find('#mlProductSelect').find('option[selected=selected]').length>0){ variant_id =$m('.'+var_id+'selectbox').find('#mlProductSelect').find('option[selected=selected]').val(); } else { variant_id =$m('.'+var_id+'selectbox').find('#mlProductSelect').val(); } $ var obj1 = {}; obj1[var_id] = 0; var obj2 = { updates:obj1 } ml_one_time_call =true; //get all product data which are in cart $m.getJSON( "/cart.js", function( data ) { var i; var mlvedacartvariant; for(i=0;i 0 ) { var qty = parseInt($cartQty); if ( qty == 1 ) { $('#site-cart .subtitle').html($('#site-cart .subtitle').data('added-singular').replace("{{ count }}", qty)); } else { $('#site-cart .subtitle').html($('#site-cart .subtitle').data('added-plural').replace("{{ count }}", qty)); } $cartCount.text(parseInt($cartCount.text()) + parseInt($cartQty)); } else { $cartCount.text(parseInt($cartCount.text()) + 1); $('#site-cart .subtitle').html($('#site-cart .subtitle').data('added-singular').replace("{{ count }}", 1)); } if (Number($cartCount.text()) > 0 ) { $('.count-holder').addClass('count-holder--active'); } else { $('.count-holder').removeClass('count-holder--active'); } $('.site-cart-handle a').trigger('click'); $m.getJSON( "/cart.js", function( data ) {}); } }); } else{ $m(ml_list).find(" a[href*='"+line_item.url.split("?")[0]+"']").each(function(){ if(storename == "sportzzheads.myshopify.com" || storename == "coffee-sweat.myshopify.com"){ $input = $m(this).find("input[type=number]"); if($input.length < 1){ $input = $m(this).parent().find("input[type=number]"); if ($input.length < 1) { $input = $m(this).parent().parent().find("input[type=number]"); if ($input.length < 1) { $input = $m(this).parent().parent().parent().find("input[type=number]"); if ($input.length < 1) { $input = $m(this).parent().parent().parent().parent().find("input[type=number]"); if ($input.length < 1) { $input = $m(this).parent().parent().parent().parent().parent().find("input[type=number]"); } } } } } } else{ $input = $m(this).find("input[type=text],input[type=number]"); if($input.length < 1){ $input = $m(this).parent().find("input[type=text],input[type=number]"); if ($input.length < 1) { $input = $m(this).parent().parent().find("input[type=text],input[type=number]"); if ($input.length < 1) { $input = $m(this).parent().parent().parent().find("input[type=text],input[type=number]"); if ($input.length < 1) { $input = $m(this).parent().parent().parent().parent().find("input[type=text],input[type=number]"); if ($input.length < 1) { $input = $m(this).parent().parent().parent().parent().parent().find("input[type=text],input[type=number]"); } } } } } } //else end }); if(typeof $input != 'undefined'){var ml_quantity = $input.val(); ml_quantity = ml_quantity.replace(/\D/g,''); ////console.log("ml_quantity : ",typeof ml_quantity); ml_one_time_call =false; if($m("input[type=text][data-line=1]").length > 0){ if(storename == "elquidinbulk.myshopify.com"){ $m("input[type=text][data-line=1]").val(ml_quantity)[0].dispatchEvent(new Event("keyup",{bubbles:true})); } else if(storename == "uniform-ware-house.myshopify.com"){ window.location.href='/cart'}else if(storename == "yayaskitchen.myshopify.com"){ window.location.href='/cart'}else if(storename == "craftcentralcompany.myshopify.com"){ window.location.href='/cart'}else{ $m("input[type=text][data-line=1]").val(ml_quantity)[0].dispatchEvent(new Event("change",{bubbles:true})); } } // for classic theme else{ if($(".mlvedacartlinkadded input.ajaxcart__qty-num").length > 0){ $(".mlvedacartlinkadded input.ajaxcart__qty-num").val(ml_quantity)[0].dispatchEvent(new Event("change",{bubbles:true})); } else if($(".mlvedacartlinkadded input.cart--quantity--input").length > 0){ if(storename == "puppybedz.myshopify.com"){$(".mlvedacartlinkadded input.cart--quantity--input").val(ml_quantity)[0].dispatchEvent(new Event("focusout",{bubbles:true})); }else {$(".mlvedacartlinkadded input.cart--quantity--input").val(ml_quantity)[0].dispatchEvent(new Event("keyup",{bubbles:true})); }} else if($(".mlvedacartlinkadded input.quantity-input").length > 0){ {$(".mlvedacartlinkadded input.quantity-input").val(ml_quantity)[0].dispatchEvent(new Event("change",{ bubbles: true })); }} else{ if(storename =="dorothycp.myshopify.com"){ $input.val(ml_quantity); Shopify.onItemAdded(line_item); } else{ if(storename == 'coffee-sweat.myshopify.com'){$m.getJSON( "/cart.js", function( data ) { debugger; for(i=0;i0){$(".mlvedacartlinkadded input.QuantitySelector__CurrentQuantity").val(ml_quantity)[0].dispatchEvent(new Event("change",{bubbles:true})); }if(storename == "yayaskitchen.myshopify.com"){ window.location.href='/cart'}}}}}} }}else{window.location.href='/cart';}}}, error: function(XMLHttpRequest, textStatus) { // Shopify.onError(XMLHttpRequest, textStatus); } }; $m.ajax(params); } /* $m( document ).ajaxComplete(function( event, xhr, settings ) { ////console.log("in AjaxComplete to check whether $ call affects here or not.1"); //after completing cart update call if ( settings.url === "/cart/update.js" ) { //////console.log("add::"+cart_quantity); //cart add call $m.post('/cart/add.js', {quantity:cart_quantity,id: new_variant}); }else if ( settings.url === "/cart/add.js" ) { //refresh current page //window.location.href=window.location.href; ////console.log("jf : ",typeof Shopify.changeItem); ////console.log("event : ",event); ////console.log("xhr : ",JSON.parse(xhr.responseText).url.split("?")[0]); ////console.log("settings : ",settings); debugger; ////console.log($(".cart-row a[href*='"+JSON.parse(xhr.responseText).url.split("?")[0]+"']")); $m($m(".cart-row a[href*='"+JSON.parse(xhr.responseText).url.split("?")[0]+"']")[0]).each(function(){ $input = $m(this).find("input[type=text]"); if($input.length < 1){ $input = $m(this).parent().find("input[type=text]"); if ($input.length < 1) { $input = $m(this).parent().parent().find("input[type=text]"); if ($input.length < 1) { $input = $m(this).parent().parent().parent().find("input[type=text]"); if ($input.length < 1) { $input = $m(this).parent().parent().parent().parent().find("input[type=text]"); if ($input.length < 1) { $input = $m(this).parent().parent().parent().parent().parent().find("input[type=text]"); } } } } } }); var ml_quantity = $input.val(); ml_quantity = ml_quantity.replace(/\D/g,''); ////console.log("ml_quantity : ",typeof ml_quantity); $input.val(ml_quantity)[0].dispatchEvent(new Event("change",{bubbles:true})); } }); */ } //start of cancel window.cancelVariant = function(variantcancelid){ debugger; //var mlveda_href=$m('.mlveda-div ').parent().find('a').attr('href'); //var mlveda_href_variant=mlveda_href.substring('mlveda_href.indexOf("=")','mlveda_href.length+1'); $m('.mlveda-div ').parent().find('a[href*="products"]').each(function(){ var mlveda_href=$m(this).attr('href'); if(mlveda_href){ var mlveda_producthandle=(mlveda_href.split("/")[mlveda_href.split("/").length-1]).split("?")[0]; mlveda_producthandle=decodeURI(mlveda_producthandle); ////console.log(mlveda_producthandle); var mlveda_variantid=mlveda_href.substring(mlveda_href.indexOf("=")+1); var mlveda_productdata=mlvedamap[mlveda_producthandle]; ////console.log(mlveda_productdata); if(mlveda_productdata){ for(k=0;k 0){ if($m('a[href*='+mlveda_variantid+'], div[data-id*='+mlveda_variantid+']').find('img').attr('srcset')=== undefined){ $m('a[href*='+mlveda_variantid+'], div[data-id*='+mlveda_variantid+']').find('img').attr('src',mlveda_imgsrc);} else{$m('a[href*='+mlveda_variantid+'], div[data-id*='+mlveda_variantid+']').find('img').attr('srcset',mlveda_imgsrc);} } else{ $m('a[href*='+mlveda_variantid+'], div[data-id*='+mlveda_variantid+']').find('.cart-img').css('background-image','url('+mlveda_imgsrc.substring(mlveda_imgsrc.indexOf(":")+1,mlveda_imgsrc.length)+')'); } } } } }}); $m('.mlveda-div').show(); $m('.mlveda-div a').show(); $m('.mlveda-main').remove(); }//end of cancel //called when change link will be clicked window.changeVariant = function(variant_id){ variant_first=null; $m.ajax({ url:"https://www.mlveda.com/ShopifyApps/EditCart/GetAllClicks", type:"post", data:{store:storename}, success:function(){ //console.log("data changeupdated"); }}); window.variantId = variant_id; //var mlveda_href=$m('.mlveda-div ').parent().find('a').attr('href'); //var mlveda_href_variant=mlveda_href.substring('mlveda_href.indexOf("=")','mlveda_href.length+1'); $m('.mlveda-div ').parent().find('a[href*="products"]').each(function(){ var mlveda_href=$m(this).attr('href'); if(mlveda_href){ var mlveda_producthandle=(mlveda_href.split("/")[mlveda_href.split("/").length-1]).split("?")[0]; mlveda_producthandle=decodeURI(mlveda_producthandle); //////console.log(mlveda_producthandle); var mlveda_variantid=mlveda_href.substring(mlveda_href.indexOf("=")+1); var mlveda_productdata=mlvedamap[mlveda_producthandle]; //////console.log(mlveda_productdata); if(mlveda_productdata){ for(k=0;k 0){ $m('a[href*='+mlveda_variantid+'], div[data-id*='+mlveda_variantid+']').find('img').attr('src',mlveda_imgsrc); } else{ $m('a[href*='+mlveda_variantid+'], div[data-id*='+mlveda_variantid+']').find('.cart-img').css('background-image','url('+mlveda_imgsrc.substring(mlveda_imgsrc.indexOf(":")+1,mlveda_imgsrc.length)+')'); } } } } }}); $m('.mlveda-div').show(); $m('.mlveda-div a').show(); $m('.mlveda-main').remove(); var product_handle = $m('#'+variant_id).attr('class'); product_handle=decodeURI(product_handle); //////console.log(product_handle); ////console.log("update:"+mlveda_update); //append select box var select_box = ""; $m(select_box).appendTo('.'+variant_id+'selectbox'); $m('.mlveda-main').hide(); //start here var mlveda_observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if(mutation.attributeName === 'style'){ if(mlveda_version == "premium") { if($m('.mlvedabrand').css('display') != 'none'){ $m('.mlvedabrand').attr("style", "display: none !important"); }} else{ if($m('.mlvedabrand').css('display') != 'block'){ $m('.mlvedabrand').attr("style", "display: block !important"); } } } if (mutation.type == 'childList') { if($m('.mlvedabrand').length == 0){ var mlpower="
Powered by MLveda
"; $m(mlpower).appendTo('.mlveda-main'); }} }); }); // Notify me of style changes var observerConfig = { attributes: true, attributeFilter: ["style"], childList: true }; var targetNode = $m('.mlvedabrand')[0]; if(mlveda_version == "premium") {$m('.mlvedabrand').attr("style", "display: none !important"); } else{ $m('.mlvedabrand').attr("style", "display: block !important"); } mlveda_observer.observe(targetNode, observerConfig); var observer1 = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.type == 'childList') { if($m('.mlvedabrand').length == 0){ var mlpower="
Powered by MLveda
"; $m(mlpower).appendTo('.mlveda-main'); }} }); }); // Notify me of style changes var observerConfig = { childList: true }; observer1.observe($m('.mlvedabrand').parent()[0], observerConfig); var label_name = []; var i,j; //console.log(mlvedamap[product_handle]); window.cp_response_product = mlvedamap[product_handle]; //console.log(cp_response_product['options']); //get all options name for(j=0;j0){ if($m(this).css('background-image')=="none"){ //hide title of variant $m(this).parent().find(list1).first().hide(); //hide change link after click $m(this).parent().find('.mlveda-div a').hide(); }}else { //for debute theme if($m(this).siblings('span').length>0){ $m(this).siblings('span').hide(); } //hide title of variant else{ if($m(this).parent().siblings('div').first().length>0){ $m(this).parent().siblings('div').first().hide(); //for debute } else{ if(storename == "thefilmposter.myshopify.com"){ $m(this).parent().parent().siblings('div').last().find('.mlvarariant').hide(); }else{ $m(this).parent().parent().siblings('div').last().hide(); } } } //hide change link after click //$m(this).parent().parent().find('.mlveda-div span a').hide();//for debute if($m(this).parent().parent().find('.mlveda-div span a').length > 0){ $m(this).parent().parent().find('.mlveda-div span a').hide();//for debute } else{ $m(this).parent().parent().siblings('div').last().find('.mlveda-div span a').hide(); } } } }); } } //For product which has only one variant if(cp_response_product.options.length == 1) { //append label manually var label_option = ""; $m(label_option).appendTo('.labelTag'); } //fill select box with variant id as value and variant title as text for(i=0;i"+ v_title + ""; $m(option).appendTo("#mlProductSelect"); } //put selected variant as first in product json to display selected variant by default when change link will be clicked for(i=0;i