if(typeof SPICESHIPPING=='undefined'){var SPICESHIPPING={}}SPICESHIPPING.SGShippingrules=function(){if((typeof Shopify)==='undefined'){Shopify={}}var scriptHost='https://geoship.spicegems.com';var productUrl=window.location;var shopName='bidaway';var spiceDiv;var spiceData;var monthNames=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];var spiceSetting={"is_active":"1","show_map":"0","cart_type":1,"ob_block":"","add_after":"","ajax_qty":"","delivery_date":"0","delivery_txt":"Expected delivery date","cart_qty":"","qty_sel":"","color_scheme":"#000000","subtotal_box_color":"#ffffff","update_btn_txt_color":"#ffffff","shipp_rate_box_title":"Shipping & Handling rates for","shipp_rate_def_title":"Shipping rates","subtotal":"Subtotal","shipping_text":"Shipping & Handling","total_text":"Total","update_btn_text":"Gather shipping rates","change_loct_text":"Not Shipping to","shipp_rate_product_title":"Shipping rates for","custom_css":"@media (min-width: 760px){\r\n#spiceshippingappid{\r\ndisplay:table;\r\nmargin-left: auto;\r\nmargin-right: auto;\r\n}\r\n.spicegems-geoship-temp1 .spicegems-geoship-address .chevron::before{\r\n margin-right: 0;\r\n margin-bottom: 5px;\r\n}\r\n}\r\n@media (max-width: 760px){\r\n.spicegems-geoship-temp1 .spicegems-geoship-form{\r\nmargin-top: 20px;\r\n}\r\n.spicegems-geoship-temp1 .spicegems-geoship-address .chevron::before{\r\nmargin-right: 15px;\r\n}}\r\n\r\n.sg-shipping-rates{\r\n max-width: 500px;\r\n padding: 20px;\r\n font-family: Quicksand,sans-serif;\r\n}\r\n.spicegems-geoship-temp1 .sg-shipping-rates-cart-subtotal{\r\n color: #000!important ;\r\n}\r\n.sg-money, .sg-rate-name, .sg-shipping-address-link.sg-shipping{\r\n color: #000;\r\n font-family: Quicksand,sans-serif;\r\n}\r\n.spicegems-geoship-temp1 .spicegems-geoship-form, #sg-country, #sg-region, #sg-zip-code {\r\n background-color: #c9f4aa!important ;\r\n}\r\n.spicegems-geoship-temp1{\r\nbackground: #f0f0f0!important ;\r\n}\r\n.sg-update-button{\r\n background-color: #1c1c1c!important ;\r\ncolor: #ffd966!important ;\r\n}","auto_install":"1","tmt":"1","db":"0","currency":" ${{ amount }} <\/span>","ship_rate_box_color":"#f6f6f6","ship_rate_box_title_color":"#080808","update_btn_color":"#080808"};var shippingZones;var shippingLocation,sgaddress=null,sgrates='',sgcart='';var cartTotalPrice=0;var pvariantid='';var b='';var P;var cartForm;var zipErr='';var m=false;var phandle='';var spiceCss="@import url('https://fonts.googleapis.com/css?family=Nunito&display=swap');.sg-shipping-rates{border:1px solid #ccc;position:relative;clear:both;text-align:-moz-left;margin:10px auto 10px 0;background-color:#fff;max-width:1140px;cursor:default;padding:5px;font-family:'Nunito', sans-serif}.sg-shipping-rates-heading{font-size:20px;font-weight:600;text-transform:none;margin-bottom:20px}.sg-shipping-rates-chooser{display:table;width:100%;margin-bottom:10px}.sg-shipping-rates-map{width:100%;vertical-align:top;margin-bottom:10px}.sg-map{width:100%;height:300px}.sg-rate-list{font-size:20px}.sg-rate-item{display:table;margin-bottom:6px}#sg-shipping-rate{vertical-align:middle;-webkit-appearance:radio;margin:0;cursor:pointer}.sg-rates-label{display:table-cell;float:none;padding-left:0.5em;font-size:1em;text-transform:none;cursor:pointer;font-family:'Nunito', sans-serif;font-style:normal}.sg-rate-name{color:#333}.sg-rate-amount{color:rgb(0, 0, 0);font-weight:bold}.sg-money{color:#333;font-weight:inherit;font-size:inherit;text-decoration:inherit}.sg-delivery-date{display:block;text-transform:none;font-weight:normal;color:#f00}.sg-error-message{padding:10px;color:red;background-color:rgb(255, 246, 246);display:block;font-family:'Nunito', sans-serif}.sg-success-msg{color:#3c763d;background-color:#dff0d8;border-color:#d6e9c6;font-family:'Nunito', sans-serif}.sg-shipping-rates-cart-subtotal{display:table;white-space:nowrap;width:100%;text-align:left;margin-bottom:5px}.sg-shipping{color:#000}#sg-shipping-subtotal{display:table-cell;white-space:nowrap}.sg-cart-money{color:inherit;font-weight:inherit;font-size:inherit;text-decoration:inherit;text-align:right;display:table-cell}.sg-shipping-address{display:inline-block;border-top:2px solid #ccc;padding:20px 0;margin-top:1em;cursor:pointer}.sg-shipping-address-link.sg-shipping{color:#333;text-decoration:none;letter-spacing:0.5px;font-family:'Nunito', sans-serif}.sg-shipping-address-chooser{display:none}.sg-country-select,.sg-region-select,.sg-zip-code{display:inline-block;-webkit-appearance:menulist;background-image:none;width:auto !important;margin-right:5px !important;margin-top:0.3em !important;margin-bottom:2px !important;padding:2px !important;height:auto;line-height:40px;font-size:0.9em;vertical-align:bottom}.sg-region-options{line-height:40px;font-size:0.9em}.sg-update-button{background:none 0 0 / auto repeat scroll padding-box border-box #034f84;box-shadow:none;border:none;border-radius:5px;padding:10px 15px;margin-top:10px;display:block;width:auto;cursor:pointer}.sg-update-button:hover{background:none 0 0 / auto repeat scroll padding-box border-box #419ce3}.sg-update-button-text.sg-shipping{font-size:14px;font-weight:700;color:#fff;cursor:pointer}#sg-cart-subtotal{float:right}#sg-cart-total{display:table-cell;white-space:nowrap;border-top:2px solid #000;font-weight:bold;color:red}.total{color:red;font-weight:bold}@media (min-width:760px){.sg-rate-list{font-size:20px;width:50%;float:left;padding-left:10px;box-sizing:border-box}.sg-shipping-rates-totals{width:50%;float:right}.sg-shipping-rates{width:75%}.sg-shipping-rates-map{width:50%;float:left;border-right:solid silver 1px;padding-right:10px;box-sizing:border-box}}.sg-shipping-rates-chooser{padding-right:5px;border-radius:5px}.sg-map{height:auto}#sg-grand-total{border-top:1px solid}.sg-shipping-rates-heading{font-size:16px !important}.sg-rates-label{font-size:16px !important;letter-spacing:0 !important}.sg-shipping-rates{border-radius:5px}.sg-country-select,.sg-region-select,.sg-zip-code{height:30px !important;display:inline-block}input#sg-zip-code{-webkit-appearance:textfield}:root{--theme-color:#a3b113;--border-color:rgba(163, 177, 19, 0.5);--sg-shipping-box-align:right;--shiping-form-align:-webkit-right;--background-color:#efefef;--shiping-form-align:-moz-right}.spicegems-geoship-temp1{border:1px solid #ccc;border-radius:4px;padding:10px;margin:5px;font-family:'Nunito', sans-serif;background:#f9fcfc;width:min-content;float:right;float:var(--sg-shipping-box-align);box-sizing:border-box}.spicegems-geoship-temp1 .spicegems-geoship-container{display:block;width:max-content;clear:both}.spicegems-geoship-temp1 .spicegems-geoship-heading{width:100%;font-size:20px;float:left;margin:0 0 15px;color:var(--theme-color);font-size:15px;font-family:'Nunito', sans-serif;font-weight:bold;letter-spacing:0.5px}.spicegems-geoship-temp1 .spicegems-geoship-map{vertical-align:top}.spicegems-geoship-temp1 .spicegems-geoship-map > .sg-map{width:100%;min-height:180px;height:auto;border:1px solid #c0c0c0}.spicegems-geoship-temp1 .spicegems-geoship-rates{min-width:200px;max-width:400px;width:100%;width:-webkit-fill-available}.spicegems-geoship-temp1 .spicegems-geoship-map + .spicegems-geoship-rates{width:auto}.spicegems-geoship-rates,.spicegems-geoship-temp1 .spicegems-geoship-map{display:inline-block;padding:5px;>>> add}.spicegems-geoship-temp1 .spicegems-geoship-rate-item{text-align:left;margin-bottom:5px;color:#444;display:inline-block;margin-left:20px;width:-webkit-fill-available}.spicegems-geoship-temp1 .spicegems-geoship-rates-label{font-size:13px;cursor:pointer;font-family:'Nunito', sans-serif;letter-spacing:0.8px;line-height:18px;text-align:left;text-transform:none;font-weight:normal;font-style:normal}.spicegems-geoship-temp1 .spicegems-geoship-option{width:100%;padding:12px 20px;margin:8px 0;box-sizing:border-box}.spicegems-geoship-temp1 .spicegems-geoship-container1{width:100%}.spicegems-geoship-temp1 .spicegems-geoship-rates-label > input#sg-shipping-rate{cursor:pointer;margin:0 7px 0 0;vertical-align:middle;width:13px !important;margin-left:-20px}.spicegems-geoship-temp1 .spicegems-geoship-rates-label > span.sg-rate-amount{font-size:14px;font-family:'Nunito', sans-serif;font-weight:normal}.spicegems-geoship-temp1 .spicegems-geoship-rates > .sg-error-message{display:none;color:red;margin-top:15px;text-align:left;font-size:13px;font-family:'Nunito', sans-serif}.spicegems-geoship-temp1 .spicegems-geoship-rates-total{width:100%;margin-top:10px;border-radius:5px;box-sizing:border-box;font-family:'Nunito', sans-serif;font-weight:bold}.spicegems-geoship-temp1 .spicegems-geoship-totals{font-size:13px;padding:5px 0;font-family:'Nunito', sans-serif;clear:both;letter-spacing:0.5px;color:#333}.spicegems-geoship-temp1 .spicegems-geoship-totals b{text-align:left;float:left;opacity:0.9}.spicegems-geoship-temp1 .sg-shipping-rates-cart-subtotal b{opacity:1}.spicegems-geoship-temp1 .spicegems-geoship-totals span{float:right}.spicegems-geoship-temp1 .sg-shipping-rates-cart-subtotal{font-weight:bold;margin-top:2px;color:var(--theme-color);position:relative}.sg-shipping-rates-cart-subtotal.spicegems-geoship-totals:after{content:'';width:100%;border-top:1.5px solid;position:absolute;top:3px;left:0;opacity:0.8}.spicegems-geoship-temp1 #sg-grand-total{border-top:none}.spicegems-geoship-temp1 .spicegems-geoship-form{background-color:var(--background-color);padding:5px;margin-top:10px;border:1px solid #ddd;border-radius:5px;cursor:pointer;text-align:var(--sg-shipping-box-align);font-family:'Nunito', sans-serif}.spicegems-geoship-temp1 .spicegems-geoship-address{padding:5px 0;font-size:14px}.spicegems-geoship-temp1 .spicegems-geoship-address:hover{color:blue}.spicegems-geoship-temp1 .spicegems-geoship-address-chooser{display:none}.spicegems-geoship-temp1 .spicegems-geoship-address-chooser{margin:5px;text-align:right;text-align:var(--shiping-form-align)}.spicegems-geoship-address-chooser > *{margin:5px;display:inline-block}.spicegems-geoship-temp1 .spicegems-geoship-address-chooser .sg-country-select,.spicegems-geoship-temp1 .spicegems-geoship-address-chooser .sg-region-select,.spicegems-geoship-temp1 .spicegems-geoship-address-chooser .sg-zip-code{padding:4px 6px;border:2px solid;border-color:var(--theme-color);margin:5px 0;line-height:normal;font-family:'Nunito', sans-serif}.spicegems-geoship-temp1 .spicegems-geoship-address-chooser .sg-zip-code{width:80px;border:2px solid;border-color:var(--theme-color)}.spicegems-geoship-temp1 .spicegems-geoship-address-chooser .sg-update-button{color:#fff;background-color:var(--theme-color);box-shadow:none;border:none;border-radius:5px;padding:10px 15px;margin-top:10px;display:block;width:auto;cursor:pointer;letter-spacing:0.8px;font-family:'Nunito', sans-serif}.spicegems-geoship-temp1 .spicegems-geoship-address span.chevron{float:right}.spicegems-geoship-temp1 .spicegems-geoship-address .chevron::before{border-style:solid;border-width:0.20em 0.20em 0 0;content:'';display:inline-block;height:8px;width:8px;position:relative;transform:rotate(45deg);vertical-align:middle;text-align:center;margin-right:5px;margin-left:5px}.spicegems-geoship-temp1 .spicegems-geoship-address .chevron-rotate::before{transform:rotate(135deg)}@media only screen and (max-width: 700px){.spicegems-geoship-temp1,.spicegems-geoship-temp1 .spicegems-geoship-container{width:100%;margin:0 auto}.spicegems-geoship-address-chooser > *{margin:5px;display:block;width:95% !important}.spicegems-geoship-rates,.spicegems-geoship-temp1 .spicegems-geoship-map{display:block;width:-webkit-fill-available}}#spiceshippingappida .sg-shipping-rates,#spiceshippingappida .spicegems-geoship-temp1{}#spiceshippingappida .sg-shipping-rates-totals{}#spiceshippingappidd .sg-shipping-rates,#spiceshippingappidd .spicegems-geoship-container,#spiceshippingappidd .spicegems-geoship-form,#spiceshippingappidd .spicegems-geoship-map,#spiceshippingappidd .spicegems-geoship-rates,#spiceshippingappidd .spicegems-geoship-temp1{width:100%}#spiceshippingappidd .sg-rate-list{float:none;width:99%}#spiceshippingappidd .sg-shipping-rates-map{width:99%}#spiceshippingappidd .sg-shipping-rates-totals{width:100%}#spiceshippingappidd .sg-shipping-rates-map{border-right:none;padding-right:none}#spiceshippingappidd .spicegems-geoship-address-chooser > *{margin:5px;display:block;width:95% !important}@media only screen and (max-width: 760px){.sg-rate-list{width:99% !important}}#spiceshippingappid .spicegems-pro-geoship{min-width:300px}#spiceshippingappid .spicegems-pro-geoship-container{border:1px solid #777;border-radius:4px;padding:10px;width:fit-content;border-color:#7272ed}.spicegems-pro-geoship-heading{font-family:'Nunito', sans-serif;font-size:20px;font-weight:600;text-transform:none;margin-top:0;margin-bottom:10px;color:#7272ed}.spicegems-pro-geoship-rates-label{font-family:'Nunito', sans-serif;font-size:14px;cursor:pointer;letter-spacing:0.8px;line-height:18px;text-align:left;text-transform:none;font-weight:normal;font-style:normal;display:block;margin-bottom:5px}.spicegems-pro-geoship-rates-label .pro-sg-money{font-size:15px}.spicegems-pro-geoship-rates-label::before{display:inline-block;content:'';-webkit-border-radius:0.375rem;border-radius:0.375rem;height:0.50rem;width:0.50rem;margin-right:10px;background-color:#bdbdbd}.spicegems-geoship-temp1 .spicegems-geoship-address-chooser .sg-update-button{margin-left:auto}.spicegems-geoship-temp1 .spicegems-geoship-address-chooser .sg-country-select,.spicegems-geoship-temp1 .spicegems-geoship-address-chooser .sg-region-select,.spicegems-geoship-temp1 .spicegems-geoship-address-chooser .sg-zip-code{margin-left:auto}";SPICESHIPPING.getForm=function(){$("form").each(function(){var action=$(this).attr('action');if(typeof action!=='undefined'){if(action==="/cart"){if($(this).parents('main').length>0){cartForm=this}else{cartForm=this}return false}}})};SPICESHIPPING.getProductHandle=function(){var dfdHandle=$.Deferred();var phref=fullUrl=productUrl.href;phref=phref.split('#')[0];phref=phref.split('?')[0];var position=phref.lastIndexOf('/');var handle=phref.substring(position+1);phandle=handle;if(fullUrl.indexOf('?variant=')!=-1){pvariantid=fullUrl.split('?variant=')[1]}dfdHandle.resolve(handle);return dfdHandle.promise()};SPICESHIPPING.getProductData=function(handle){var d10=$.Deferred();$.ajax({type:"GET",url:'/products/'+handle+'.js',dataType:"json",error:function(data){d10.reject()},success:function(data){if(data.variants[0].requires_shipping===true){d10.resolve(data)}else{d10.reject()}}});return d10.promise()};SPICESHIPPING.getProductShipping=function(data){var d11=$.Deferred();var shop_data=SPICESHIPPING.storage.get('sgdata');var locations=shop_data.location;if(pvariantid===''){var vdata=data.variants[0]}else{var vdata=$.grep(data.variants,function(variant){return variant.id==pvariantid});vdata=vdata[0]}if(vdata.requires_shipping){var country=locations.country,province=locations.province,price=vdata.price,weight=vdata.weight;var data=SPICESHIPPING.pstorage.get('sgpdata',phandle);if(!data){$.ajax({url:scriptHost+"/shippingrates/"+country+'/'+province+'/'+price+'/'+weight+'?shop='+shopName,type:"GET",dataType:'json',success:function(data){if(data.success){d11.resolve(data)}else{d11.reject()}}})}else{d11.resolve(data)}}else{spiceDiv.html('');d11.reject()}return d11.promise()};SPICESHIPPING.loadAsync=function(url){$.ajax({'url':url,'dataType':'script','cache':true,'success':$.noop})};SPICESHIPPING.onError=function(XMLHttpRequest,textStatus,msg){if(XMLHttpRequest.status>300&&typeof msg!=='undefined'){SPICESHIPPING.e(msg)}};SPICESHIPPING.storage={save:function(key,data,expiration){var expirationMS=expiration*60*1000;var record={value:JSON.stringify(data),timestamp:new Date().getTime()+expirationMS};window.localStorage.setItem(key,JSON.stringify(record));return data},get:function(key){var record=JSON.parse(window.localStorage.getItem(key));if(record==null){return false}return(new Date().getTime()record.timestamp){SPICESHIPPING.pstorage.remove(key);return false}if(typeof record[handle]=='undefined'){return false}return(new Date().getTime()0){sgcart=cart;if(spiceSetting.length==0||spiceSetting.is_active==='0'){d3.reject()}d3.resolve()}else if(SPICESHIPPING.checkPage('products')){d3.resolve()}else{SPICESHIPPING.callObserver();d3.reject()}d3.then(SPICESHIPPING.shippingRate);return d3.promise()};SPICESHIPPING.countryExists=function(address){var shopdata=SPICESHIPPING.storage.get('sgdata');if(typeof shopdata=="undefined"){return false}var countries=shopdata.shipping_zones.countries;if(countries.indexOf(address.country)>-1){return true}else{return false}};SPICESHIPPING.getCartShippingRatesForDestination=function(address){var d4=$.Deferred();var newAddress=(typeof address=='undefined')?sgaddress:address;if(SPICESHIPPING.countryExists(newAddress)){delete newAddress.city;zipErr='';var params={type:'GET',url:'/cart/shipping_rates.json',data:{'shipping_address':newAddress},dataType:'json',success:function(data,status,response){rates=data.shipping_rates;d4.resolve(rates,address)},error:function(XMLHttpRequest,textStatus,msg){var e=JSON.parse(XMLHttpRequest.responseText);if(typeof e.zip!=='undefined'){zipErr=e.zip}d4.resolve([],address)}};jQuery.ajax(params)}else{d4.resolve([],address)}return d4.promise()};SPICESHIPPING.e=function(msg){var srh,srm,sr,srt,sem;if(spiceSetting.tmt==1){srh='.spicegems-geoship-heading',srm='.spicegems-geoship-map',sr='.spicegems-geoship-rate-list',srt='.spicegems-geoship-rates-total',sem='.sg-error-message'}else{srh='.sg-shipping-rates-heading',srm='.sg-shipping-rates-maps',srt='.sg-shipping-rates-chooser',sem='.sg-error-message'}$(srh).text('Shipping rates');$(srm).remove();$(sr).remove();$(srt).remove();var c=$(sem);c.text(msg);c.show()};SPICESHIPPING.currencyFormat=function(num){var newcurrency=num.toFixed(2);var spiceCurrency=spiceSetting.currency;return spiceCurrency.replace(/ *\{{[^)]*\}}*/g,newcurrency)};SPICESHIPPING.getRateList={list1:function(rates){var sl=$('
');var sfr='';$.each(rates,function(k,v){var ri=$('
');var rl=$('');var rateprice=SPICESHIPPING.currencyFormat(parseFloat(v.price));if(sfr===''){sfr=parseFloat(v.price);ri.append('')}else{ri.append('')}if(spiceSetting.delivery_date==1&&v.delivery_date!==null){var ddate=new Date(v.delivery_date);var newdays=(v.delivery_days[0]===v.delivery_days[1])?v.delivery_days[0]:v.delivery_days[0]+'-'+v.delivery_days[1];rl.append(''+v.name+'('+newdays+' Days): ');rl.append(''+rateprice+'');rl.append(''+spiceSetting.delivery_txt+' '+monthNames[ddate.getMonth()]+' '+ddate.getDate()+','+ddate.getFullYear()+'')}else{rl.append(''+v.name+': ');rl.append(''+rateprice+'');rl.append('')}ri.append(rl);sl.append(ri)});return sl},list2:function(rates){var sl=$('
');var sfr='';$.each(rates,function(k,v){var ri=$('
');var rl=$('');var rateprice=SPICESHIPPING.currencyFormat(parseFloat(v.price));if(sfr===''){sfr=parseFloat(v.price);rl.append('')}else{rl.append('')}if(spiceSetting.delivery_date==1&&v.delivery_date!==null){var ddate=new Date(v.delivery_date);var newdays=(v.delivery_days[0]===v.delivery_days[1])?v.delivery_days[0]:v.delivery_days[0]+'-'+v.delivery_days[1];rl.append(''+v.name+'('+newdays+' Days): ');rl.append(''+rateprice+'');rl.append(''+spiceSetting.delivery_txt+' '+monthNames[ddate.getMonth()]+' '+ddate.getDate()+','+ddate.getFullYear()+'')}else{rl.append(''+v.name+': ');rl.append(''+rateprice+'');rl.append('')}ri.append(rl);sl.append(ri)});return sl},list3:function(rates){var sl=$('
');$.each(rates,function(k,v){var rl=$('');var rateprice=SPICESHIPPING.currencyFormat(parseFloat(v.price));rl.append(''+v.name+': ');rl.append(''+rateprice+'');rl.append('');sl.append(rl)});return sl}};SPICESHIPPING.generateMap={map1:function(address,rates){var b=$('
');var list=SPICESHIPPING.getRateList.list1(rates);if(spiceSetting.show_map==1){var c=$('
');var q='';q+=address.country?address.country+',':'';if(address.province){q+=address.province+','}q+=address.zip?address.zip:'';c.append('');b.append(c)}b.append(list);return b},map2:function(address,rates){var b='';if(spiceSetting.show_map==1){var b=$('
');var q='';q+=address.country?address.country+',':'';if(address.province){q+=address.province+','}q+=address.zip?address.zip:'';b.append('')}return b}};SPICESHIPPING.changeGrandTotal=function(v){var sprice=parseFloat(v.value);var gtotal=parseFloat(cartTotalPrice)+parseFloat(sprice);var formatedSprice=SPICESHIPPING.currencyFormat(sprice);var formatedTotal=SPICESHIPPING.currencyFormat(gtotal);$(v).parents().find('.sg-cart-money-shipping').html(formatedSprice);$(v).parents().find('.sg-cart-money-total').html(formatedTotal)};SPICESHIPPING.generateRateTotalBlock=function(rates){var t=$('
');var sp=parseFloat(sgcart.items_subtotal_price);var sfr='';$.each(rates,function(k,v){if(sfr===''){sfr=parseFloat(v.price)}});cartTotalPrice=sp/100;t.append('
'+spiceSetting.subtotal+''+SPICESHIPPING.currencyFormat(sp/100)+'
');t.append('
'+spiceSetting.shipping_text+''+SPICESHIPPING.currencyFormat(sfr)+'
');t.append('
'+spiceSetting.total_text+' '+SPICESHIPPING.currencyFormat(sp/100+sfr)+'
');return t};SPICESHIPPING.generateRateBlock={block1:function(rates){var d=$('
');var t=$('
');var sp=parseFloat(sgcart.items_subtotal_price);var sfr='';$.each(rates,function(k,v){if(sfr===''){sfr=parseFloat(v.price)}});cartTotalPrice=sp/100;t.append('
'+spiceSetting.subtotal+''+SPICESHIPPING.currencyFormat(sp/100)+'
');t.append('
'+spiceSetting.shipping_text+''+SPICESHIPPING.currencyFormat(sfr)+'
');t.append('
'+spiceSetting.total_text+' '+SPICESHIPPING.currencyFormat(sp/100+sfr)+'
');d.append(t);return d},block2:function(sgaddress,sgrates){var k=$('
');var j=$('
');if(sgrates.length>0){var m=SPICESHIPPING.generateMap.map2(sgaddress,sgrates);var r=SPICESHIPPING.getRateList.list2(sgrates);var t=SPICESHIPPING.generateRateTotalBlock(sgrates);var province=' ';if(typeof sgaddress.province==='undefined'||sgaddress.province===null){province=sgaddress.country}else{province=sgaddress.province+', '+sgaddress.country}j.append('

'+spiceSetting.shipp_rate_box_title+' '+province+'

');var e=$('');j.append(r);j.append(e);j.append(t)}else{var m='';j.append('

'+spiceSetting.shipp_rate_def_title+'

');if(SPICESHIPPING.countryExists(sgaddress)){if(sgaddress.zip==''||sgaddress.zip==null){var e=$('');j.append(e)}else if(zipErr.length>0){var t=$('
Zip Code '+sgaddress.zip+' '+zipErr[0]+'
');j.append(t);t.show()}}else{j.append('')}}k.append(m);k.append(j);return k}};SPICESHIPPING.generateHtml={tmpt1:function(){var bgcolor=(typeof spiceSetting.ship_rate_box_color!=='undefined')?'style="background-color:'+spiceSetting.ship_rate_box_color:'';var a=$('
');var j=$('
');if(sgrates.length>0){var m=SPICESHIPPING.generateMap.map1(sgaddress,sgrates);var r=SPICESHIPPING.generateRateBlock.block1(sgrates);var province=' ';if(typeof sgaddress.province==='undefined'||sgaddress.province===null){province=sgaddress.country}else{province=sgaddress.province+', '+sgaddress.country}j.append('

'+spiceSetting.shipp_rate_box_title+' '+province+'

');var e=$('')}else{j.append('

'+spiceSetting.shipp_rate_def_title+'

');if(sgaddress.zip==''||sgaddress.zip==null){var e=$('
')}else if(zipErr.length>0){var e=$('
Zip Code '+sgaddress.zip+' '+zipErr[0]+'.
').css('display','block')}}j.append(m);j.append(r);a.append(j);j.after(e);return a},tmpt2:function(){var a=$('
');var j=SPICESHIPPING.generateRateBlock.block2(sgaddress,sgrates);var f=SPICESHIPPING.generateForm('spicegems-geoship',sgrates);a.append(j);a.append(f);return a},ptmpt:function(rates){var a=$('
');if(rates.length>0){var k=$('
');var province=' ';if(typeof sgaddress.province==='undefined'||sgaddress.province===null){province=sgaddress.country}else{province=sgaddress.province+', '+sgaddress.country}k.append('

'+spiceSetting.shipp_rate_product_title+' '+province+'

');var l=SPICESHIPPING.getRateList.list3(rates);k.append(l)}a.append(k);return a}};SPICESHIPPING.changeProvinces=function(c,l){var r=$(c).parent().find('.sg-region-select');var C=$(c).val();r.html('');var provinces=shippingZones.provinces;var selectedProvince1=provinces[C];if(selectedProvince1.length>0){selectedProvince=JSON.parse(selectedProvince1);selectedProvince.sort();if(selectedProvince.length>0){r.show();$.each(selectedProvince,function(k,v){if(sgaddress.province===v){g=v;r.append('')}else{r.append('')}})}else{r.hide()}}else{r.hide()}};SPICESHIPPING.showAddressForm=function(a){if(spiceSetting.tmt==1){$(a).parent().parent().find('.spicegems-geoship-address-chooser').slideToggle();$('.spicegems-geoship-address .chevron').toggleClass("chevron-rotate")}else{$(a).parent().parent().find('.sg-shipping-address-chooser').slideToggle()}};SPICESHIPPING.generateForm=function(className,rates){var countries=shippingZones.countries;if(countries.length>0){var zipCode=(sgaddress.zip==''||sgaddress.zip==null)?'':sgaddress.zip;var a=$('
');var b=$('
');var borderColor={'border-color':spiceSetting.color_scheme};var c=(zipCode==''||zipErr.length>0||!SPICESHIPPING.countryExists(sgaddress)||rates.length==0)?$('
'):$('
');var e=$('');var f=$('');e.css(borderColor);f.css(borderColor);var g='';var province=' ';if(typeof sgaddress.province==='undefined'||sgaddress.province===null){province=sgaddress.country}else{province=sgaddress.province+', '+sgaddress.country}if(!SPICESHIPPING.countryExists(sgaddress)||rates.length==0){b.append('Available Shipping Zones')}else{b.append(''+spiceSetting.change_loct_text+' '+province+'?')}$.each(countries,function(k,v){if(sgaddress.country===v){e.append('')}else{e.append('')}});c.append(e);c.append(f);SPICESHIPPING.changeProvinces(e,f);c.append('');c.append('');a.append(b);a.append(c);return a}};SPICESHIPPING.appendShpping=function(rates,address){var d5=$.Deferred();sgrates=rates;cartPage=SPICESHIPPING.checkIsCartPage();if(cartPage){if(spiceSetting.tmt==1){var maprate=SPICESHIPPING.generateHtml.tmpt2()}else{var maprate=SPICESHIPPING.generateHtml.tmpt1();var sgform=SPICESHIPPING.generateForm('sg-shipping',rates)}if(spiceDiv.length>0){spiceDiv.append(maprate);if(spiceSetting.tmt==0){spiceDiv.append(sgform)}}else if(spiceSetting.auto_install==1){var spd=$('
0){var province=' ';var frmheading='';if(typeof sgaddress.province==='undefined'||sgaddress.province===null){frmheading=spiceSetting.change_loct_text+' '+sgaddress.country+'?'}else{province=sgaddress.province+', ';frmheading=spiceSetting.change_loct_text+' '+province+sgaddress.country+'?'}$('.sg-location').text(frmheading);if(spiceSetting.tmt==1){var rateBlock=$('.spicegems-geoship-rates');var mapBlock=$('.spicegems-geoship-map');mapBlock.remove();rateBlock.html('');var map=SPICESHIPPING.generateMap.map2(sgaddress,sgrates);var r=SPICESHIPPING.getRateList.list2(sgrates);var t=SPICESHIPPING.generateRateTotalBlock(sgrates);if(map!==''){map.insertBefore('.spicegems-geoship-rates')}rateBlock.html('

'+spiceSetting.shipp_rate_box_title+' '+province+sgaddress.country+'

');rateBlock.append(r);rateBlock.append('');rateBlock.append(t)}else{$(".sg-error-message").text('').hide();var mainBlock=$('.sg-shipping-rates');var mapBlock=$('.sg-map-rate-block');$('.sg-shipping-rates-maps').remove();var map=SPICESHIPPING.generateMap.map1(sgaddress,sgrates);var rates=SPICESHIPPING.generateRateBlock.block1(sgrates);mapBlock.html('');mapBlock.html('

'+spiceSetting.shipp_rate_box_title+' '+province+sgaddress.country+'

');mapBlock.append(map);mapBlock.append(rates)}d6.resolve()}else{if(spiceSetting.tmt==1){$('.spicegems-geoship-rate-list').remove();$('.spicegems-geoship-rates-total').remove();$('.spicegems-geoship-map').remove()}else{$('.sg-map-rate-block').html('');$('.sg-shipping-rates-maps').remove();$(".sg-error-message").text('').hide()}if(zipErr.length>0){SPICESHIPPING.e('Zip Code '+sgaddress.zip+' '+zipErr[0])}else{$('.sg-location').text('Available Shipping Zones')}$('.spicegems-geoship-heading').text(spiceSetting.shipp_rate_def_title);d6.reject()}m=false;return d6.promise()};SPICESHIPPING.getNewShipping=function(btn){var zipElement=$(btn).parent().find('.sg-zip-code');var zipCode=zipElement.val();if(zipCode==''){zipElement.css('border','solid red 2px');$('.sg-error-message').hide();return false}else{zipElement.css('border-color',spiceSetting.color_scheme)}$.when(SPICESHIPPING.getCart()).then(SPICESHIPPING.setCart).then(function(){var location={"country":$(btn).parent().find('.sg-country-select').val(),"province":$(btn).parent().find('.sg-region-select').val(),"zip":zipCode};SPICESHIPPING.storage.update('sgdata',location);$.when(SPICESHIPPING.getCartShippingRatesForDestination(location)).then(SPICESHIPPING.updateShippingData)})};SPICESHIPPING.blankSnippet=function(){var d7=$.Deferred();var sglocation=SPICESHIPPING.storage.get('sgdata');sglocation=sglocation.location;d7.resolve(sglocation);return d7.promise()};SPICESHIPPING.callOnQuntityUpdate=function(){$.when(SPICESHIPPING.getCart()).then(SPICESHIPPING.setCart).then(function(){$.when(SPICESHIPPING.blankSnippet()).then(SPICESHIPPING.getCartShippingRatesForDestination).then(SPICESHIPPING.updateShippingData).then(SPICESHIPPING.cartQuantityUpdate)})};SPICESHIPPING.cartQuantityUpdate=function(){var q=spiceSetting.cart_qty;var p=spiceSetting.qty_sel;$(q).one("change",function(){setTimeout(function(){SPICESHIPPING.callOnQuntityUpdate()},500)});$(p).one("click",function(){setTimeout(function(){SPICESHIPPING.callOnQuntityUpdate()},500)})};SPICESHIPPING.callObserver=function(){var d14=$.Deferred();var targetNodes;if($('form[action="/cart"] div.cart__row').length>0){targetNodes=document.querySelector('form[action="/cart"] div.cart__row')}else if($('form[action="/cart"] div.cartitems').length>0){targetNodes=document.querySelector('form[action="/cart"] div.cartitems')}else if($('form[action="/cart"] div.CartItem').length>0){targetNodes=document.querySelector('form[action="/cart"] div.CartItem')}else if($('form[action="/cart"] div.cart-item').length>0){targatNodes=document.querySelector('form[action="/cart"] div.cart-item')}else if($('form[action="/cart"] tr.cart-item').length>0){targetNodes=document.querySelector('form[action="/cart"] tr.cart-item')}if(typeof targetNodes!=='undefined'&&spiceSetting.cart_qty==""){var config={attributes:true,childList:true,subtree:true,characterData:true};var observer=new MutationObserver(function(){if(m==false){m=true;SPICESHIPPING.callOnQuntityUpdate()}});observer.observe(targetNodes,config)}else{SPICESHIPPING.cartQuantityUpdate()}d14.resolve();d14.then(SPICESHIPPING.shippingRate);return d14.promise()};SPICESHIPPING.aj={appendAjaxCart:function(data){var d8=$.Deferred();var p=spiceSetting.add_after;setTimeout(function(){if($(p).length==0){SPICESHIPPING.aj.appendAjaxCart(data)}else{$(p).after(data);d8.resolve()}},500);return d8.promise()},loadAndSetInAjaxCart:function(rates){var d7=$.Deferred();if(typeof rates!='undefined'){sgrates=rates}if(sgcart.item_count>0){if(spiceSetting.tmt==1){var h=SPICESHIPPING.generateHtml.tmpt2()}else{var h=SPICESHIPPING.generateHtml.tmpt1();var sgFrom=SPICESHIPPING.generateForm('sg-shipping',rates)}var s='';if(spiceSetting.cart_type=="2"){s='spiceshippingappida'}else if(spiceSetting.cart_type=="3"){s='spiceshippingappidd'}if(s!=''){if($('#'+s).length>0){$('#'+s).html('');var a=$('#'+s);a.html(h);}else{var a=$('
');a.append(h)}if(spiceSetting.tmt==0){a.append(sgFrom)}d7.resolve(a)}else{d7.reject()}}else{d7.reject()}return d7.promise()},addToCartbtn:function(){m=false},setNewCartValue:function(cart){var d9=$.Deferred();sgcart=cart;if(sgcart.item_count>0){d9.resolve(sgaddress)}else{$('.sg_ajax_snip').remove();d9.reject()}return d9.promise()},updateAjaxData:function(){if(spiceSetting.length==0||spiceSetting.is_active=='1'){setTimeout(function(){$.when(SPICESHIPPING.getCart()).then(SPICESHIPPING.aj.setNewCartValue).then(SPICESHIPPING.getCartShippingRatesForDestination).then(SPICESHIPPING.aj.loadAndSetInAjaxCart).then(SPICESHIPPING.aj.appendAjaxCart).then(SPICESHIPPING.aj.addToCartbtn)},100)}},loadAjaxCartData:function(){if(spiceSetting.length==0||spiceSetting.is_active=='1'){setTimeout(function(){$.when(SPICESHIPPING.getCart()).then(SPICESHIPPING.aj.setNewCartValue).then(SPICESHIPPING.getCartShippingRatesForDestination).then(SPICESHIPPING.aj.loadAndSetInAjaxCart).then(SPICESHIPPING.aj.appendAjaxCart).then(SPICESHIPPING.aj.addToCartbtn).then(SPICESHIPPING.aj.quantityUpdater)},500)}},quantityUpdater:function(){var q=spiceSetting.ajax_qty;$(q).one('click',function(){SPICESHIPPING.aj.loadAjaxCartData()})},drawerPopObserver:function(){if(typeof spiceSetting.ob_block=='undefined'||spiceSetting.cart_type==1||spiceSetting.ob_block==''){return false}var targetNodes=document.querySelector(spiceSetting.ob_block);if(targetNodes==null){return false}var config={attributes:true,childList:true,subtree:true,characterData:true};var observer=new MutationObserver(function(mutations){var form=$(spiceSetting.ob_block).closest('form[action="/cart"]');if(form.length==0){form=$(spiceSetting.ob_block).find('form[action="/cart"]')}setTimeout(function(){var attr=form.attr('data-sg-form-status');if(typeof attr==='undefined'){for(let mutation of mutations){var shop_name=Shopify.theme.name;if((mutation.addedNodes.length>1||form.length>0)&&m==false){m=true;SPICESHIPPING.aj.loadAjaxCartData();if(form.length>0){form.attr('data-sg-form-status','processed')}break}}}},500)});observer.observe(targetNodes,config);return true}};SPICESHIPPING.checkIsCartPage=function(){var cartShopUrl=window.location.href;var shopUrlSplit=cartShopUrl.split('/');var is_cart=shopUrlSplit[3];if(typeof is_cart!=='undefined'&&is_cart.indexOf("cart")!==-1){return true}else{return false}};SPICESHIPPING.checkPage=function(pageTitle){var pageShopUrl=window.location.href;var shopUrlSplit=pageShopUrl.split('/');if(typeof shopUrlSplit!=='undefined'&&shopUrlSplit.indexOf(pageTitle)!==-1){return true}else{return false}};SPICESHIPPING.appendProductPage=function(rates){var d13=$.Deferred();SPICESHIPPING.pstorage.save('sgpdata',phandle,rates,60);if(spiceDiv.length>0){spiceDiv.html('');var a=SPICESHIPPING.generateHtml.ptmpt(rates.shipping_rates);spiceDiv.append(a)}d13.resolve();return d13.promise()};SPICESHIPPING.shippingRate=function(){var d15=$.Deferred();if(spiceSetting.length==0||spiceSetting.is_active==='0'){d15.reject()}else{if(SPICESHIPPING.checkPage('products')){$.when(SPICESHIPPING.getProductHandle()).then(SPICESHIPPING.getProductData).then(SPICESHIPPING.getProductShipping).then(SPICESHIPPING.appendProductPage)}d15.resolve()}return d15.promise()};SPICESHIPPING.showShipping=function(){spiceDiv=$('#spiceshippingappid');SPICESHIPPING.getForm();SPICESHIPPING.addCustomCss(spiceCss);SPICESHIPPING.loadAsync("https://maps.googleapis.com/maps/api/js?key=AIzaSyBQ9znCSYMbz73ubZ00hIA6dUnVhA3I92g");$.when(SPICESHIPPING.getShippingData(),SPICESHIPPING.getCart(),SPICESHIPPING.aj.drawerPopObserver()).then(SPICESHIPPING.getUserLocation).then(SPICESHIPPING.getCartShippingRatesForDestination).then(SPICESHIPPING.appendShpping).then(SPICESHIPPING.callObserver);$(window).on('change',function(){SPICESHIPPING.shippingRate()})};SPICESHIPPING.checkJqueryLoad=function(){var headTag=document.getElementsByTagName("head")[0];var scriptTag=document.createElement("script");scriptTag.type="text/javascript";if(typeof jQuery==='undefined'){scriptTag.src="https://cdn.jsdelivr.net/combine/npm/jquery@3.3.1/dist/jquery.min.js,npm/bootstrap@3.3.7/dist/js/bootstrap.js"}else{scriptTag.src="https://cdn.jsdelivr.net/combine/npm/bootstrap@3.3.7/dist/js/bootstrap.js"}scriptTag.onload=SPICESHIPPING.showShipping;headTag.appendChild(scriptTag)};if(document.readyState==="complete"||(document.readyState!=="loading"&&!document.documentElement.doScroll)){SPICESHIPPING.checkJqueryLoad()}else{document.addEventListener("DOMContentLoaded",SPICESHIPPING.checkJqueryLoad)}};SPICESHIPPING.checkIsCartPage=function(){var cartShopUrl=window.location.href;var shopUrlSplit=cartShopUrl.split('/');var is_cart=shopUrlSplit[3];if(typeof is_cart!=='undefined'&&is_cart.indexOf("cart")!==-1){return true}else{return false}};(function(){if(window.spiceShippingScript===true){return false}window.spiceShippingScript=true;SPICESHIPPING.SGShippingrules()})();