Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard.
– OR –
var freeshipping = false;
var postcode = '37205'; var state = 'TN'; var country = 'US'; var city = 'Nashville'; var baddress = '4525 Harding Pike Suite 104'; if (jQuery('#shipping_method_extra_custom input[type="radio"]:checked').val() == 'local_pickup2') { jQuery('#shipping_state').val(state).change(); jQuery('#shipping_country').val(country).change(); jQuery('#shipping_postcode').val(postcode); jQuery('#shipping_address_1').val(baddress); jQuery('#shipping_city').val(city); jQuery('.woocommerce-shipping-fields__field-wrapper #shipping_postcode_field, .woocommerce-shipping-fields__field-wrapper #shipping_address_1_field, .woocommerce-shipping-fields__field-wrapper #shipping_city_field').attr('style','display:none !important;'); jQuery("#shipping_method input:radio").each(function(index, element) { var str1 = jQuery(this).val(); var str2 = 'local_pickup'; if(str1.indexOf(str2) != -1){ jQuery(this).trigger("click"); } else if(str1.indexOf('free_shipping') != -1 && freeshipping){ jQuery(this).trigger("click"); } }); jQuery("#shipping_method_third_step input:radio").each(function(index, element) { var str1 = jQuery(this).val(); var str2 = 'local_pickup'; if(str1.indexOf(str2) != -1){ jQuery(this).trigger("click"); } else if(str1.indexOf('free_shipping') != -1 && freeshipping){ jQuery(this).trigger("click"); } }); } else { jQuery('#shipping_state').val(''); jQuery('#shipping_postcode').val(''); jQuery('#shipping_address_1').val(''); jQuery('#shipping_city').val(''); jQuery('.woocommerce-shipping-fields__field-wrapper #shipping_postcode_field, .woocommerce-shipping-fields__field-wrapper #shipping_address_1_field, .woocommerce-shipping-fields__field-wrapper #shipping_city_field').attr('style','display:block !important;'); jQuery("#shipping_method input:radio").each(function(index, element) { var str1 = jQuery(this).val(); var str2 = 'flat_rate'; if(str1.indexOf(str2) != -1){ jQuery(this).trigger("click"); } else if(str1.indexOf('free_shipping') != -1 && freeshipping){ jQuery(this).trigger("click"); } }); jQuery("#shipping_method_third_step input:radio").each(function(index, element) { var str1 = jQuery(this).val(); var str2 = 'flat_rate'; if(str1.indexOf(str2) != -1){ jQuery(this).trigger("click"); } else if(str1.indexOf('free_shipping') != -1 && freeshipping){ jQuery(this).trigger("click"); } }); } jQuery('body').on('click','#shipping_method_extra_custom input[type="radio"]',function(){ if (jQuery(this).is(':checked') && jQuery(this).val() == 'local_pickup2') { jQuery('#shipping_state').val(state).change(); jQuery('#shipping_country').val(country).change(); jQuery('#shipping_postcode').val(postcode); jQuery('#shipping_address_1').val(baddress); jQuery('#shipping_city').val(city); jQuery('.woocommerce-shipping-fields__field-wrapper #shipping_postcode_field, .woocommerce-shipping-fields__field-wrapper #shipping_address_1_field, .woocommerce-shipping-fields__field-wrapper #shipping_city_field').attr('style','display:none !important;'); jQuery("#shipping_method input:radio").each(function(index, element) { var str1 = jQuery(this).val(); console.log(str1); var str2 = 'local_pickup'; if(str1.indexOf(str2) != -1){ console.log(str2); jQuery(this).trigger("click"); } else if(str1.indexOf('free_shipping') != -1 && freeshipping){ jQuery(this).trigger("click"); } }); jQuery("#shipping_method_third_step input:radio").each(function(index, element) { var str1 = jQuery(this).val(); console.log(str1); var str2 = 'local_pickup'; if(str1.indexOf(str2) != -1){ console.log(str2); jQuery(this).trigger("click"); } else if(str1.indexOf('free_shipping') != -1 && freeshipping){ jQuery(this).trigger("click"); } }); } else { jQuery('#shipping_state').val(''); jQuery('#shipping_postcode').val(''); jQuery('#shipping_address_1').val(''); jQuery('#shipping_city').val(''); jQuery('.woocommerce-shipping-fields__field-wrapper #shipping_postcode_field, .woocommerce-shipping-fields__field-wrapper #shipping_address_1_field, .woocommerce-shipping-fields__field-wrapper #shipping_city_field').attr('style','display:block !important;'); jQuery("#shipping_method input:radio").each(function(index, element) { var str3 = jQuery(this).val(); console.log(str3); var str4 = 'flat_rate'; if(str3.indexOf(str4) != -1){ console.log(str4); jQuery(this).trigger("click"); } else if(str1.indexOf('free_shipping') != -1 && freeshipping){ jQuery(this).trigger("click"); } }); jQuery("#shipping_method_third_step input:radio").each(function(index, element) { var str3 = jQuery(this).val(); console.log(str3); var str4 = 'flat_rate'; if(str3.indexOf(str4) != -1){ console.log(str4); jQuery(this).trigger("click"); } else if(str1.indexOf('free_shipping') != -1 && freeshipping){ jQuery(this).trigger("click"); } }); } });
jQuery('body').on('click','.step_1_email span.edit',function(){ jQuery('.step_1 .step').each(function(){ jQuery(this).removeClass('active');
}); jQuery('.col-2').addClass('active');
}); jQuery('body').on('click','.checkout_details .col-3 .nxt_step a.back_step_3',function(){ jQuery('.step_1 .step').each(function(){ jQuery(this).removeClass('active');
}); jQuery('.col-2').addClass('active'); });
jQuery('body').on('click','.col-2 .nxt_step a.third_step',function(){ var additional_email2 = jQuery('#billing_email').val();
var billing_first_name = jQuery('#billing_first_name').val(); var billing_last_name = jQuery('#billing_last_name').val(); var billing_phone = jQuery('#billing_phone').val(); var billing_address_1 = jQuery('#billing_address_1').val(); var billing_city = jQuery('#billing_city').val(); var billing_postcode = jQuery('#billing_postcode').val(); var additional_terms = jQuery('#billing_terms_conditions:checked').val(); var is_error = false;
if(additional_terms == undefined){ console.log(additional_terms); is_error = true; if(!jQuery('#billing_terms_conditions').parent().find('span.error').length) { jQuery('#billing_terms_conditions').parent().append('Please check terms and condition checkbox '); jQuery('#billing_terms_conditions').parents('p.form-row').addClass('woocommerce-invalid'); } else { jQuery('#billing_terms_conditions').parent().find('span.error').text('Please check terms and condition checkbox'); jQuery('#billing_terms_conditions').parent().find('span.error').show(); } } else { jQuery('#billing_terms_conditions').parent().find('span.error').hide(); }
if(jQuery('#account_password').val() == '' ){ console.log(1); is_error = true; jQuery('#create-account span.error').attr('style','display:block !important;'); } else { jQuery('#create-account span.error').hide(); }
if(jQuery('#billing_first_name').val() == ''){ is_error = true; if(!jQuery('#billing_first_name').parent().find('span.error').length) { jQuery('#billing_first_name').parent().append('Please enter first name'); jQuery('#billing_first_name').parents('p.form-row').addClass('woocommerce-invalid'); } else { jQuery('#billing_first_name').parent().find('span.error').text('Please enter first name'); jQuery('#billing_first_name').parent().find('span.error').show(); } } else { jQuery('#billing_first_name').parent().find('span.error').hide(); }
if(additional_email2 == ''){ is_error = true; if(!jQuery('#billing_email').parent().find('span.error').length) { jQuery('#billing_email').parent().append('Please enter email'); jQuery('#billing_email').parents('p.form-row').addClass('woocommerce-invalid'); } else { jQuery('#billing_email').parent().find('span.error').show(); } } else { if(!isEmail(additional_email2)) { is_error = true; if(!jQuery('#billing_email').parent().find('span.error').length) { jQuery('#billing_email').parent().append('Invalid Format'); jQuery('#billing_email').parents('p.form-row').addClass('woocommerce-invalid'); } else { jQuery('#billing_email').parent().find('span.error').text('Invalid Format'); jQuery('#billing_email').parent().find('span.error').show(); } } else { jQuery('#billing_email').parent().find('span.error').hide(); }
} if(billing_last_name == ''){ is_error = true; if(!jQuery('#billing_last_name').parent().find('span.error').length) { jQuery('#billing_last_name').parent().append('Please enter last name'); jQuery('#billing_last_name').parents('p.form-row').addClass('woocommerce-invalid'); } else { jQuery('#billing_last_name').parent().find('span.error').text('Please enter last name'); jQuery('#billing_last_name').parent().find('span.error').show(); } } else { jQuery('#billing_last_name').parent().find('span.error').hide(); }
if(billing_phone == ''){ is_error = true; if(!jQuery('#billing_phone').parent().find('span.error').length) { jQuery('#billing_phone').parent().append('Please enter phone'); jQuery('#billing_phone').parents('p.form-row').addClass('woocommerce-invalid'); } else { jQuery('#billing_phone').parent().find('span.error').show(); } } else { if(billing_phone.length > 12 || billing_phone.length < 12 ) { is_error = true; if(!jQuery('#billing_phone').parent().find('span.error').length) { jQuery('#billing_phone').parent().append('Phone Should have only 10 digits'); jQuery('#billing_phone').parents('p.form-row').addClass('woocommerce-invalid'); } else { jQuery('#billing_phone').parent().find('span.error').text('Phone Should have only 10 digits'); jQuery('#billing_phone').parent().find('span.error').show(); }
} else { jQuery('#billing_phone').parent().find('span.error').hide(); }
}
if(billing_address_1 == ''){
is_error = true; if(!jQuery('#billing_address_1').parents('p.form-row').hasClass('woocommerce-invalid')) { jQuery('#billing_address_1').parent().append('Please enter address '); jQuery('#billing_address_1').parents('p.form-row').addClass('woocommerce-invalid'); } else { jQuery('#billing_address_1').parent().find('span.error').text('Please enter address'); jQuery('#billing_address_1').parent().find('span.error').show(); } } else { jQuery('#billing_address_1').parent().find('span.error').hide(); }
if(billing_city == ''){ is_error = true; if(!jQuery('#billing_city').parents('p.form-row').hasClass('woocommerce-invalid')) { jQuery('#billing_city').parent().append('Please enter city'); jQuery('#billing_city').parents('p.form-row').addClass('woocommerce-invalid'); } else { jQuery('#billing_city').parent().find('span.error').text('Please enter city'); jQuery('#billing_city').parent().find('span.error').show(); } } else { jQuery('#billing_city').parent().find('span.error').hide(); }
if(billing_postcode == ''){ is_error = true; if(!jQuery('#billing_postcode').parents('p.form-row').hasClass('woocommerce-invalid')) { jQuery('#billing_postcode').parent().append('Please enter zipcode'); jQuery('#billing_postcode').parents('p.form-row').addClass('woocommerce-invalid'); } else { jQuery('#billing_postcode').parent().find('span.error').text('Please enter zipcode'); jQuery('#billing_postcode').parent().find('span.error').show(); } } else { jQuery('#billing_postcode').parent().find('span.error').hide(); }
if(!is_error){ jQuery('.col-2').removeClass('active'); jQuery('.col-3').addClass('active'); var address = ''; jQuery('div.step_1_forwarded div.step_1_email').html(additional_email2 + 'Change');
if(jQuery('#shipping_method_extra_custom input[type="radio"]:checked').val() == 'local_pickup2') { jQuery('.checkout_details .col-3 .nxt_step a.back_step_3').show(); jQuery('.checkout_details .col-3 .woocommerce-additional-fields').show(); jQuery('div.col-3 div.shipping_wrapper h4').text('Pickup method'); address = jQuery('#shipping_first_name').val()+' '+jQuery('#shipping_last_name').val()+' | '+ jQuery('#shipping_phone').val(); jQuery('div.step_2_forwarded h5').text('Contact Information'); //jQuery('div.step_3_forwarded div.step_3_shipping').html(persondetails + 'Change'); } else { address = jQuery('#billing_address_1').val()+', '+ jQuery('#billing_city').val()+' '+jQuery('#billing_postcode').val()+' ,'+jQuery('#billing_country').val(); } jQuery('div.step_2_forwarded div.step_2_address').html(address + 'Change'); } });
jQuery('body').on('click','.step_3_shipping span.edit',function(){ jQuery('.step_1 .step').each(function(){ jQuery(this).removeClass('active');
}); jQuery('.col-3').addClass('active');
});
jQuery('body').on('click','.step_2_address span.edit',function(){ jQuery('.step_1 .step').each(function(){ jQuery(this).removeClass('active');
}); jQuery('.col-2').addClass('active');
});
jQuery('body').on('click','.col-3 .nxt_step a.fourth_step',function(){ var additionalpickupdate = jQuery('#additional_pickup_date').val(); var iserror = false;
var additional_email2 = jQuery('#billing_email').val(); var address = jQuery('#billing_address_1').val()+', '+ jQuery('#billing_city').val()+' '+jQuery('#billing_postcode').val()+' ,'+jQuery('#billing_country').val(); jQuery('div.step_1_forwarded div.step_1_email').html(additional_email2 + 'Change'); jQuery('div.step_2_forwarded div.step_2_address').html(address + 'Change');
if(jQuery('#additional_pickup_date').is(':visible') && additionalpickupdate == ''){ iserror = true; if(!jQuery('#additional_pickup_date').parents('p.form-row').hasClass('woocommerce-invalid')) { jQuery('#additional_pickup_date').parent().append('Please choose date'); jQuery('#additional_pickup_date').parents('p.form-row').addClass('woocommerce-invalid'); } else { jQuery('#additional_pickup_date').parent().find('span.error').text('Please choose date'); jQuery('#additional_pickup_date').parent().find('span.error').show(); } } if(!iserror) { if(jQuery('#additional_pickup_date').is(':visible') && additionalpickupdate != ''){ shippingmethod = jQuery('#shipping_method_third_step input[type="radio"]:checked').attr('title')+' - '+additionalpickupdate; } else { shippingmethod = jQuery('#shipping_method_third_step input[type="radio"]:checked').attr('title'); } jQuery('.col-3').removeClass('active'); jQuery('.col-4').addClass('active'); } }); // Step-2 shipping Option tabs jQuery('#shipping_phone, #billing_phone').on( 'input focusout', function() { var p = jQuery(this).val(); var cleaned = ('' + p).replace(/\D/g, ''); if (cleaned.length > 10) { cleaned = cleaned.substring(0, 11); } console.log(cleaned); if (cleaned.length == 11) { var match_1 = cleaned.match(/^(\d{1})(\d{3})(\d{3})(\d{4})$/); if (match_1) { p = match_1[1] + ' ' + match_1[2] + '-' + match_1[3] + '-' + match_1[4]; } }else if (cleaned.length == 12) { var match_2 = cleaned.match(/^(\d{2})(\d{3})(\d{3})(\d{4})$/) if (match_2) { p = match_2[1] + ' ' + match_2[2] + '-' + match_2[3] + '-' + match_2[4] } }else{ var match = cleaned.match(/^(\d{3})(\d{3})(\d{4})$/); if (match) { p = match[1] + '-' + match[2] + '-' + match[3] } } //return null;
// p = p.replace(/[^0-9]/g, ''); //p = p.replace(/(\d{3})(\d{3})(\d{4})/, "$1-$2-$3"); jQuery(this).val(p); });
function check_login() { var ajaxurl = 'https://www.compasshp.com/wp-admin/'+'admin-ajax.php'; var uname = jQuery('#username').val(); var pwd = jQuery('#password').val(); if(uname !="" && pwd!="") { jQuery('.loggin_form div.error_info_wrapper').css('display','block'); jQuery('.loggin_form div.error_info_wrapper').text('Sending Info'); jQuery('.woocommerce-form-login').addClass('disabled_form'); jQuery.ajax({ url: ajaxurl, type:"GET", data: { 'action':'user_login','uname':uname,'pwd':pwd }, dataType: "json", success:function(data) { jQuery('.loggin_form div.error_info_wrapper').html(data.error); jQuery('.woocommerce-form-login').removeClass('disabled_form'); if(data.error == 'Successfully Logged In') { setTimeout(function() { window.location.href = location+'?logged_in=true'; }, 1500); } } }); } else { jQuery('.loggin_form div.error_info_wrapper').text('Fill the below fields!'); jQuery('.loggin_form div.error_info_wrapper').css('display','block'); return false; } } function isEmail(email) { var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; return regex.test(email); }
jQuery('body').on('click','.loginform input[type="checkbox"]',function(){ if(jQuery(this).attr('id') == 'ulogin') { if(jQuery(this).is(':checked')) { jQuery('div.loggin_form').show(); jQuery('#createaccount').prop('checked',false); jQuery('div.create-account').hide(); } else { jQuery('div.loggin_form').hide(); } } if(jQuery(this).attr('id') == 'createaccount') { if(jQuery(this).is(':checked')) { jQuery('div.loggin_form').hide(); jQuery('#ulogin').prop('checked',false); } else { //jQuery('div.loggin_form').hide(); } } }); jQuery(document).on('click', '.product-remove a.remove', function (e) { var ajaxurl = 'https://www.compasshp.com/wp-admin/'+'admin-ajax.php'; e.preventDefault();
var product_id = jQuery(this).attr("data-product_id"), cart_item_key = jQuery(this).attr("data-cart_item_key");
jQuery.ajax({ type: 'POST', dataType: 'text', url: ajaxurl, data: { action: "product_remove", product_id: product_id, cart_item_key: cart_item_key }, success: function(response) { //jQuery('#order_review').html(response); jQuery(document.body).trigger('update_checkout');
} });
});