/
home
/
sjslayjy
/
public_html
/
theweavenest
/
public
/
js
/
Upload File
HOME
function change_product_color_image(img,color){ jQuery('#color_id').val(color); jQuery('.simpleLens-big-image-container').html('<a data-lens-image="'+img+'" class="simpleLens-lens-image"><img src="'+img+'" class="simpleLens-big-image"></a>'); } function home_add_to_cart(id,size_str_id,color_str_id){ jQuery('#color_id').val(color_str_id); jQuery('#size_id').val(size_str_id); add_to_cart(id,size_str_id,color_str_id); } function add_to_cart(id,size_str_id,color_str_id){ jQuery('#add_to_cart_msg').html(''); var color_id=jQuery('#color_id').val(); var size_id=jQuery('#size_id').val(); if(size_str_id==0){ size_id='no'; } if(color_str_id==0){ color_id='no'; } if(size_id=='' && size_id!='no'){ jQuery('#add_to_cart_msg').html('<div class="alert alert-danger fade in alert-dismissible mt10"><a href="#" class="close" data-dismiss="alert" aria-label="close" title="close">×</a>Please select size</div>'); }else if(color_id=='' && color_id!='no'){ jQuery('#add_to_cart_msg').html('<div class="alert alert-danger fade in alert-dismissible mt10"><a href="#" class="close" data-dismiss="alert" aria-label="close" title="close">×</a>Please select color</div>'); }else{ jQuery('#product_id').val(id); jQuery('#pqty').val(jQuery('#qty').val()); jQuery.ajax({ url:'/add_to_cart', data:jQuery('#frmAddToCart').serialize(), type:'post', success:function(result){ var totalPrice=0; alert(' '+result.msg); if(result.totalItem==0){ jQuery('.aa-cart-notify').html('0'); jQuery('.aa-cartbox-summary').remove(); }else{ jQuery('.aa-cart-notify').html(result.totalItem); var html='<ul>'; jQuery.each(result.data, function(arrKey,arrVal){ totalPrice=parseInt(totalPrice)+(parseInt(arrVal.qty)*parseInt(arrVal.price)); html+='<li><a class="aa-cartbox-img" href="#"><img src="'+PRODUCT_IMAGE+'/'+arrVal.image+'" alt="img"></a><div class="media-heading"><h4><a href="#">'+arrVal.name+'</a></h4><p> '+arrVal.qty+' * Rs '+arrVal.price+'</p></div></li>'; }); } html+='<li><span class="aa-cartbox-total-title">Total</span><span class="aa-cartbox-total-price">Rs '+totalPrice+'</span></li>'; html+='</ul><a class="aa-cartbox-checkout aa-primary-btn" href="checkout">Checkout</a>'; console.log(html); jQuery('cartBox').html(html); } }); } } function deleteCartProduct(pid, size, color, attr_id) { jQuery('#color_id').val(color); jQuery('#size_id').val(size); jQuery('#qty').val(0); add_to_cart(pid, size, color); jQuery('#cart_box' + attr_id).hide(); // Alert to notify user of deletion } function updateQty(pid, size, color, attr_id, price) { jQuery('#color_id').val(color); jQuery('#size_id').val(size); var qty = jQuery('#qty' + attr_id).val(); jQuery('#qty').val(qty); add_to_cart(pid, size, color); jQuery('#total_price_' + attr_id).html('Rs ' + qty * price); } var isSubmitting = false; jQuery('#frmRegistration').submit(function(e){ e.preventDefault(); if (isSubmitting) { return; } jQuery('.field_error').html(''); jQuery('#btnRegistration').prop('disabled', true); isSubmitting = true; jQuery.ajax({ url: 'registration_process', data: jQuery('#frmRegistration').serialize(), type: 'post', success: function(result) { jQuery('#btnRegistration').prop('disabled', false); isSubmitting = false; if (result.status == "error") { jQuery.each(result.error, function(key, val) { jQuery('#' + key + '_error').html(val[0]); }); } else if (result.status == "success") { jQuery('#frmRegistration')[0].reset(); jQuery('#thank_you_msg').html(result.msg); } }, error: function() { jQuery('#btnRegistration').prop('disabled', false); // Re-enable the submit button in case of an error isSubmitting = false; // Reset form submission flag in case of an error } }); }); jQuery('#frmLogin').submit(function(e){ jQuery('#login_msg').html(""); e.preventDefault(); jQuery.ajax({ url:'/login_process', data:jQuery('#frmLogin').serialize(), type:'post', success:function(result){ if(result.status=="error"){ jQuery('#login_msg').html(result.msg); } if(result.status=="success"){ // Check if the current page is the checkout page if (window.location.pathname === '/checkout') { // Redirect to the checkout page window.location.href = '/checkout'; } else { // Redirect to the home page if not on the checkout page window.location.href = '/'; } // You can optionally reset the login form and display a thank you message here // jQuery('#frmLogin')[0].reset(); // jQuery('#thank_you_msg').html(result.msg); } } }); }); function forgot_password(){ jQuery('#popup_forgot').show(); jQuery('#popup_login').hide(); } function show_login_popup(){ jQuery('#popup_forgot').hide(); jQuery('#popup_login').show(); } jQuery('#frmForgot').submit(function(e){ jQuery('#forgot_msg').html("Please wait..."); e.preventDefault(); jQuery.ajax({ url:'/forgot_password', data:jQuery('#frmForgot').serialize(), type:'post', success:function(result){ console.log(result); jQuery('#forgot_msg').html(result.msg); } }); }); jQuery('#frmUpdatePassword').submit(function(e){ jQuery('#thank_you_msg').html("Please wait..."); jQuery('#thank_you_msg').html(""); e.preventDefault(); jQuery.ajax({ url:'/forgot_password_change_process', data:jQuery('#frmUpdatePassword').serialize(), type:'post', success:function(result){ console.log(result); jQuery('#frmUpdatePassword')[0].reset(); jQuery('#thank_you_msg').html(result.msg); } }); }); function applyCouponCode(){ jQuery('#coupon_code_msg').html(''); jQuery('#order_place_msg').html(''); var coupon_code=jQuery('#coupon_code').val(); if(coupon_code!=''){ jQuery.ajax({ type:'post', url:'/apply_coupon_code', data:'coupon_code='+coupon_code+'&_token='+jQuery("[name='_token']").val(), success:function(result){ console.log(result.status); if(result.status=='success'){ jQuery('.show_coupon_box').removeClass('hide'); jQuery('#coupon_code_str').html(coupon_code); jQuery('#total_price').html('INR '+result.totalPrice); jQuery('.apply_coupon_code_box').hide(); }else{ } jQuery('#coupon_code_msg').html(result.msg); } }); }else{ jQuery('#coupon_code_msg').html('Please enter coupon code'); } } function remove_coupon_code(){ jQuery('#coupon_code_msg').html(''); var coupon_code=jQuery('#coupon_code').val(); jQuery('#coupon_code').val(''); if(coupon_code!=''){ jQuery.ajax({ type:'post', url:'/remove_coupon_code', data:'coupon_code='+coupon_code+'&_token='+jQuery("[name='_token']").val(), success:function(result){ if(result.status=='success'){ jQuery('.show_coupon_box').addClass('hide'); jQuery('#coupon_code_str').html(''); jQuery('#total_price').html('INR '+result.totalPrice); jQuery('.apply_coupon_code_box').show(); }else{ } jQuery('#coupon_code_msg').html(result.msg); } }); } } function sort_by(){ var sort_by_value=jQuery('#sort_by_value').val(); jQuery('#sort').val(sort_by_value); jQuery('#categoryFilter').submit(); } function sort_price_filter(){ jQuery('#filter_price_start').val(jQuery('#skip-value-lower').html()); jQuery('#filter_price_end').val(jQuery('#skip-value-upper').html()); jQuery('#categoryFilter').submit(); } function setColor(color,type){ var color_str=jQuery('#color_filter').val(); if(type==1){ var new_color_str=color_str.replace(color+':',''); jQuery('#color_filter').val(new_color_str); }else{ jQuery('#color_filter').val(color+':'+color_str); jQuery('#categoryFilter').submit(); } jQuery('#categoryFilter').submit(); } document.getElementById('search_form').addEventListener('submit', function(event) { event.preventDefault(); // Prevent default form submission funSearch(); // Call search function }); // Search function function funSearch() { var search_str = jQuery('#search_str').val().trim(); // Trim whitespace if (search_str && search_str.length > 3) { var encodedSearchStr = encodeURIComponent(search_str); // Encode search string var url = '/search/' + encodedSearchStr; console.log('Redirecting to:', url); // Debugging: log the URL window.location.href = url; // Redirect to the search results page } else { alert("Please enter a search term longer than 3 characters."); // Alert for invalid input } } document.addEventListener('DOMContentLoaded', (event) => { // Debugging: Log all clicks on the document document.addEventListener('click', function(event) { console.log('Element clicked:', event.target); }); // Example: Ensure no event listeners are blocking the link click const productLinks = document.querySelectorAll('.product-thumb a'); productLinks.forEach(link => { link.addEventListener('click', function(event) { console.log('Link clicked:', this.href); // Ensure default behavior is not prevented // event.preventDefault(); // Comment out if this line exists }); }); }); // jQuery('#frmPlaceOrder').submit(function(e) { // e.preventDefault(); // Prevent the form from submitting normally // jQuery.ajax({ // url: '/place_order', // data: jQuery('#frmPlaceOrder').serialize(), // type: 'POST', // success: function(result) { // if (result.status === 'success') { // // Initiate the Razorpay payment // initiateRazorpayPayment(result.oid, result.amount); // } else { // alert('Error: ' + result.msg); // } // }, // error: function(xhr, status, error) { // alert('Error: ' + error); // } // }); // }); // this work // function initiateRazorpayPayment(orderId, amount) { // var options = { // key: 'rzp_test_DNg0mT7iFdPYTb', // Your Razorpay API key // amount: amount, // Amount in paise // currency: 'INR', // name: 'Your Company Name', // description: 'Order Payment', // image: 'https://example.com/logo.png', // Your company logo URL // order_id: orderId, // Razorpay order ID // handler: function(response) { // // Handle successful payment response here // alert('Payment successful! Payment ID: ' + response.razorpay_payment_id); // // Optionally, you can send the payment ID to your server for verification or further processing // }, // prefill: { // name: 'John Doe', // Default customer name // email: 'john@example.com', // Default customer email // contact: '7905938318' // Default customer contact number // }, // notes: { // address: 'Customer Address' // Additional notes, if any // }, // theme: { // color: '#3399cc' // Theme color // } // }; // var rzp = new Razorpay(options); // rzp.on('payment.failed', function(response) { // // Handle failed payment // alert('Payment failed: ' + response.error.description); // }); // // Open Razorpay checkout form // rzp.open(); // } jQuery('#frmPlaceOrder').submit(function(e) { e.preventDefault(); var paymentMethod = jQuery('input[name="payment_type"]:checked').val(); if (paymentMethod === 'Gateway') { jQuery.ajax({ url: '/place_order', data: jQuery('#frmPlaceOrder').serialize(), type: 'POST', success: function(result) { if (result.status === 'success') { initiateRazorpayPayment(result.oid, result.amount); } else { alert('Error: ' + result.msg); } }, error: function(xhr, status, error) { alert('Error: ' + error); } }); } else if (paymentMethod === 'COD') { jQuery.ajax({ url: '/place_order', data: jQuery('#frmPlaceOrder').serialize(), type: 'POST', success: function(result) { if (result.status === 'success') { window.location.href = "/order_placed"; } else { alert('Error: ' + result.msg); } }, error: function(xhr, status, error) { alert('Error: ' + error); } }); } else { alert('Please select a payment method'); } }); function initiateRazorpayPayment(orderId, amount) { var options = { key: 'rzp_test_DNg0mT7iFdPYTb', amount: amount, currency: 'INR', name: 'THE WEAVENEAST', description: 'Order Payment', image: 'https://example.com/logo.png', order_id: orderId, handler: function(response) { alert('Payment successful! Payment ID: ' + response.razorpay_payment_id); // Send the payment ID and order ID to the server jQuery.ajax({ url: '/update_payment_status', type: 'POST', data: { order_id: orderId, payment_id: response.razorpay_payment_id, _token: '{{ csrf_token() }}' }, headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' }, success: function(result) { window.location.href = '/order_placed'; if (result.status === 'success') { alert('Payment status updated successfully'); } else { alert('Error updating payment status: ' + result.msg); } }, error: function(xhr, status, error) { alert('Error: ' + error); } }); }, prefill: { name: 'John Doe', email: 'john@example.com', contact: '7905938318' }, notes: { address: 'Customer Address' }, theme: { color: '#3399cc' } }; var rzp = new Razorpay(options); rzp.on('payment.failed', function(response) { // Handle failed payment alert('Payment failed: ' + response.error.description); }); rzp.open(); } jQuery(function(){ if($('body').is('.productPage')){ var skipSlider = document.getElementById('skipstep'); var filter_price_start=jQuery('#filter_price_start').val(); var filter_price_end=jQuery('#filter_price_end').val(); if(filter_price_start=='' || filter_price_end==''){ var filter_price_start=100; var filter_price_end=1700; } noUiSlider.create(skipSlider, { range: { 'min': 0, '10%': 100, '20%': 300, '30%': 500, '40%': 700, '50%': 900, '60%': 1100, '70%': 1300, '80%': 1500, '90%': 1700, 'max': 1900 }, snap: true, connect: true, start: [filter_price_start, filter_price_end] }); // for value print var skipValues = [ document.getElementById('skip-value-lower'), document.getElementById('skip-value-upper') ]; skipSlider.noUiSlider.on('update', function( values, handle ) { skipValues[handle].innerHTML = values[handle]; }); } }); //REVEIW jQuery('#frmProductReview').submit(function(e){ //jQuery('#thank_you_msg').html("Please wait..."); //jQuery('#thank_you_msg').html(""); e.preventDefault(); jQuery.ajax({ url:'/product_review_process', data:jQuery('#frmProductReview').serialize(), type:'post', success:function(result){ if(result.status=="success"){ jQuery('.review_msg').html(result.msg); jQuery('#frmProductReview')[0].reset(); setInterval(function(){ window.location.href=window.location.href },3000); }if(result.status=="error"){ jQuery('.review_msg').html(result.msg) } //jQuery('#frmUpdatePassword')[0].reset(); //jQuery('#thank_you_msg').html(result.msg); } }); });