File "function - Copy-20241115045718-20241115100607.js"

Full Path: /home/krishnamexports/public_html/js/function - Copy-20241115045718-20241115100607.js
File size: 15.51 KB
MIME-type: text/plain; charset=us-ascii
Charset: utf-8

var baseUrl = "http://"+location.hostname+"/krishnam-exports/";

jQuery.fn.ForceNumericOnly =

function()

{

    return this.each(function()

    {

        $(this).keydown(function(e)

        {

            var key = e.charCode || e.keyCode || 0;			

            // allow backspace, tab, delete, enter, arrows, numbers and keypad numbers ONLY

            // home, end, period, and numpad decimal

            return (

                key == 8 || 

                key == 9 ||

                key == 13 ||

                key == 46 ||

                key == 110 ||

                //key == 190 ||

                (key >= 35 && key <= 40) ||

                (key >= 48 && key <= 57) ||

                (key >= 96 && key <= 105));

        });

    });

};

$(".regMobile").ForceNumericOnly();

$(".numberOnly").ForceNumericOnly();



$('.setCurrency').click(function(){

	$.blockUI({ message: '<h4><img src="'+baseUrl+'assets/img/busy.gif" /> Please Wait...</h4>' });

	var currencyType = $(this).data('currency');	 			

	$.ajax({

		url: baseUrl+"ajax/setCurrency.php?currencyType="+currencyType,

		type: 'GET',

		dataType: 'html',

		success: function (data) {			

			var data = $.parseJSON(data);

			if(data.status==1)

			{

				setTimeout(function(){location.reload();}, 1000);

			}			

		}

	});

});



$('#LoginCustomer').submit(function(e){	

		e.preventDefault();

		var mobile = $("#logMobile").val();

	 	if(mobile.length>9)

		{			

			$.ajax({

			url: baseUrl+"ajax/LoginCustomer.php",

			type: 'POST',

			data:$("#LoginCustomer").serialize(),

			dataType: 'html',

			success: function (data) {			

				var data = $.parseJSON(data);

				if(data.status==1)

				{				

					$("#ErrorReg2").html(data.SuccessMsg);					

					setTimeout(function(){ location.reload(); }, 2000);									

				}

				else if(data.status==2)

				{

					$("#ErrorReg2").html(data.ErrorMsg);										

					$("#logMobile").attr("readonly","readonly");	

					$(".otpBox2").show();

					$("#loginotp").val(data.otp);

					$("#loginotp").attr("required","required");

				}

				else if(data.status==3)

				{

					$("#ErrorReg2").html(data.ErrorMsg);																																											

				}								

			}

			});

		}

		else

		{

			alert("Enter Minimum 10 Digit.");	

		}

});



$('#RegisterCustomer').submit(function(e){	

		e.preventDefault();

		var mobile = $("#regMobile").val();

	 	if(mobile.length>9)

		{			

			$.ajax({

			url: baseUrl+"ajax/RegisterCustomer.php",

			type: 'POST',

			data:$("#RegisterCustomer").serialize(),

			dataType: 'html',

			success: function (data) {			

				var data = $.parseJSON(data);

				if(data.status==1)

				{				

					$("#ErrorReg").html(data.ErrorMsg);									

				}

				else if(data.status==2)

				{

					$("#ErrorReg").html('');										

					$("#regMobile").attr("readonly","readonly");	

					$(".otpBox").show();

					$("#signupotp").val(data.otp);

					$("#signupotp").attr("required","required");

				}

				else if(data.status==3)

				{

					$("#ErrorReg").html(data.ErrorMsg);																																											

				}				

				else if(data.status==4)

				{

					$("#ErrorReg").html(data.SuccessMsg);					

					setTimeout(function(){ window.location.href = baseUrl+"index.php"; }, 2000);

																																																																		

				}

				else if(data.status==5)

				{						

					$("#ErrorReg").html(data.ErrorMsg);																																											

				}

			}

			});

		}

		else

		{

			alert("Enter Minimum 10 Digit.");	

		}

});



$('.setPolish').click(function(){

	var polishId = $(this).val();		 

	$("#polish_id").val(polishId);		

});



$('.setSize').change(function(){

	var sizeId = $(this).val();		 

	$("#size_id").val(sizeId);		

});



