// ################################################################### // Powered by A&A Digital Agency (מקבוצת אלמיר מערכות תוכנה) // www.almir.co.il || info@almir.co.il // Developer : Albert Amir // Phone/Fax: +972 04-63-63-281 // Mobile: +972 0523731057 // ################################################################### var WebsiteDomain = "https://www.jewishshop.co.il"; function CreateDeleteLocalPickupBasket() { $.LoadingOverlay("show"); setTimeout(function(){ var data = ""; data+= "task=CreateDeleteLocalPickupBasket"; $.ajax({ type: "POST" , url: 'GlobalIncludes/_CLASS/class.basket.php' , data: data , async: false , cache: false , timeout: 5000 , dataType: 'text' , error: function() { return 'error'; }, success: function(Result) { $.LoadingOverlay("hide"); CallUpdateHTML(); CallHTMLBasketData(); return true; } }); }, 500); } function CreateLocalPickupBasket() { var ConfirmResult = confirm("האם אתם בטוחים שאתם מעוניינים לאסוף את המוצרים מהחנות ?"); if(ConfirmResult==true) { $.LoadingOverlay("show"); setTimeout(function(){ var data = ""; data+= "task=CreateLocalPickupBasket"; $.ajax({ type: "POST" , url: 'GlobalIncludes/_CLASS/class.basket.php' , data: data , async: false , cache: false , timeout: 5000 , dataType: 'text' , error: function() { return 'error'; }, success: function(Result) { $.LoadingOverlay("hide"); CallUpdateHTML(); CallHTMLBasketData(); return true; } }); }, 500); } } function CreateCheckCouponBasket(GetCouponCode) { var CouponCode = document.getElementById(GetCouponCode); if(CouponCode.value==''){ alert("לא רשמתם קוד קופון!"); CouponCode.focus(); return false; } var CouponCodelength = CouponCode.value, MinCouponCodelength = 6; if(CouponCodelength.length < MinCouponCodelength) { alert("קופון לא תקין והינו קצר."+"\n"+"קוד קופון צריך להיות לפחות "+MinCouponCodelength+" תווים."); return false; } $.LoadingOverlay("show"); setTimeout(function(){ var data = ""; data+= "task=CreateCheckCouponBasket"; data+= "&CouponCode="+CouponCode.value; $.ajax({ type: "POST" , url: 'GlobalIncludes/_CLASS/class.basket.php' , data: data , async: false , cache: false , timeout: 5000 , dataType: 'text' , error: function() { return 'error'; }, success: function(Result) { $.LoadingOverlay("hide"); if(Result.search("{NoneCoupon}")>0) { alert("לא קיים קופון זה או שהקופון זה נועד רק למוצר ספציפי שבאתר"); return false; } if(Result.search("{CouponExpire}")>0) { alert("קופון זה פג תודף"); return false; } if(Result.search("{CouponMinimumBuy}")>0) { var CouponMinimumBuy = Result.split("_"); alert("על מנת להשתמש בקופון זה יש לעשות קניות בסכום של "+CouponMinimumBuy[1]+" ₪ ומעלה"); return false; } if(Result.search("{OK}")>0) { CallUpdateHTML(); CallHTMLBasketData(); return true; } /* if(Result.search("{XXXX}")>0) { alert(""); return true; } */ } }); }, 500); } function CreateSaveExtras(GetExtraA,GetExtraB,GetStyle,GetCountField,GetPrice,GetId,GetProductName,GetPriceFor,GetImage) { if(document.getElementById(GetExtraA)){ if(document.getElementById(GetExtraA).value==''){ alert("נא לבחור אחת מהאפשרויות"); document.getElementById(GetExtraA).focus(); return false; } } if(document.getElementById(GetExtraB)){ if(document.getElementById(GetExtraB).value==''){ alert("נא לבחור אחת מהאפשרויות"); document.getElementById(GetExtraB).focus(); return false; } } document.getElementById("Extra_count_"+GetId).value--; ChangeBasket(GetStyle,GetCountField,GetPrice,GetId,GetProductName,GetPriceFor,GetImage); document.getElementById("count_"+GetId).value = document.getElementById("Extra_count_"+GetId).value; /* document.getElementById("Extra_count_"+GetId).value = 1; document.getElementById(GetExtraA).value = ""; document.getElementById(GetExtraB).value = ""; */ $("#ModalExtras"+GetId).modal("hide"); } function ChangeBasket(GetStyle,GetCountField,GetPrice,GetId,GetProductName,GetPriceFor,GetImage) { var quantity = document.getElementById(GetCountField); switch(GetStyle) { case "p": if(document.getElementById("ModalExtras"+GetId) && (document.getElementById("ModalExtras"+GetId).style.display=='none' || document.getElementById("ModalExtras"+GetId).style.display=='')) { if( (document.getElementById("ExtraA_"+GetId) && document.getElementById("ExtraA_"+GetId).value=='') || (document.getElementById("ExtraB_"+GetId) && document.getElementById("ExtraB_"+GetId).value=='') ){ $("#ModalExtras"+GetId).modal("show"); return false; } $("#ModalExtras"+GetId).modal("show"); return false; } if(GetPriceFor=='kg'){ quantity.value = Number(quantity.value)+0.5; } else { quantity.value++; } break; case "m": if(quantity.value<=0){ quantity.value = 0; return false; } if(GetPriceFor=='kg'){ quantity.value = Number(quantity.value)-0.5; } else { quantity.value--; } break; } $.LoadingOverlay("show"); setTimeout(function(){ var data = ""; data+= "task=UpdateBasket"; data+= "&quantity="+quantity.value; data+= "&price="+GetPrice; data+= "&name="+GetProductName; data+= "&price_for="+GetPriceFor; data+= "&image="+GetImage; data+= "&id="+GetId; if (document.getElementById("ExtraA_"+GetId) && document.getElementById("ExtraA_"+GetId).value!='') { data+= "&ExtraA="+document.getElementById("ExtraA_"+GetId).value; } if (document.getElementById("ExtraB_"+GetId) && document.getElementById("ExtraB_"+GetId).value!='') { data+= "&ExtraB="+document.getElementById("ExtraB_"+GetId).value; } $.ajax({ type: "POST" , url: 'GlobalIncludes/_CLASS/class.basket.php' , data: data , async: false , cache: false , timeout: 5000 , dataType: 'text' , error: function() { return 'error'; }, success: function(Result) { $.LoadingOverlay("hide"); } }); }, 500); setTimeout(function(){ CallUpdateHTML(); }, 500); } function CallDeleteProductFromBasket(GetId) { var ConfirmResult = confirm("להסיר מוצר מהעגלת הקניות?"); if(ConfirmResult==true) { var data = ""; data+= "task=CallDeleteProductFromBasket"; data+= "&id="+GetId; $.ajax({ type: "POST" , url: 'GlobalIncludes/_CLASS/class.basket.php' , data: data , async: false , cache: false , timeout: 5000 , dataType: 'text' , error: function() { return 'error'; }, success: function(Result) { if(document.getElementById("count_"+GetId)){ document.getElementById("count_"+GetId).value = "0"; } } }); CallUpdateHTML(); CallHTMLBasketData(); } } function CallHTMLBasketData() { var data = ""; data+= "task=CallHTMLBasketData"; $.ajax({ type: "POST" , url: 'GlobalIncludes/_CLASS/class.basket.php' , data: data , async: false , cache: false , timeout: 5000 , dataType: 'text' , /* (xml, json, script, text, html) */ error: function() { return 'error'; }, success: function(Result) { document.getElementById("HTMLBasketData").innerHTML = Result; } }); } $(window).on('shown.bs.modal', function() { CallHTMLBasketData(); }); function CallUpdateHTML() { var data = ""; data+= "task=CallUpdateHTML"; $.ajax({ type: "POST" , url: 'GlobalIncludes/_CLASS/class.basket.php' , data: data , async: false , cache: false , timeout: 5000 , dataType: 'text' , error: function() { return 'error'; }, success: function(Result) { var str = Result , Data = str.split("_"); if(document.getElementById("BasketCounter")){ document.getElementById("BasketCounter").innerHTML = Data[0]; } if(document.getElementById("BasketPrice")){ document.getElementById("BasketPrice").innerHTML = Data[1]; } if(document.getElementById("h-BasketCounter")){ document.getElementById("h-BasketCounter").innerHTML = Data[0]; } if(document.getElementById("h-BasketCounter-mobile")){ document.getElementById("h-BasketCounter-mobile").innerHTML = Data[0]; } } }); } function CreateOrderButton(GetFrm,PayBuy,PayAmount) { var Frm = document.getElementById(GetFrm); if(Frm.Fullname.value==''){ alert("הערה: חובה לרשום שם מלא"); Frm.Fullname.focus(); return false; } if(Frm.Mobile.value==''){ alert("הערה: חובה לרשום טלפון נייד"); Frm.Mobile.focus(); return false; } if(Frm.Mobile.value!='' && checkPhoneNumber(Frm.Mobile)==false){ alert("המספר אינו תקין"); Frm.Mobile.focus(); return false; } if(Frm.Email.value!='' && isValidEmailAddress(Frm.Email.value)==false){ alert("דואר אלקטרוני אינו תקין"); Frm.Email.focus(); return false; } if(Frm.ShippingStatus.value=='Shipping') { if(Frm.City.value==''){ alert("הערה: חובה לרשום עיר למשלוח"); Frm.City.focus(); return false; } if(Frm.Address.value==''){ alert("הערה: חובה לרשום כתובת מלאה למשלוח"); Frm.Address.focus(); return false; } } else if(Frm.ShippingStatus.value=='LocalPickup') { } if(PayBuy!='whatsapp'){ if(Frm.terms.checked==false){ alert("נא לאשר תקנון האתר"); return false; } } switch(PayBuy) { case "whatsapp": document.getElementById("payButtonWhatsApp").disabled = true; if(document.getElementById("payButtonPayPal")){ document.getElementById("payButtonPayPal").disabled = true; } if(document.getElementById("payButtonCreditCard")){ document.getElementById("payButtonCreditCard").disabled = true; } document.getElementById("payButtonWhatsApp").innerHTML = " מייצר הזמנה, אנה המתן..."; document.getElementById("payButtonWhatsAppBootstrap").className = "col-12"; if(document.getElementById("payButtonPayPalBootstrap")){ document.getElementById("payButtonPayPalBootstrap").style.display = 'none'; } if(document.getElementById("payButtonCreditCardBootstrap")){ document.getElementById("payButtonCreditCardBootstrap").style.display = 'none'; } break; case "paypal": if(document.getElementById("payButtonWhatsApp")){ document.getElementById("payButtonWhatsApp").disabled = true; } document.getElementById("payButtonPayPal").disabled = true; if(document.getElementById("payButtonCreditCard")){ document.getElementById("payButtonCreditCard").disabled = true; } document.getElementById("payButtonPayPal").innerHTML = " מייצר הזמנה, אנה המתן..."; if(document.getElementById("payButtonWhatsAppBootstrap")){ document.getElementById("payButtonWhatsAppBootstrap").style.display = 'none'; } document.getElementById("payButtonPayPalBootstrap").className = "col-12"; if(document.getElementById("payButtonCreditCardBootstrap")){ document.getElementById("payButtonCreditCardBootstrap").style.display = 'none'; } break; case "ccard": if(document.getElementById("payButtonWhatsApp")){ document.getElementById("payButtonWhatsApp").disabled = true; } if(document.getElementById("payButtonPayPal")){ document.getElementById("payButtonPayPal").disabled = true; } document.getElementById("payButtonCreditCard").disabled = true; document.getElementById("payButtonCreditCard").innerHTML = " מייצר הזמנה, אנה המתן..."; if(document.getElementById("payButtonWhatsAppBootstrap")){ document.getElementById("payButtonWhatsAppBootstrap").style.display = 'none'; } if(document.getElementById("payButtonPayPalBootstrap")){ document.getElementById("payButtonPayPalBootstrap").style.display = 'none'; } document.getElementById("payButtonCreditCardBootstrap").className = "col-12"; break; } var uniqNum = "f3727e93cf398ccd2a"; var data = ""; data+= "task=CreateOrder"; data+= "&Fullname="+Frm.Fullname.value; data+= "&Mobile="+Frm.Mobile.value; data+= "&Email="+Frm.Email.value; data+= "&City="+Frm.City.value; data+= "&Address="+Frm.Address.value; data+= "&Remark="+Frm.Remark.value; data+= "&uniqNum="+encodeURIComponent(uniqNum); $.ajax({ type: "POST" , url: 'GlobalIncludes/_CLASS/class.basket.php' , data: data , async: false , cache: false , timeout: 5000 , dataType: 'text' , error: function() { return 'error'; }, success: function(Result) { Result = trim(Result," "); switch(PayBuy) { case "whatsapp": var whatsapp_phone = "97239311091"; var location_href = "https://api.whatsapp.com/send?phone="+whatsapp_phone+"&text="+Result+"&source=&data="; window.location.href = location_href; break; case "paypal": var paypal_email = ""; var btn_return = encodeURIComponent(WebsiteDomain+"/ThanksPage.php"); var btn_cancel_return = ""; encodeURIComponent(WebsiteDomain+'/CancelPage.php'); var cbt = ""; // חזרה לחנות"; var location_href = "https://www.paypal.com/cgi-bin/webscr/"; location_href+= "?business="+paypal_email; location_href+= "&cmd=_xclick"; location_href+= "&item_name=תשלום מ"+Frm.Fullname.value+" עבור מס "+uniqNum; location_href+= "&amount="+PayAmount; location_href+= "¤cy_code=ILS"; location_href+= "&return="+btn_return; location_href+= "&cancel_return="+btn_cancel_return; //location_href+= "&cbt="+cbt; window.location.href = location_href; break; case "ccard": var pfsAuthCode = "98f657030dbc430cb07685060aa19f08"; var location_href = "PayPlusCreatePaymentPage.php"; location_href+= "?uniqNum="+uniqNum; location_href+= "&custom_invoice_name=תשלום מ"+Frm.Fullname.value+" עבור מס "+uniqNum; location_href+= "&amount="+PayAmount; location_href+= "&Fullname="+Frm.Fullname.value; location_href+= "&Email="+Frm.Email.value; location_href+= "&Mobile="+Frm.Mobile.value; location_href+= "&City="+Frm.City.value; location_href+= "&Address="+Frm.Address.value; window.location.href = location_href; break; } } }); }