/*$('.setStone').change(function(){

	var stoneId = $(this).val();		 

	$("#stone_id").val(stoneId);		

});*/



$('.addtoCart').click(function(){

	var productId = $(this).data('id');		

	var qty       = $("#qty").val();  

	var polishId  = $("#polish_id").val();

	var sizeId    = $("#size_id").val();	

	$(".addtoCart").html('<i class="fa fa-spinner fa-spin"></i> LOADING');

	$(".addtoCart").attr('Disabled','Disabled');

	$.blockUI({ message: '<h4><img src="'+baseUrl+'assets/img/busy.gif" /> Please Wait...</h4>' });		 				

	$.ajax({		

		url: baseUrl+"ajax/addtoCart.php?productId="+productId+"&qty="+qty+"&polishId="+polishId+"&sizeId="+sizeId,

		type: 'GET',

		dataType: 'html',

		success: function (data) {			

			var data = $.parseJSON(data);

			if(data.status==1 || data.status==2 || data.status==3 || data.status==4)

			{				

				$(".addtoCart").html('ADD TO WISHLIST');

				$(".addtoCart").removeAttr('Disabled');

				$("#warning").html(data.msg);

				$.unblockUI();

				warningNotification();															

			}

			else if(data.status==0)

			{				

				$(".addtoCart").html('ADDED TO WISHLIST');

				$(".addtoCart").removeAttr('Disabled');

				$("#success").html(data.msg);				

				$(".miniCart").html('');

				$.each(data.productList, function(idx, obj) {					

					$(".miniCart").append('<li class="minicart-item"><div class="minicart-thumb"><a href="'+baseUrl+'product/'+obj.productSlugURL+'"><img src="'+baseUrl+'products/'+obj.productPhoto+'" alt="product"></a></div><div class="minicart-content"><h3 class="product-name"><a href="product-details.html">'+obj.productName+'</a></h3><p><span class="cart-quantity">Qty - '+obj.qty+'</p></div><button class="minicart-remove removeToCart" data-productId="'+obj.productId+'" data-polishId="'+obj.polishId+'" data-sizeId="'+obj.sizeId+'"><i class="pe-7s-close"></i></button></li>');

				});

				$(".productCount").html(data.productCount);													

				$(".miniCartTotal").html('');						

				//$(".miniCartTotal").html('<li><span><strong>Sub Total</strong></span><span><strong>'+data.subTotal+'</strong></span></li><li><span><strong>Delivery Charges</strong></span><span><strong>'+data.deliveryCharges+'</strong></span></li><li class="total"><span><strong>Total</strong></span><span><strong>'+data.orderTotal+'</strong></span></li>');						

				$(".minicart-button").html('<a href="'+baseUrl+'cart"><i class="fa fa-shopping-cart"></i> View WishList</a><a href="'+baseUrl+'checkout" class="processCheckout"><i class="fa fa-share"></i> Checkout</a>');

				$.unblockUI();

				successNotification();

				$.getScript( baseUrl+"js/function.js" ).done(function( script, textStatus ) {

					console.log( textStatus );

				});																		

			}			

		}

	});

});



$('.addtoCartBulk').click(function(){		

	$(".addtoCartBulk").html('<i class="fa fa-spinner fa-spin"></i> LOADING');

	$(".addtoCartBulk").attr('Disabled','Disabled');

	$.blockUI({ message: '<h4><img src="'+baseUrl+'assets/img/busy.gif" /> Please Wait...</h4>' });		 				

	$.ajax({		

		url: baseUrl+"ajax/addtoCartBulk.php",

		type: 'POST',

		data:$("#addBulkOrder").serialize(),

		dataType: 'html',

		cache: true,

		success: function (data) {			

			var data = $.parseJSON(data);

			if(data.status==1 || data.status==2 || data.status==3 || data.status==5)

			{				

				$(".addtoCartBulk").html('ADD TO WISHLIST');

				$(".addtoCartBulk").removeAttr('Disabled');

				$("#warning").html(data.msg);

				$.unblockUI();

				warningNotification();															

			}

			else if(data.status==4)

			{				

				$(".addtoCartBulk").html('ADDED TO WISHLIST');

				$(".addtoCartBulk").removeAttr('Disabled');

				$("#success").html(data.msg);				

				$(".miniCart").html('');

				$.each(data.productList, function(idx, obj) {					

					$(".miniCart").append('<li class="minicart-item"><div class="minicart-thumb"><a href="'+baseUrl+'product/'+obj.productSlugURL+'"><img src="'+baseUrl+'products/'+obj.productPhoto+'" alt="product"></a></div><div class="minicart-content"><h3 class="product-name"><a href="product-details.html">'+obj.productName+'</a></h3><p><span class="cart-quantity">Qty - '+obj.qty+'</p></div><button class="minicart-remove removeToCart" data-productId="'+obj.productId+'" data-polishId="'+obj.polishId+'" data-sizeId="'+obj.sizeId+'"><i class="pe-7s-close"></i></button></li>');

				});

				$(".productCount").html(data.productCount);													

				$(".miniCartTotal").html('');

				//$(".miniCartTotal").html('<li><span><strong>Sub Total</strong></span><span><strong>'+data.subTotal+'</strong></span></li><li><span><strong>Delivery Charges</strong></span><span><strong>'+data.deliveryCharges+'</strong></span></li><li class="total"><span><strong>Total</strong></span><span><strong>'+data.orderTotal+'</strong></span></li>');						

				$(".minicart-button").html('<a href="'+baseUrl+'cart"><i class="fa fa-shopping-cart"></i> View WishList</a><a href="'+baseUrl+'checkout" class="processCheckout"><i class="fa fa-share"></i> Checkout</a>');

				$.unblockUI();

				successNotification();

				$.getScript( baseUrl+"js/function.js" ).done(function( script, textStatus ) {

				  console.log( textStatus );

				});																		

			}	

			else if(data.status==0)

			{				

				$(".addtoCartBulk").html('ADDED TO CART');

				$(".addtoCartBulk").removeAttr('Disabled');

				$("#success").html(data.msg);				

				$(".miniCart").html('');

				$.each(data.productList, function(idx, obj) {					

					$(".miniCart").append('<li class="minicart-item"><div class="minicart-thumb"><a href="'+baseUrl+'product/'+obj.productSlugURL+'"><img src="'+baseUrl+'products/'+obj.productPhoto+'" alt="product"></a></div><div class="minicart-content"><h3 class="product-name"><a href="product-details.html">'+obj.productName+'</a></h3><p><span class="cart-quantity">Qty - '+obj.qty+'</p></div><button class="minicart-remove removeToCart" data-productId="'+obj.productId+'" data-polishId="'+obj.polishId+'" data-sizeId="'+obj.sizeId+'"><i class="pe-7s-close"></i></button></li>');

				});

				$(".productCount").html(data.productCount);													

				$(".miniCartTotal").html('');

				//$(".miniCartTotal").html('<li><span><strong>Sub Total</strong></span><span><strong>'+data.subTotal+'</strong></span></li><li><span><strong>Delivery Charges</strong></span><span><strong>'+data.deliveryCharges+'</strong></span></li><li class="total"><span><strong>Total</strong></span><span><strong>'+data.orderTotal+'</strong></span></li>');						

				$(".minicart-button").html('<a href="'+baseUrl+'cart"><i class="fa fa-shopping-cart"></i> View WishList</a><a href="'+baseUrl+'checkout" class="processCheckout"><i class="fa fa-share"></i> Checkout</a>');

				$.unblockUI();

				successNotification();

				$.getScript( baseUrl+"js/function.js" ).done(function( script, textStatus ) {

				  console.log( textStatus );

				});																	

			}			

		}

	});

});



$('.removeToCart').click(function(){

	var productId = $(this).attr("data-productId");//$(this).data('productId');		  

	var polishId  = $(this).attr("data-polishId");//$(this).data('polishId');

	var sizeId    = $(this).attr("data-sizeId");//$(this).data('sizeId');		

	$.blockUI({ message: '<h4><img src="'+baseUrl+'assets/img/busy.gif" /> Please Wait...</h4>' });		 			

	$.ajax({

		url: baseUrl+"ajax/removeToCart.php?productId="+productId+"&polishId="+polishId+"&sizeId="+sizeId,

		type: 'GET',

		dataType: 'html',

		success: function (data) {			

			var data = $.parseJSON(data);

			if(data.status==1 || data.status==2 || data.status==3 || data.status==4)

			{				

				$(".addtoCart").html('ADD TO WISHLIST');

				$(".addtoCart").removeAttr('Disabled');

				$("#warning").html(data.msg);

				$.unblockUI();

				warningNotification();															

			}

			else if(data.status==0)

			{								

				$("#success").html(data.msg);				

				$(".miniCart").html('');

				$.each(data.productList, function(idx, obj) {					

					$(".miniCart").append('<li class="minicart-item"><div class="minicart-thumb"><a href="'+baseUrl+'product/'+obj.productSlugURL+'"><img src="'+baseUrl+'products/'+obj.productPhoto+'" alt="product"></a></div><div class="minicart-content"><h3 class="product-name"><a href="product-details.html">'+obj.productName+'</a></h3><p><span class="cart-quantity">Qty - '+obj.qty+'</p></div><button class="minicart-remove removeToCart" data-productId="'+obj.productId+'" data-polishId="'+obj.polishId+'" data-sizeId="'+obj.sizeId+'"><i class="pe-7s-close"></i></button></li>');

				});

				$(".productCount").html(data.productCount);	

				if(data.productList.length>0)

				{

					//$(".miniCartTotal").html('<li><span><strong>Sub Total</strong></span><span><strong>'+data.subTotal+'</strong></span></li><li><span><strong>Delivery Charges</strong></span><span><strong>'+data.deliveryCharges+'</strong></span></li><li class="total"><span><strong>Total</strong></span><span><strong>'+data.orderTotal+'</strong></span></li>');						

					$(".miniCartTotal").html('');

					$(".minicart-button").html('<a href="'+baseUrl+'cart"><i class="fa fa-shopping-cart"></i> View Wishlist</a><a href="'+baseUrl+'checkout" class="processCheckout"><i class="fa fa-share"></i> Checkout</a>');	

				}

				else

				{

					$(".miniCart").append('<div class="empty-cart"><img src="'+baseUrl+'assets/img/icon/empty-cart.png"><p>There is no Product in your cart</p></div>');

					$(".miniCartTotal").html('');						

					$(".minicart-button").html('<a href="'+baseUrl+'"><i class="fa fa-shopping-cart"></i> Continue Shopping</a>');	

				}				

				$.unblockUI();

				successNotification();

				$.getScript( baseUrl+"js/function.js" ).done(function( script, textStatus ) {

				  console.log( textStatus );

				});																

			}			

		}

	});

});



$('.processCheckout').click(function(){

	//e.preventDefault();

	var adRemark = [];	

	$("input[name='additionInfo[]']").each(function () {

		//alert($(this).val());

		adRemark.push($(this).val());

	})

	var additionalInfo = adRemark.join("/");

	$.blockUI({ message: '<h4><img src="'+baseUrl+'assets/img/busy.gif" /> Please Wait...</h4>' });		 			

	$.ajax({

		url: baseUrl+"ajax/checkLogin.php?additionalInfo="+additionalInfo,

		type: 'GET',

		dataType: 'html',

		success: function (data) {			

			var data = $.parseJSON(data);

			if(data.status==1)

			{				

				setTimeout(function(){ window.location.href = baseUrl+"checkout";}, 1000);

			}

			else if(data.status==2)

			{

				$.unblockUI();				

				$('#modalRegisterForm').modal('show');	

			}

		}

	});

});



$('#placeOrder').submit(function(e){	

	e.preventDefault();

	$.blockUI({ message: '<h4><img src="'+baseUrl+'assets/img/busy.gif" /> Please Wait...</h4>' });	

	$.ajax({

		url: baseUrl+"ajax/placeOrder.php",

		type: 'POST',

		data:$("#placeOrder").serialize(),

		dataType: 'html',

		success: function (data){			

				var data = $.parseJSON(data);

				//alert(data.status);

				if(data.status==true)

				{													

					setTimeout(function(){ window.location.href = baseUrl+"thank-you.php?orderId="+data.orderId;}, 2000);									

				}	

				else

				{					

					setTimeout(function(){ window.location.href = baseUrl+"checkout";}, 2000);						

				}

			}

		});

});



function warningNotification() {

  var x = document.getElementById("warning");

  x.className = "show";

  setTimeout(function(){ x.className = x.className.replace("show", ""); }, 4000);

}



function successNotification() {

  var x = document.getElementById("success");

  x.className = "show";

  setTimeout(function(){ x.className = x.className.replace("show", ""); }, 4000);

}