1var nc = jQuery.noConflict(); 2nc(document).ready(function () { 3 4//Manage Account Edit pg start GetShippingAddresses Api 5nc('#manageaccount_editpg').on('click',function(){ 6 7 nc("#manage_account_editpg").show(); 8 nc("#anchor_donetag").show(); 9 nc("#shippingaddress_addeditpg").show(); 10 nc("#manage_account_showpg").hide(); 11 nc("#manageaccount_editpg").hide(); 12 13 var CustomerId = nc("#hid_resultid").val(); 14 15 nc.ajax({ 16 type: "POST", 17 url:""+nc('#admin_url').val()+"", 18 data: { 19 action: "getshippingaddress_dropdown", 20 CustomerId: CustomerId, 21 }, 22 beforeSend: function(){ 23 }, 24 success: function(msg){ 25 if(msg){ 26 console.log(msg); 27 //alert(msg); 28 var splitted = msg.split('==='); 29 console.log(splitted); 30 31 var ship_nickname= splitted[2].replace(/\\/g, ''); 32 var ship_companyname= splitted[3].replace(/\\/g, ''); 33 var ship_address1= splitted[4].replace(/\\/g, ''); 34 var ship_address2= splitted[5].replace(/\\/g, ''); 35 var ship_city= splitted[6]; 36 var ship_state= splitted[7]; 37 var ship_postalcode= splitted[8]; 38 var ship_isdefault= splitted[9]; 39 var ship_addressid= splitted[10]; 40 var shipbirthdate= splitted[12]; 41 var shipfirstname= splitted[13].replace(/\\/g, ''); 42 var shiplastname= splitted[14].replace(/\\/g, ''); 43 var shipphonenumber= splitted[15]; 44 var deliveryinstructions= splitted[16]; 45 var ship_city_state_postalcode= splitted[6]+', '+splitted[7]+', '+splitted[8]; 46 47 //alert(splitted[0]) Success===Other Duplex===Candy Good===2596 Parkwood Drive===Green Bay===WI===54304===1===1561===1561===2596 Parkwood 48 if(splitted[1] == 'Success'){ 49 nc('.dropdown-btn').empty(); 50 //nc('.dropdown-btn').html(splitted[11]); 51 nc('.dropdown-btn').html(ship_nickname+' - '+splitted[11].replace(/\\/g, '')+', '+ship_city_state_postalcode) 52 nc('.dropdown-content').empty(); 53 nc('.dropdown-content').html(splitted[0]); 54 nc('#ship-nickname').val(ship_nickname); 55 nc('#ship-companyname').val(ship_companyname); 56 nc('#shipbirthdate').val(shipbirthdate); 57 nc('#ship-firstname').val(shipfirstname); 58 nc('#ship-lastname').val(shiplastname); 59 nc('#ship-address1').val(ship_address1); 60 nc('#ship-address2').val(ship_address2); 61 nc('#ship-city').val(ship_city); 62 nc('#ship-state').val(ship_state); 63 nc('#ship-postalcode').val(ship_postalcode); 64 nc('#isdefault').val(ship_isdefault); 65 nc('#ship-addressid').val(ship_addressid); 66 nc('#ship-phone-number').val(shipphonenumber); 67 nc('#deliveryinstructions').val(deliveryinstructions); 68 69 if (ship_isdefault === 'Yes') { 70 nc('#isdefault').prop('checked', true); 71 } else { 72 nc('#isdefault').prop('checked', false); 73 } 74 } 75 } 76 } 77 }); 78}); 79//Manage Account Edit pg End 80 81//Manage Account click done pg start 82nc("#anchor_donetag").on("click",function(e){ 83 //window.location.reload(); 84 85 if (nc('#manage_account_savedetail').data('edited')) { 86 e.stopImmediatePropagation(); // Stop other click handlers temporarily 87 nc('#notification').fadeIn(); 88 return false; // Prevent default for this click 89 } else { 90 nc('#notification').fadeOut(); 91 } 92 93 nc("#manage_account_editpg").hide(); 94 nc("#anchor_donetag").hide(); 95 nc("#shippingaddress_addeditpg").hide(); 96 97 nc.ajax({ 98 type: "POST", 99 url: "" + nc('#admin_url').val() + "", 100 data: { 101 action: "custom_club_account_getbasketinfo" 102 }, 103 beforeSend: function() { 104 nc('.loader.small-loader-donetag').show(); 105 }, 106 success: function(msg) { 107 if (msg) { 108 //alert(msg) 109 console.log(msg); 110 var splitted = msg.split('==='); 111 112 nc('.loader.small-loader-donetag').hide(); 113 114 var responseObj = JSON.parse(splitted[1]); 115 // Extract the values response Object creditcardnum 116 117 var resultid = responseObj.resultid[0]; 118 var name = responseObj.name[0]; 119 //var shipaddress1 = responseObj.shipaddress1[0].replace(/\\/g, ''); 120 //var shipaddress2 = responseObj.shipaddress2[0].replace(/\\/g, ''); 121 var shipaddress1 = responseObj.shipaddress1 && responseObj.shipaddress1[0] ? responseObj.shipaddress1[0].replace(/\\/g, '') : ''; 122 var shipaddress2 = responseObj.shipaddress2 && responseObj.shipaddress2[0] ? responseObj.shipaddress2[0].replace(/\\/g, '') : ''; 123 var shipcity = responseObj.shipcity[0]; 124 var shipstate = responseObj.shipstate[0]; 125 var shippostalcode = responseObj.shippostalcode[0]; 126 var phone = responseObj.phone[0]; 127 var email = responseObj.email[0]; 128 var creditcardnum = responseObj.creditcardnum[0]; 129 var creditcardtype = responseObj.creditcardtype[0]; 130 var expirationmonthyear = responseObj.expirationmonth[0]+'/'+responseObj.expirationyear[0]; 131 var expirationmonth = responseObj.expirationmonth[0]; 132 var expirationyear = responseObj.expirationyear[0]; 133 var avsaddress = responseObj.avsaddress[0]; 134 var avscity = responseObj.avscity[0]; 135 var avsstate = responseObj.avsstate[0]; 136 var avspostalcode = responseObj.avspostalcode[0]; 137 var customerfirstname = responseObj.customerfirstname && responseObj.customerfirstname[0] ? responseObj.customerfirstname[0].replace(/\\/g, '') : ''; 138 var customerlastname = responseObj.customerlastname && responseObj.customerlastname[0] ? responseObj.customerlastname[0].replace(/\\/g, '') : ''; 139 var emailaddress2 = responseObj.emailaddress2[0]; 140 var username = responseObj.username[0]; 141 var birthday = responseObj.birthday[0]; 142 var country = responseObj.country[0]; 143 var shipbirthdate = responseObj.shipbirthdate[0]; 144 var shipcountry= responseObj.shipcountry[0]; 145 var notpickedup= responseObj.notpickedup[0]; 146 var numberpkgsfob= responseObj.numberpkgsfob[0]; 147 var isgift= responseObj.isgift[0]; 148 var giftnotes= responseObj.giftnotes[0]; 149 var numberpkgspickedup= responseObj.numberpkgspickedup[0]; 150 var numberpkgsshipped= responseObj.numberpkgsshipped[0]; 151 var smallestpurchase= responseObj.smallestpurchase[0]; 152 var largestpurchase= responseObj.largestpurchase[0]; 153 var totalproduct= responseObj.totalproduct[0]; 154 var totaldiscount= responseObj.totaldiscount[0]; 155 var totalsellingprice= responseObj.totalsellingprice[0]; 156 var totaltaxes = responseObj.totaltaxes[0]; 157 var totalshipnhandle= responseObj.totalshipnhandle[0]; 158 var totalprice= responseObj.totalprice[0]; 159 var pickuplocation= responseObj.pickuplocation[0]; 160 var shipfirstname= responseObj.shipfirstname && responseObj.shipfirstname[0] ? responseObj.shipfirstname[0].replace(/\\/g, '') : ''; 161 var shiplastname= responseObj.shiplastname && responseObj.shiplastname[0] ? responseObj.shiplastname[0].replace(/\\/g, '') : ''; 162 var deliveryinstructions= responseObj.deliveryinstructions[0]; 163 164 // Set values to form fields active_club_manage_account.php 165 nc("#name span").text(name); 166 nc("#shipaddress2_avsaddress").text(shipaddress1); 167 nc("#shipaddress2_avsaddress").text(shipaddress2); 168 nc("#shipaddress2_avscity").text(shipcity); 169 nc("#shipaddress2_avsstate").text(shipstate); 170 nc("#shipaddress2_avspostalcode").text(shippostalcode); 171 nc("#phonenumber span").text(phone); 172 nc("#email span").text(email); 173 nc("#creditcardnum span").text(creditcardnum); 174 nc("#creditcardtype span").text(creditcardtype); 175 nc("#expirationmonthyear span").text(expirationmonth+'/'+expirationmonthyear); 176 nc("#shipaddress1_avsaddress").text(avsaddress); 177 nc("#shipaddress1_avscity").text(avscity); 178 nc("#shipaddress1_avsstate").text(avsstate); 179 nc("#shipaddress1_avspostalcode").text(avspostalcode); 180 nc("#shipaddress1_customerfirstname").text(customerfirstname+' '+customerlastname); 181 nc("#username span").text(username); 182 nc("#birthday span").text(birthday); 183 nc("#hid_pickuplocation").text(pickuplocation); 184 nc("#shipaddress2_customerfirstname").text(shipfirstname+' '+shiplastname); 185 nc("#delivery_ins").text(deliveryinstructions); 186 187 nc("#manage_account_showpg").show(); 188 nc("#manageaccount_editpg").show(); 189 } 190 } 191 }); 192}); 193 194//Manage Account Shipping Address select-category on change in bottom Part 195nc("#selected_shipping_address_id").on('focus', function(){ 196 var thisValue = nc(this).val(); 197 var CustomerId = nc("#hid_resultid").val(); 198 var select_category_id =thisValue;
198// nc("#select-shipping-address").val(); 199 200 nc.ajax({ 201 type: "POST", 202 url:""+nc('#admin_url').val()+"", 203 data: { 204 action: "shippinaddress_select_category", 205 ShipAddressId: select_category_id, 206 CustomerId: CustomerId, 207 }, 208 beforeSend: function(){ 209 }, 210 success: function(msg){ 211 if(msg){ 212 console.log(msg); 213 // alert(msg); 214 nc('#ship-addressid').val(''); 215 nc('#new-addedit').val(''); 216 nc('#ship-nickname').val(''); 217 nc('#ship-companyname').val(''); 218 nc('#ship-firstname').val(''); 219 nc('#ship-lastname').val(''); 220 nc('#shipbirthdate').val(''); 221 nc('#ship-address1').val(''); 222 nc('#ship-address2').val(''); 223 nc('#ship-city').val(''); 224 nc('#ship-state').val(''); 225 nc('#ship-postalcode').val(''); 226 nc('#deliveryinstructions').val(''); 227 228 var splitted = msg.split('==='); 229 //alert(splitted[0]) 230 var ship_nickname= splitted[1].replace(/\\/g, ''); 231 var ship_companyname= splitted[2].replace(/\\/g, ''); 232 var ship_address1= splitted[3].replace(/\\/g, ''); 233 var ship_address2= splitted[4].replace(/\\/g, ''); 234 var ship_city= splitted[5]; 235 var ship_state= splitted[6]; 236 var ship_postalcode= splitted[7]; 237 var ship_addressid= splitted[8]; 238 var ship_isdefault= splitted[9]; 239 var shipbirthdate= splitted[10]; 240 var shipfirstname= splitted[11].replace(/\\/g, ''); 241 var shiplastname= splitted[12].replace(/\\/g, ''); 242 var deliveryinstructions= splitted[13].replace(/\\/g, ''); 243 var ship_city_state_postalcode= splitted[5]+', '+splitted[6]+', '+splitted[7]; 244 245 if(splitted[0] == 'Success'){ 246 nc('.dropdown-btn').empty(); 247 nc('.dropdown-btn').html(ship_nickname+' - '+splitted[3].replace(/\\/g, '')+', '+ship_city_state_postalcode); 248 nc('#ship-nickname').val(ship_nickname); 249 nc('#ship-companyname').val(ship_companyname); 250 nc('#ship-firstname').val(shipfirstname); 251 nc('#ship-lastname').val(shiplastname); 252 nc('#shipbirthdate').val(shipbirthdate); 253 nc('#ship-address1').val(ship_address1); 254 nc('#ship-address2').val(ship_address2); 255 nc('#ship-city').val(ship_city); 256 nc('#ship-state').val(ship_state); 257 nc('#ship-postalcode').val(ship_postalcode); 258 nc('#ship-addressid').val(ship_addressid); 259 nc('#deliveryinstructions').val(deliveryinstructions); 260 261 if (ship_isdefault === 'Yes') { 262 nc('#isdefault').prop('checked', true); 263 } else { 264 nc('#isdefault').prop('checked', false); 265 } 266 } 267 } 268 } 269 }); 270}); 271 272//Manage Account in bottom Part Shipping Address click on Add Button process 273nc("#shippinaddress_addedit").on('click', function(){ 274 nc('#ship-addressid').val(''); 275 nc('#new-addedit').val(1); 276 nc('#ship-nickname').val(''); 277 nc('#ship-companyname').val(''); 278 nc('#ship-firstname').val(''); 279 nc('#ship-lastname').val(''); 280 nc('#shipbirthdate').val(''); 281 nc('#ship-phone-number').val(''); 282 nc('#ship-address1').val(''); 283 nc('#ship-address2').val(''); 284 nc('#ship-city').val(''); 285 nc('#ship-state').val(''); 286 nc('#ship-postalcode').val(''); 287 nc('#deliveryinstructions').val(''); //textarea 288 nc('#isdefault').prop('checked', true); 289}); 290 291//Manage Account in bottom Part Shipping Address click trash icon DeleteShippingAddress 292nc('body').on('click', '.shipping_address_delete', function(e) { 293 294 e.preventDefault();
294 // Prevent the default action of the anchor tag 295 var deleteshippingaddress = confirm('Are you sure that you want to delete this address?'); 296 297 if (deleteshippingaddress) { 298 var ship_addressid = nc(this).data('id'); 299 var hid_customerid=nc('#hid_customerid').val(); 300 nc.ajax({ 301 type: "POST", 302 url:""+nc('#admin_url').val()+"", 303 data: { 304 action: "delete_shipping_address", 305 ship_addressid:ship_addressid, 306 customerid:hid_customerid 307 }, 308 beforeSend: function(){ 309 nc('.loader.small-loader-delete').show(); 310 }, 311 success: function(msg){ 312 if(msg){ 313 nc('.loader.small-loader-delete').hide(); 314 // alert(msg); 315 console.log(msg); 316 317 // After save data GetShippingAddresses again to refill the drop down 318 var splitted = msg.split('==='); 319 console.log(splitted); 320 321 var ship_nickname= splitted[2].replace(/\\/g, ''); 322 var ship_companyname= splitted[3].replace(/\\/g, ''); 323 var ship_address1= splitted[4].replace(/\\/g, ''); 324 var ship_address2= splitted[5].replace(/\\/g, ''); 325 var ship_city= splitted[6]; 326 var ship_state= splitted[7]; 327 var ship_postalcode= splitted[8]; 328 var ship_isdefault= splitted[9]; 329 var ship_addressid= splitted[10]; 330 var shipbirthdate= splitted[12]; 331 var shipfirstname= splitted[13].replace(/\\/g, ''); 332 var shiplastname= splitted[14].replace(/\\/g, ''); 333 var shipphonenumber= splitted[15]; 334 var deliveryinstructions= splitted[16]; 335 var ship_city_state_postalcode= splitted[6]+', '+splitted[7]+', '+splitted[8]; 336 337 if(splitted[1] == 'Success'){ 338 nc('.dropdown-btn').empty(); 339 //nc('.dropdown-btn').html(splitted[11]); 340 nc('.dropdown-btn').html(ship_nickname+' - '+splitted[11].replace(/\\/g, '')+', '+ship_city_state_postalcode); 341 nc('.dropdown-content').empty(); 342 nc('.dropdown-content').html(splitted[0]); 343 nc('#ship-nickname').val(ship_nickname); 344 nc('#ship-companyname').val(ship_companyname); 345 nc('#shipbirthdate').val(shipbirthdate); 346 nc('#ship-firstname').val(shipfirstname); 347 nc('#ship-lastname').val(shiplastname); 348 nc('#ship-address1').val(ship_address1); 349 nc('#ship-address2').val(ship_address2); 350 nc('#ship-city').val(ship_city); 351 nc('#ship-state').val(ship_state); 352 nc('#ship-postalcode').val(ship_postalcode); 353 nc('#isdefault').val(ship_isdefault); 354 nc('#ship-addressid').val(ship_addressid); 355 nc('#ship-phone-number').val(shipphonenumber); 356 nc('#deliveryinstructions').val(deliveryinstructions); 357 358 if (ship_isdefault === 'Yes') { 359 nc('#isdefault').prop('checked', true); 360 } else { 361 nc('#isdefault').prop('checked', false); 362 } 363 364 nc('#span_to_post_response_edit').text('Delete Successfully') 365 .css({ 366 'color': 'red', 367 'text-align': 'center' 368 }) 369 .show() 370 .delay(3000) // Adjust the delay time in milliseconds (2000ms = 2 seconds) 371 .fadeOut(); 372 } 373 } 374 } 375 }); 376 } 377}); 378 379//Manage Account Edit data Store detail in Toppart 380nc("#manage_account_savedetail").on('click', function (e) { 381 e.preventDefault(); 382 383 // Show loader for captcha step 384 nc('.loader.small-loader_review').show(); 385 386 // STEP 1: CAPTCHA Validation 387 var captchaInput = nc('#captcha_input').val(); 388 389 jQuery.ajax({ 390 type: "POST", 391 url: nc('#admin_url').val(), 392 data: { 393 action: 'validate_custom_captcha', 394 captcha_input: captchaInput 395 }, 396 success: function (response) { 397 398 if (!response.success) { 399 // Show CAPTCHA error 400 nc('#captcha_error').show(); 401 402 // Refresh image 403 nc('#captcha-img').attr('src', myplugin_vars.plugin_url + 'includes/generate-captcha.php?rand=' + Date.now()); 404 405 nc('.loader.small-loader_review').hide(); 406 return false; // stop here 407 } 408 409 // CAPTCHA passed â hide error 410 nc('#captcha_error').hide(); 411 nc('.loader.small-loader_review').hide(); 412 413 414 //Hide, notification-Almost Done! Just scroll down and click âSave Detailsâ 415 nc('#manage_account_savedetail').removeClass('nt-sve'); 416 nc('#manage_account_savedetail').removeData('edited'); // Clear edited state 417 nc('#notification').fadeOut(); 418 419 // STEP 2: Continue with original account save logic 420 //Credit Card Validation 421 //var errors_credit=0; 422 //var cardNumber = nc("#creditcardnum_edit").val(); 423 //var cardNumberWithoutchange = nc("#creditcardnum-withoutchange").val(); 424 425 /*if(cardNumber != "") { 426 nc('#creditcardnum_edit').validateCreditCard(function(result){ 427 428 if(!(result.valid)){ 429 errors_credit=1; 430 nc('#errorwarn_credit').show(); 431 nc("#creditcardnum_edit").addClass("error"); 432 nc("#creditcardnum_edit").focus(); 433 nc("#errorwarn_credit").html("Credit Card Number is Invalid."); 434 return false;
435 exit; 436 }else{ 437 // errors_credit=0; 438 nc("#creditcardnum_edit").removeClass("error"); 439 nc("#errorwarn_credit").hide('slow'); //hide credit card error warning. 440 } 441 }); 442 }*/ 443 444 var customer_firstname = nc("#customer-firstname").val(); 445 var customer_lastname = nc("#customer-lastname").val(); 446 var email = nc("#customer-email").val(); 447 var user_name = nc("#user-name").val(); 448 var phone_number = nc("#phone-number").val(); 449 var birthdate = nc("#birthdate").val(); 450 var creditcardnum = nc("#encrypt_creditcardnum").val(); 451 var credit_cardnum_edit = nc("#creditcardnum_edit").val(); 452 var expiration_month = nc("#expiration-month").val(); 453 var expiration_year = nc("#expiration-year").val(); 454 var credit_cardnum_withoutchange = nc("#creditcardnum-withoutchange").val(); 455 var expiration_month_withoutchange = nc("#expiration-month-withoutchange").val(); 456 var expiration_year_withoutchange = nc("#expiration-year-withoutchange").val(); 457 var avs_address = nc("#avs-address").val(); 458 var avs_postalcode = nc("#avs-postalcode").val(); 459 var avs_city = nc("#avs-city").val(); 460 var avs_state = nc("#avs-state").val(); 461 var customerid = nc("#hid_customerid").val(); 462 463 // Validate required fields 464 var errors = 0; 465 nc('#manage_account_editpg :input[data-required="yes"]').map(function () { 466 if (!nc(this).val().trim()) { 467 nc(this).addClass('error'); 468 errors++; 469 } else { 470 nc(this).removeClass('error'); 471 } 472 }); 473 474 // Email validation 475 var errors_emailaddress = 0; 476 var customeremail = jQuery('#customer-email').val(); 477 if (jQuery.trim(customeremail) !== '') { 478 var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,5})?$/; 479 if (!emailReg.test(customeremail)) { 480 errors_emailaddress = 1; 481 jQuery("#customer-email").addClass("error").focus(); 482 jQuery('#errorwarn_cusemail').show().html("Please enter valid email."); 483 return false; 484 } else { 485 jQuery("#customer-email").removeClass("error"); 486 jQuery("#errorwarn_cusemail").hide('slow'); 487 } 488 } 489 490 if (errors > 0) { 491 nc('#errorwarn_info').show().html("Please fill the required fields."); 492 return false; 493 } else { 494 nc('#errorwarn_info').hide('slow'); 495 nc.ajax({ 496 type: "POST", 497 url: nc('#admin_url').val(), 498 data: { 499 action: "manage_account_savedetails", 500 customer_firstname: customer_firstname, 501 customer_lastname: customer_lastname, 502 email: email, 503 user_name: user_name, 504 phone_number: phone_number, 505 birthdate: birthdate, 506 credit_cardnum: creditcardnum, 507 credit_cardnum_edit: credit_cardnum_edit, 508 expiration_month: expiration_month, 509 expiration_year: expiration_year, 510 credit_cardnum_withoutchange: credit_cardnum_withoutchange, 511 expiration_month_withoutchange: expiration_month_withoutchange, 512 expiration_year_withoutchange: expiration_year_withoutchange, 513 avs_address: avs_address, 514 avs_postalcode: avs_postalcode, 515 avs_city: avs_city, 516 avs_state: avs_state, 517 customerid: customerid 518 }, 519 beforeSend: function () { 520 nc('.loader.small-loader').show(); 521 }, 522 success: function (msg) { 523 nc('.loader.small-loader').hide(); 524 var splitted = msg.split('==='); 525 if (splitted[0] == 1) { 526 nc('#span_to_post_response').text('Your account details have been saved.') 527 .css({ 528 'color': 'green', 529 'text-align': 'center', 530 'margin-bottom': '1.5rem' 531 }).show().delay(3000).fadeOut(); 532 533 //update creditcard number field 534 var creditcardnumedit = nc("#creditcardnum_edit").val(); 535 var maskedNumber = creditcardnumedit.slice(0, -4).replace(/./g, 'X') + creditcardnumedit.slice(-4); 536 537 nc("#creditcardnum_edit").empty; 538 nc("#creditcardnum_edit").val(maskedNumber); 539 540 } else { 541 542 nc('#span_to_post_response').text(splitted[1]) 543 .css({ 544 'color': 'red', 545 'text-align': 'center', 546 'margin-bottom': '1.5rem' 547 }).show().delay(3000).fadeOut(); 548 } 549 } 550 }); 551 } 552 } 553 }); 554}); 555 556//Manage Account Store Add/edit addrss detail start part manage_account_saveaddress_add_edit 557nc("#manage_account_saveaddress_add_edit").on('click', function(){ 558 559 // Retrieve the checkbox element 560 var checkbox = document.getElementById('isdefault'); 561 562 // Check if the checkbox element exists 563 if(checkbox){ 564 // Retrieve the checked state of the checkbox 565 var isdefault_check = checkbox.checked; 566 var isdefault; 567 // Check the checked state of the checkbox and set isdefault accordingly 568 if (isdefault_check) { 569 isdefault = 'Yes'; 570 } else { 571 isdefault = 'No'; 572 } 573 }
574 var ship_addressid = nc("#ship-addressid").val(); 575 var ship_nickname = nc("#ship-nickname").val(); 576 var customerid = nc("#hid_customerid").val(); 577 var ship_companyname = nc("#ship-companyname").val(); 578 var ship_firstname = nc("#ship-firstname").val(); 579 var ship_lastname = nc("#ship-lastname").val(); 580 var shipbirthdate = nc("#shipbirthdate").val(); 581 var ship_phone_number = nc("#ship-phone-number").val(); 582 var ship_address1 = nc("#ship-address1").val(); 583 var ship_address2 = nc("#ship-address2").val(); 584 var ship_city = nc("#ship-city").val(); 585 var ship_state = nc("#ship-state").val(); 586 var ship_postalcode = nc("#ship-postalcode").val(); 587 var new_addedit = nc("#new-addedit").val(); 588 var deliveryinstructions = nc("#deliveryinstructions").val(); 589 590 //validation empty field 591 var errors = 0; 592 nc('#shippingaddress_addeditpg :input[data-required = "yes"]').map(function(){ 593 if( !nc(this).val().trim()) { 594 nc(this).addClass('error'); 595 errors++; 596 } else if (nc(this).val()) { 597 nc(this).removeClass('error'); 598 } 599 }); 600 601 //Empty field validation. 602 if(errors > 0){ 603 nc('#errorwarn_ship').show(); 604 nc('#errorwarn_ship').html("Please fill the required fields."); 605 return false; 606 607 }else{ 608 nc('#errorwarn_ship').hide('slow'); //hide error warning. 609 nc.ajax({ 610 type: "POST", 611 url:""+nc('#admin_url').val()+"", 612 data: { 613 action: "manage_account_saved_addedit_details", 614 ship_addressid:ship_addressid, 615 isdefault: isdefault, 616 ship_nickname: ship_nickname, 617 customerid:customerid, 618 ship_companyname:ship_companyname, 619 ship_firstname:ship_firstname, 620 ship_lastname:ship_lastname, 621 shipbirthdate:shipbirthdate, 622 ship_phone_number:ship_phone_number, 623 ship_address1:ship_address1, 624 ship_address2:ship_address2, 625 ship_city:ship_city, 626 ship_state:ship_state, 627 ship_postalcode:ship_postalcode, 628 new_addedit:new_addedit, 629 deliveryinstructions:deliveryinstructions, 630 }, 631 beforeSend: function(){ 632 nc('.loader.small-loader-saveaddress').show(); 633 nc("#manage_account_saveaddress_add_edit").prop("disabled", true).addClass('disabled'); //Disable save button 634 }, 635 success: function(msg){ 636 nc('.loader.small-loader-saveaddress').hide(); 637 638 if(msg){ 639 var splitted = msg; 640 console.log(splitted); 641 // alert(msg); 642 643 // After save data GetShippingAddresses again to refill the drop down 644 var splitted = msg.split('==='); 645 var ship_nickname= splitted[2].replace(/\\/g, ''); 646 var ship_companyname= splitted[3].replace(/\\/g, ''); 647 var shipfirstname= splitted[13].replace(/\\/g, ''); 648 var shiplastname= splitted[14].replace(/\\/g, ''); 649 var ship_address1= splitted[4].replace(/\\/g, ''); 650 var ship_address2= splitted[5].replace(/\\/g, ''); 651 var ship_city= splitted[6]; 652 var ship_state= splitted[7]; 653 var ship_postalcode= splitted[8]; 654 var ship_isdefault= splitted[9]; 655 var ship_addressid= splitted[10]; 656 var shipbirthdate= splitted[12]; 657 var shipphonenumber= splitted[15]; 658 var deliveryinstructions= splitted[17].replace(/\\/g, ''); 659 var ship_city_state_postalcode= splitted[6]+', '+splitted[7]+', '+splitted[8]; 660 661 if(splitted[1] == 'Success'){ 662 nc('.dropdown-btn').empty(); 663 //nc('.dropdown-btn').html(splitted[11]); 664 nc('.dropdown-btn').html(ship_nickname+' - '+splitted[11].replace(/\\/g, '')+', '+ship_city_state_postalcode); 665 nc('.dropdown-content').empty(); 666 nc('.dropdown-content').html(splitted[0]); 667 nc('#ship-nickname').val(ship_nickname); 668 nc('#ship-companyname').val(ship_companyname); 669 nc('#shipbirthdate').val(shipbirthdate); 670 nc('#ship-firstname').val(shipfirstname); 671 nc('#ship-lastname').val(shiplastname); 672 nc('#ship-address1').val(ship_address1); 673 nc('#ship-address2').val(ship_address2); 674 nc('#ship-city').val(ship_city); 675 nc('#ship-state').val(ship_state); 676 nc('#ship-postalcode').val(ship_postalcode); 677 nc('#isdefault').val(ship_isdefault); 678 nc('#ship-addressid').val(ship_addressid); 679 nc('#ship-phone-number').val(shipphonenumber); 680 nc('#deliveryinstructions').val(deliveryinstructions); 681 682 if (ship_isdefault === 'Yes') { 683 nc('#isdefault').prop('checked', true); 684 } else { 685 nc('#isdefault').prop('checked', false); 686 } 687 688 setTimeout(function() { //Remove disable 689 nc("#manage_account_saveaddress_add_edit").prop("disabled", false).removeClass('disabled'); 690 }, 3000); 691 692 nc('#span_to_post_response_edit').text('Your address details have been saved.') 693 .css({ 694 'color': 'green', 695 'text-align': 'center' 696 }) 697 .show() 698 .delay(3000) // Adjust the delay time in milliseconds (2000ms = 2 seconds) 699 .fadeOut(); 700 } 701 } 702 } 703 }); 704 } 705}); 706 707//Club Account login create account Start 708nc("#create-user-info-form").on('submit', function(event) { 709 event.preventDefault(); 710 711 // Show loader for review 712 nc('.loader.small-loader_review').show(); 713 714 // Step 1: Validate CAPTCHA first 715 var captchaInput = nc('#captcha_input').val(); 716 717 jQuery.ajax({ 718 type: "POST", 719 url: nc('#admin_url').val(), 720 data: { 721 action: 'validate_custom_captcha', 722 captcha_input: captchaInput 723 }, 724 success: function(response) { 725 726 if (!response.success) { 727 // Show CAPTCHA error 728 nc('#captcha_error').show(); 729 730 // Refresh image 731 nc('#captcha-img').attr('src', myplugin_vars.plugin_url + 'includes/generate-captcha.php?rand=' + Date.now()); 732 733 nc('.loader.small-loader_review').hide(); 734 return false;
735 } else { 736 // Hide captcha error if previously shown 737 nc('#captcha_error').hide(); 738 739 // Step 2: Proceed with your original form validation logic 740 var first_name = nc("#first-name").val(); 741 var last_name = nc("#last-name").val(); 742 var user_name = nc("#user-name").val(); 743 var password = nc("#password").val(); 744 var allocation_id = nc("#allocation_id").val(); 745 var encryptcreatepassword = nc("#encryptcreatepassword").val(); 746 var source = nc("#encryptcreatepassword").data('source'); // stored original plain value 747 748 // Validation empty fields 749 var errors = 0; 750 nc('#create-account-form :input[data-required = "yes"]').map(function(){ 751 if( !nc(this).val().trim()) { 752 nc(this).addClass('error'); 753 errors++; 754 } else if (nc(this).val()) { 755 nc(this).removeClass('error'); 756 } 757 }); 758 759 if(errors > 0){ 760 nc('#errorwarn').show().html("Please fill the required fields."); 761 nc('.loader.small-loader_review').hide(); 762 return false; 763 } else { 764 nc('#errorwarn').hide('slow'); 765 766 // If encrypted password is missing, encrypt first 767 if (password !== '' && (encryptcreatepassword === '' || source !== password)) { 768 nc.ajax({ 769 type: "POST", 770 url: nc('#admin_url').val(), 771 data: "action=get_password_encrypt&result=passenc&webpassword=" + encodeURIComponent(password), 772 beforeSend: function() { 773 nc('.loader.small-loader').show(); 774 }, 775 success: function(msg) { 776 if (msg) { 777 nc('#encryptcreatepassword').val(msg); 778 account_password = msg; 779 createaccount(first_name,last_name,user_name,account_password,allocation_id); // Call login function 780 } 781 } 782 }); 783 } else { 784 createaccount(first_name,last_name,user_name,account_password,allocation_id); 785 } 786 } 787 } 788 } 789 }); 790}); 791 792//Create account 793function createaccount(first_name,last_name,user_name,account_password,allocation_id){ 794 nc.ajax({ 795 type: "POST", 796 url: nc('#admin_url').val(), 797 data: { 798 action: "custom_club_account_login", 799 result: "login", 800 first_name: first_name, 801 last_name: last_name, 802 user_name: user_name, 803 allocation_id: allocation_id, 804 encryptcreatepassword: account_password 805 }, 806 beforeSend: function(){ 807 nc('.loader.small-loader').show(); 808 }, 809 success: function(msg){ 810 if(msg){ 811 var splitted = msg.split('==='); 812 var responseObj = JSON.parse(splitted[2]); 813 var isloggedin = responseObj.isloggedin[0]; 814 var resultid = responseObj.resultid[0]; 815 var name = responseObj.name[0]; 816 var email = responseObj.email[0]; 817 var customerfirstname = responseObj.customerfirstname[0]; 818 var customerlastname = responseObj.customerlastname[0]; 819 var username = responseObj.username[0]; 820 821 nc('#create-user-info-form .loader.small-loader').hide(); 822 nc('#create-user-info-form #final-result').empty().html(splitted[0]); 823 nc("#hid_ca_isloggedin").val(isloggedin); 824 nc("#hid_ca_resultid").val(resultid); 825 nc("#hid_ca_resultname").val(name); 826 nc("#hid_ca_username").val(username); 827 nc("#hid_ca_email").val(email); 828 nc("#hid_ca_customerfirstname").val(customerfirstname); 829 nc("#hid_ca_customerlastname").val(customerlastname); 830 831 if (splitted[1] != '') { 832 document.getElementById('create-user-info-form').submit(); 833 } 834 } 835 } 836 }); 837} 838//create-account END 839 840//club account signin-account Start 841nc("#user-info-form").on('submit', function(event) { 842 event.preventDefault(); 843
844 var signin_username = nc("#signin-username").val(); 845 var signin_password = nc("#encryptsigninpassword").val(); 846 var raw_password = nc("#signin-password").val(); 847 var source = nc("#encryptsigninpassword").data('source'); // original plain password used 848 849 var errors = 0; 850 851 nc('#user-info-form :input[data-required="yes"]').map(function() { 852 if (!nc(this).val().trim()) { 853 nc(this).addClass('error'); 854 errors++; 855 } else { 856 nc(this).removeClass('error'); 857 } 858 }); 859 860 // Empty field validation. 861 if (errors > 0) { 862 nc('#errorwarnsignin').show(); 863 nc('#errorwarnsignin').html("Please fill the required fields."); 864 return false; 865 866 } else { 867 868 nc('#errorwarnsignin').hide('slow'); // Hide error warning. 869 870 // If encrypted password is missing, encrypt first 871 if (raw_password !== '' && (signin_password === '' || source !== raw_password)) { 872 //if (raw_password !== '' && signin_password === '') { 873 nc.ajax({ 874 type: "POST", 875 url: nc('#admin_url').val(), 876 data: "action=get_password_encrypt&result=passenc&webpassword=" + encodeURIComponent(raw_password), 877 beforeSend: function() { 878 nc('.loader.small-loader_sign').show(); 879 }, 880 success: function(msg) { 881 if (msg) { 882 nc('#encryptsigninpassword').val(msg); 883 signin_password = msg; 884 submitLogin(signin_username, signin_password); // Call login function 885 } 886 } 887 }); 888 889 } else { 890 submitLogin(signin_username, signin_password); 891 } 892 } 893}); 894 895// Function to handle login request and set hidden fields 896function submitLogin(username, password) { 897 898 nc.ajax({ 899 type: "POST", 900 url: "" + nc('#admin_url').val() + "", 901 data: { 902 action: "custom_club_account_signin", 903 result: "login", 904 signin_username: username, 905 signin_password: password // Encode the password 906 }, 907 beforeSend: function() { 908 nc('.loader.small-loader_sign').show(); 909 }, 910 success: function(msg) { 911 if (msg) { 912 //alert(msg) 913 console.log(msg); 914 var splitted = msg.split('==='); 915 916 nc('.loader.small-loader_sign').hide(); 917 nc('#final-result_sign').empty(); 918 nc('#final-result_sign').html(splitted[0]); 919 920 var responseObj = JSON.parse(splitted[3]); 921 922 // Extract the values response Object 923 var isloggedin = responseObj.isloggedin[0]; 924 var resultid = responseObj.resultid[0]; 925 var name = responseObj.name[0]; 926 var description = responseObj.description[0]; 927 var notes = responseObj.notes[0]; 928 var billshippingto = responseObj.billshippingto[0]; 929 var shippersonname = responseObj.shippersonname[0]; 930 var shipaddress1 = responseObj.shipaddress1[0]; 931 var shipaddress2 = responseObj.shipaddress2[0]; 932 var shipcity = responseObj.shipcity[0]; 933 var shipstate = responseObj.shipstate[0]; 934 var shippostalcode = responseObj.shippostalcode[0]; 935 var shipphone = responseObj.shipphone[0]; 936 var residentialaddress = responseObj.residentialaddress[0]; 937 var phone = responseObj.phone[0]; 938 var phonealternate = responseObj.phonealternate[0]; 939 var email = responseObj.email[0]; 940 var creditcardnum = responseObj.creditcardnum[0]; 941 var creditcardtype = responseObj.creditcardtype[0]; 942 var expirationmonthyear = responseObj.expirationmonth[0]+'/'+responseObj.expirationyear[0]; 943 var expirationmonth = responseObj.expirationmonth[0]; 944 var expirationyear = responseObj.expirationyear[0]; 945 var avsaddress = responseObj.avsaddress[0]; 946 var avscity = responseObj.avscity[0]; 947 var avsstate = responseObj.avsstate[0]; 948 var avspostalcode = responseObj.avspostalcode[0]; 949 var customerfirstname = responseObj.customerfirstname[0]; 950 var customerlastname = responseObj.customerlastname[0]; 951 var emailoptin = responseObj.emailoptin[0]; 952 var textoptin = responseObj.textoptin[0]; 953 var emailaddress2 = responseObj.emailaddress2[0]; 954 var username = responseObj.username[0]; 955 var webpassword = responseObj.webpassword[0];
956 var spousename = responseObj.spousename[0]; 957 var birthday = responseObj.birthday[0]; 958 var country = responseObj.country[0]; 959 var shipbirthdate = responseObj.shipbirthdate[0]; 960 var shipcountry= responseObj.shipcountry[0]; 961 var notpickedup= responseObj.notpickedup[0]; 962 var numberpkgsfob= responseObj.numberpkgsfob[0]; 963 var isgift= responseObj.isgift[0]; 964 var giftnotes= responseObj.giftnotes[0]; 965 var numberpkgspickedup= responseObj.numberpkgspickedup[0]; 966 var numberpkgsshipped= responseObj.numberpkgsshipped[0]; 967 var smallestpurchase= responseObj.smallestpurchase[0]; 968 var largestpurchase= responseObj.largestpurchase[0]; 969 var totalproduct= responseObj.totalproduct[0]; 970 var totaldiscount= responseObj.totaldiscount[0]; 971 var totalsellingprice= responseObj.totalsellingprice[0]; 972 var totaltaxes = responseObj.totaltaxes[0]; 973 var totalshipnhandle= responseObj.totalshipnhandle[0]; 974 var totalprice= responseObj.totalprice[0]; 975 var pickuplocation= responseObj.pickuplocation[0]; 976 var firstinvname= responseObj.firstinvname[0]; 977 var secondinvname= responseObj.secondinvname[0]; 978 var thirdinvname= responseObj.thirdinvname[0]; 979 var fourthinvname= responseObj.fourthinvname[0]; 980 var fifthinvname= responseObj.fifthinvname[0]; 981 var statetaxcode= responseObj.statetaxcode[0]; 982 var statetax= responseObj.statetax[0]; 983 var localtax= responseObj.localtax[0]; 984 var taxrate= responseObj.taxrate[0]; 985 var shipfirstname= responseObj.shipfirstname[0]; 986 var shiplastname= responseObj.shiplastname[0]; 987 var shipcompanyname= responseObj.shipcompanyname[0]; 988 var companyname= responseObj.companyname[0]; 989 var giftduration= responseObj.giftduration[0]; 990 var holdforpickup= responseObj.holdforpickup[0]; 991 var tokenizedcreditcard= responseObj.tokenizedcreditcard[0]; 992 var vaultid= responseObj.vaultid[0]; 993 var vaultlast4digits= responseObj.vaultlast4digits[0]; 994 var loyaltycardid= responseObj.loyaltycardid[0]; 995 var enableonhold= responseObj.enableonhold[0]; 996 997 // Set values to form fields active_club_manage_account.php 998 nc("#hid_isloggedin").val(isloggedin); 999 nc("#hid_resultid").val(resultid); 1000 nc("#hid_resultname").val(name); 1001 nc("#hid_description").val(description); 1002 nc("#hid_notes").val(notes); 1003 nc("#hid_billshippingto").val(billshippingto); 1004 nc("#hid_shippersonname").val(shippersonname); 1005 nc("#hid_shipaddress1").val(shipaddress1); 1006 nc("#hid_shipaddress2").val(shipaddress2); 1007 nc("#hid_shipcity").val(shipcity); 1008 nc("#hid_shipstate").val(shipstate); 1009 nc("#hid_shippostalcode").val(shippostalcode); 1010 nc("#hid_shipphone").val(shipphone); 1011 nc("#hid_residentialaddress").val(residentialaddress); 1012 nc("#hid_phonenumber").val(phone); 1013 nc("#hid_phonealternate").val(phonealternate); 1014 nc("#hid_email").val(email); 1015 nc("#hid_creditcardnum").val(creditcardnum); 1016 nc("#hid_creditcardtype").val(creditcardtype); 1017 nc("#hid_expirationmonthyear").val(expirationmonthyear); 1018 nc("#hid_expirationmonth").val(expirationmonth); 1019 nc("#hid_expirationyear").val(expirationyear); 1020 nc("#hid_avsaddress").val(avsaddress); 1021 nc("#hid_avscity").val(avscity); 1022 nc("#hid_avsstate").val(avsstate); 1023 nc("#hid_avspostalcode").val(avspostalcode); 1024 nc("#hid_customerfirstname").val(customerfirstname); 1025 nc("#hid_customerlastname").val(customerlastname); 1026 nc("#hid_emailoptin").val(emailoptin); 1027 nc("#hid_textoptin").val(textoptin); 1028 nc("#hid_emailaddress2").val(emailaddress2); 1029 nc("#hid_username").val(username);
1030 nc("#hid_spousename").val(spousename); 1031 nc("#hid_birthday").val(birthday); 1032 nc("#hid_country").val(country); 1033 nc("#hid_shipbirthdate").val(shipbirthdate); 1034 nc("#hid_shipcountry").val(shipcountry); 1035 nc("#hid_notpickedup").val(notpickedup); 1036 nc("#hid_numberpkgsfob").val(numberpkgsfob); 1037 nc("#hid_isgift").val(isgift); 1038 nc("#hid_giftnotes").val(giftnotes); 1039 nc("#hid_numberpkgspickedup").val(numberpkgspickedup); 1040 nc("#hid_numberpkgsshipped").val(numberpkgsshipped); 1041 nc("#hid_smallestpurchase").val(smallestpurchase); 1042 nc("#hid_largestpurchase").val(largestpurchase); 1043 nc("#hid_totalproduct").val(totalproduct); 1044 nc("#hid_totaldiscount").val(totaldiscount); 1045 nc("#hid_totalsellingprice").val(totalsellingprice); 1046 nc("#hid_totaltaxes").val(totaltaxes); 1047 nc("#hid_totalshipnhandle").val(totalshipnhandle); 1048 nc("#hid_totalprice").val(totalprice); 1049 nc("#hid_pickuplocation").val(pickuplocation); 1050 nc("#hid_firstinvname").val(firstinvname); 1051 nc("#hid_secondinvname").val(secondinvname); 1052 nc("#hid_thirdinvname").val(thirdinvname); 1053 nc("#hid_fourthinvname").val(fourthinvname); 1054 nc("#hid_fifthinvname").val(fifthinvname); 1055 nc("#hid_statetaxcode").val(statetaxcode); 1056 nc("#hid_statetax").val(statetax); 1057 nc("#hid_localtax").val(localtax); 1058 nc("#hid_taxrate").val(taxrate); 1059 nc("#hid_shipfirstname").val(shipfirstname); 1060 nc("#hid_shiplastname").val(shiplastname); 1061 nc("#hid_shipcompanyname").val(shipcompanyname); 1062 nc("#hid_companyname").val(companyname); 1063 nc("#hid_giftduration").val(giftduration); 1064 nc("#hid_holdforpickup").val(holdforpickup); 1065 nc("#hid_tokenizedcreditcard").val(tokenizedcreditcard); 1066 nc("#hid_vaultid").val(vaultid); 1067 nc("#hid_vaultlast4digits").val(vaultlast4digits); 1068 nc("#hid_loyaltycardid").val(loyaltycardid); 1069 nc("#hid_enableonhold").val(enableonhold); 1070 1071 if (splitted[2] != '') { 1072 document.getElementById('user-info-form').submit(); 1073 } 1074 } 1075 } 1076 }); 1077} 1078//signin-account End 1079 1080//Forgot username Start 1081nc("#acs_acc_un").on('submit', function(event) { 1082 event.preventDefault(); 1083 var forgot_email = nc("#forgot-email").val(); 1084 1085 //Email validation 1086 var errors_frgtemail=0; 1087 1088 if(jQuery.trim(forgot_email) != ''){ 1089 var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,5})?$/; 1090 1091 if( !emailReg.test(forgot_email) ) { 1092 errors_frgtemail=1; 1093 //jQuery('#errorwarn').hide('slow'); 1094 jQuery("#forgot-email").addClass("error"); 1095 jQuery("#forgot-email").focus(); 1096 jQuery('#errorwarnfrgtun').show(); 1097 jQuery("#errorwarnfrgtun").empty().html("Please enter valid email."); 1098 return false; 1099 }else{ 1100 errors_frgtemail=0; 1101 jQuery("#forgot-email").removeClass("error"); 1102 jQuery("#errorwarnfrgtun").hide('slow'); //hide email error warning. 1103 } 1104 } 1105 //Email validation end. 1106 1107 var errors = 0; 1108 nc('#acs_acc_un :input[data-required="yes"]').map(function() { 1109 if (!nc(this).val().trim()) { 1110 nc(this).addClass('error'); 1111 errors++; 1112 } else { 1113 nc(this).removeClass('error'); 1114 } 1115 }); 1116 1117 // Empty field validation. 1118 if (errors > 0) { 1119 nc('#errorwarnfrgtun').show(); 1120 nc('#errorwarnfrgtun').empty().html("Please fill the required fields."); 1121 return false; 1122 1123 } else { 1124 1125 nc('#errorwarnfrgtun').hide('slow'); // Hide error warning. 1126 nc.ajax({ 1127 type: "POST", 1128 url: "" + nc('#admin_url').val() + "", 1129 data: { 1130 action: "custom_club_account_frgtusname", 1131 result: "frgtusname", 1132 forgot_email: forgot_email, 1133 }, 1134 beforeSend: function() { 1135 nc('.loader.small-loader_frgtusname').show(); 1136 }, 1137 success: function(msg) { 1138 if (msg) { 1139 //alert(msg) 1140 console.log(msg); 1141 var splitted = msg.split('==='); 1142 1143 nc('.loader.small-loader_frgtusname').hide(); 1144 nc('#final-result_frgtusname').empty(); 1145 nc('#final-result_frgtusname').html(splitted[0]); 1146 1147 /*if (splitted[2] != '') { 1148 document.getElementById('acs_acc_un').submit(); 1149 }*/ 1150 } 1151 } 1152 }); 1153 } 1154}); 1155//forgot username end. 1156 1157//Forgot password start 1158nc("#acs_acc_fp").on('submit', function(event) { 1159 event.preventDefault(); 1160 var forgot_uname = nc("#forgot-username").val(); 1161 1162 var errors = 0; 1163 nc('#acs_acc_fp :input[data-required="yes"]').map(function() { 1164 if (!nc(this).val().trim()) { 1165 nc(this).addClass('error'); 1166 errors++; 1167 } else { 1168 nc(this).removeClass('error'); 1169 } 1170 }); 1171 1172 // Empty field validation. 1173 if (errors > 0) { 1174 nc('#errorwarnfrgtpd').show(); 1175 nc('#errorwarnfrgtpd').html("Please fill the required fields."); 1176 return false;
1177 1178 } else { 1179 1180 nc('#errorwarnfrgtpd').hide('slow'); // Hide error warning. 1181 nc.ajax({ 1182 type: "POST", 1183 url: "" + nc('#admin_url').val() + "", 1184 data: { 1185 action: "custom_club_account_frgtpass", 1186 result: "frgtpass", 1187 forgot_uname: forgot_uname, 1188 }, 1189 beforeSend: function() { 1190 nc('.loader.small-loader_frgtpass').show(); 1191 }, 1192 success: function(msg) { 1193 if (msg) { 1194 //alert(msg) 1195 console.log(msg); 1196 var splitted = msg.split('==='); 1197 1198 nc('.loader.small-loader_frgtpass').hide(); 1199 nc('#final-result_frgtpass').empty(); 1200 nc('#final-result_frgtpass').html(splitted[0]); 1201 1202 /*if (splitted[2] != '') { 1203 document.getElementById('acs_acc_un').submit(); 1204 }*/ 1205 } 1206 } 1207 }); 1208 } 1209}); 1210//Forgot password end. 1211 1212//Reset new password start 1213nc("#acs_acc_rp").on('submit', function(event) { 1214 event.preventDefault(); 1215 var new_reset_pass = nc("#new-reset-password").val(); 1216 var encryptresetpassword = nc("#encryptresetpassword").val(); 1217 var reset = nc("#reset").val(); 1218 var chkword = nc("#chkword").val(); 1219 var account_login_url = nc("#account_login_url").val(); 1220 var source = nc("#encryptresetpassword").data('source'); 1221 1222 var errors = 0; 1223 nc('#acs_acc_rp :input[data-required="yes"]').map(function() { 1224 if (!nc(this).val().trim()) { 1225 nc(this).addClass('error'); 1226 errors++; 1227 } else { 1228 nc(this).removeClass('error'); 1229 } 1230 }); 1231 1232 // Empty field validation. 1233 if (errors > 0) { 1234 nc('#errorwarnresetpass').show(); 1235 nc('#errorwarnresetpass').html("Please fill the required fields."); 1236 return false; 1237 1238 } else { 1239 1240 nc('#errorwarnsignin').hide('slow'); // Hide error warning. 1241 1242 // If encrypted password is missing, encrypt first 1243 if (new_reset_pass !== '' && (encryptresetpassword === '' || source !== new_reset_pass)) { 1244 nc.ajax({ 1245 type: "POST", 1246 url: nc('#admin_url').val(), 1247 data: "action=get_password_encrypt&result=passenc&webpassword=" + encodeURIComponent(new_reset_pass), 1248 beforeSend: function() { 1249 nc('.loader.small-loader_resetpass').show(); 1250 }, 1251 success: function(msg) { 1252 if (msg) { 1253 nc('#encryptresetpassword').val(msg); 1254 encryptresetpassword = msg; 1255 resetPasswd(encryptresetpassword,reset,chkword,account_login_url); // Call Reset function 1256 } 1257 } 1258 }); 1259 1260 } else { 1261 resetPasswd(encryptresetpassword,reset,chkword,account_login_url); 1262 } 1263 } 1264}); 1265 1266//Reset Password function 1267function resetPasswd(encryptresetpassword,reset,chkword,account_login_url){ 1268 nc('#errorwarnresetpass').hide('slow'); // Hide error warning. 1269 nc.ajax({ 1270 type: "POST", 1271 url: "" + nc('#admin_url').val() + "", 1272 data: { 1273 action: "custom_club_reset_password", 1274 result: "resetpass", 1275 encryptresetpassword: encryptresetpassword, 1276 reset : reset, 1277 chkword : chkword, 1278 }, 1279 beforeSend: function() { 1280 nc('.loader.small-loader_resetpass').show(); 1281 }, 1282 success: function(msg) { 1283 if (msg) { 1284 //alert(msg) 1285 console.log(msg); 1286 var splitted = msg.split('==='); 1287 1288 nc('.loader.small-loader_resetpass').hide(); 1289 nc('#final-result_resetpass').empty(); 1290 nc('#final-result_resetpass').html(splitted[0]); 1291 1292 if(splitted[1] == 1){ 1293 window.location.href = account_login_url; 1294 } 1295 } 1296 } 1297 }); 1298} 1299//Reset new password end. 1300 1301//forgotusname hide/show 1302nc("#frgt-user, #show-frgt-uname-cont").on('click', function(){ 1303 nc("#user-info-form, #cart-user-info-form").hide(); 1304 nc("#forgot-password-container").hide(); 1305 nc("#forgot-username-container").show(); 1306}); 1307 1308//forgot passowrd hide/show 1309nc("#frgt-pass, #show-frgt-pass-cont").on('click', function(){ 1310 nc("#user-info-form, #cart-user-info-form").hide(); 1311 nc("#forgot-username-container").hide(); 1312 nc("#forgot-password-container").show(); 1313}); 1314 1315//cancel-frgtusname, show login form 1316nc("#cancel-frgtusname, #cancel-frgtpass").on('click', function(){ 1317 nc("#forgot-username-container").hide(); 1318 nc("#forgot-password-container").hide(); 1319 nc("#user-info-form, #cart-user-info-form").show(); 1320}); 1321 1322// Club Membership Section below code start 1323//Club membership 1324nc("#manage_account_club_show").show(); 1325nc("#manage_account_club_edit").hide(); 1326nc("#manage_account_club_done").hide(); 1327 1328//Club Membership Done link click event. 1329nc("#manage_account_club_done").on('click', function(){ 1330 nc("#manage_account_club_show").show(); 1331 nc("#manage_account_club_edit").hide(); 1332 nc("#manage_account_club_done").hide(); 1333 nc("#membership_edit_club").show(); 1334 1335 var giftmessage = nc("#giftmessage").val(); 1336 nc("#gift-txt").empty().html(giftmessage); 1337 1338 //default address display 1339 var address1 = nc("#selected_shipping_address1").val();
1340 var address2 = nc("#selected_shipping_address2").val(); 1341 var city = nc("#selected_shipping_city").val(); 1342 var state = nc("#selected_shipping_state").val(); 1343 var postal = nc("#selected_shipping_postal").val(); 1344 1345 nc("#deliv-ship-address1").empty().html(address1); 1346 nc("#deliv-ship-address2").empty().html(address2); 1347 nc("#deliv-ship-city").empty().html(city); 1348 nc("#deliv-ship-state").empty().html(state); 1349 nc("#deliv-ship-postal").empty().html(postal); 1350 1351 //pickup address 1352 var pickup = nc("#selected_pickup_address_id-cm").val(); 1353 nc("#hid_pickuplocation").empty().html(pickup); 1354 1355 //change billshippingto value 1356 // Attach tab change handler ONCE 1357 setTimeout(function() { 1358 var curVal = nc('.pills-tab-edit a.active').attr('data-val'); 1359 nc('#billshippingto').val(curVal); 1360 //console.log("Updated input to:", curVal); 1361 }, 100); // small delay to let class update 1362 1363}); 1364 1365 1366//Club Membership Edit link click event start 1367nc('#membership_edit_club').on('click', function(){ 1368 nc("#manage_account_club_show").hide(); 1369 nc("#manage_account_club_edit").show(); 1370 nc("#manage_account_club_done").show(); 1371 nc("#membership_edit_club").hide(); 1372 1373 // billshippingto 1374 var billshippingto = nc("#billshippingto").val(); 1375 //alert(billshippingto); 1376 1377 if(billshippingto === 'Pickup') //pickup part 1378 { 1379 var CustomerId = nc("#hid_resultid").val(); 1380 var membership_edit_club =nc("#membership_edit_club").text(); 1381 var select_pickuplocationaddress = nc(".hid_pickuplocation").val(); 1382 // alert(membership_edit_club) 1383 1384 // Remove active class and aria-selected from other tabs 1385 nc('.pills-tab-edit .nav-item a').removeClass('active').attr('aria-selected', 'false'); 1386 nc('#manage_account_club_edit .tab-pane').removeClass('active show'); 1387 1388 // Add active class and aria-selected to pickup-tab2 1389 nc('#pickup-tab2').addClass('active').attr('aria-selected', 'true'); 1390 nc('#pills-profile2').addClass('active show'); 1391 1392 nc.ajax({ 1393 type: "POST", 1394 url: "" + nc('#admin_url').val() + "", 1395 data: { 1396 action: "custom_club_membership_pickup", 1397 result: "login", 1398 customerId: CustomerId, 1399 select_pickuplocationaddress:select_pickuplocationaddress, 1400 }, 1401 beforeSend: function() { 1402 nc('.loader.small-loader_sign').show(); 1403 }, 1404 success: function(msg) { 1405 if(msg){ 1406 console.log(msg); 1407 1408 var splitted = msg.split('==='); 1409 //alert(splitted[0]) Success===Other Duplex===Candy Good===2596 Parkwood Drive======Green Bay===WI===54304===1===1561===1561===2596 Parkwood 1410 if(splitted[1] == 'Success'){ 1411 var ship_city_state_postalcode = splitted[4]+', '+splitted[5]+', '+splitted[6]+', '+splitted[7]; 1412 nc('.dropdown-btn-cm').empty(); 1413 nc('.dropdown-btn-cm').text(splitted[2]+' - '+splitted[3]+', '+ship_city_state_postalcode); //data display in select dropdown 1414 nc('.dropdown-content-cm').empty(); 1415 nc('.dropdown-content-cm').html(splitted[0]); 1416 nc('#cm-pickup-nickname').text(splitted[2]); 1417 nc('#cm-pickup-address1').text(splitted[3]); 1418 nc('#cm-pickup_city_state_postalcode').text(ship_city_state_postalcode); 1419 } 1420 } 1421 } 1422 }); 1423 1424 }else{ 1425 1426 var CustomerId = nc("#hid_resultid").val(); 1427 1428 // Remove active class and aria-selected from other tabs 1429 nc('.pills-tab-edit .nav-item a').removeClass('active').attr('aria-selected', 'false'); 1430 nc('#manage_account_club_edit .tab-pane').removeClass('active show'); 1431 1432 // Add active class and aria-selected to ship-tab1 1433 nc('#ship-tab1').addClass('active').attr('aria-selected', 'true'); 1434 nc('#pills-home1').addClass('active show'); 1435 1436 nc.ajax({ 1437 type: "POST", 1438 url: "" + nc('#admin_url').val() + "", 1439 1440 data: { 1441 action: "custom_club_membership_edit", 1442 result: "login", 1443 customerId: CustomerId, 1444 }, 1445 beforeSend: function() { 1446 nc('.loader.small-loader_sign').show(); 1447 }, 1448 success: function(msg) { 1449 1450 if(msg){ 1451 console.log(msg); 1452 //alert(msg); 1453 1454 var splitted = msg.split('==='); 1455 var ship_nickname= splitted[2]; 1456 var ship_companyname= splitted[3]; 1457 var ship_address1= splitted[4]+', '+splitted[5]; 1458 var ship_city_state_postalcode= splitted[6]+', '+splitted[7]+', '+splitted[8]; 1459 var ship_addressid= splitted[10]; 1460 //alert(splitted[0]) Success===Other Duplex===Candy Good===2596 Parkwood Drive======Green Bay===WI===54304===1===1561===1561===2596 Parkwood 1461 1462 if(splitted[1] == 'Success'){ 1463 nc('.dropdown-btn-cm').empty(); 1464 //nc('.dropdown-btn-cm').html(splitted[12]); 1465 nc('.dropdown-btn-cm').html(ship_nickname+' - '+splitted[12]+', '+ship_city_state_postalcode); 1466 nc('.dropdown-content-cm').empty(); 1467 nc('.dropdown-content-cm').html(splitted[0]); 1468 nc('#cm-ship-nickname').text(ship_nickname); 1469 nc('#cm-ship-address1').text(ship_address1); 1470 nc('#cm-ship_city_state_postalcode').text(ship_city_state_postalcode); 1471 } 1472 } 1473 } 1474 }); 1475 } 1476}); 1477 1478 1479//Club Membership Form click in pickup but without edit click 1480/*nc('#membership_edit_club_pickup').on('click',function(){ 1481 var CustomerId = nc("#hid_resultid").val(); 1482 var membership_edit_club =nc("#membership_edit_club").text(); 1483 //alert(membership_edit_club) 1484 nc.ajax({ 1485 type: "POST", 1486 url: "" + nc('#admin_url').val() + "", 1487 data: { 1488 action: "custom_club_membership_pickup", 1489 result: "login", 1490 customerId: CustomerId, 1491 }, 1492 beforeSend: function() { 1493 nc('.loader.small-loader_sign').show(); 1494 }, 1495 success: function(msg) { 1496 if(msg){ 1497 console.log(msg); 1498 var splitted = msg.split('==='); 1499 //alert(splitted[0]) Success===Other Duplex===Candy Good===2596 Parkwood Drive======Green Bay===WI===54304===1===1561===1561===2596 Parkwood 1500 1501 if(splitted[1] == 'Success'){ 1502 var ship_city_state_postalcode= splitted[4]+', '+splitted[5]+', '+splitted[6]+', '+splitted[7]; 1503 nc('.dropdown-btn-cm').empty(); 1504 nc('.dropdown-btn-cm').text(splitted[3]+' - '+ship_city_state_postalcode); //data display in select dropdown 1505 nc('.dropdown-content-cm').empty(); 1506 nc('.dropdown-content-cm').html(splitted[0]); 1507 nc('#cm-pickup-nickname').text(splitted[3]); 1508 nc('#cm-pickup-address1').text(splitted[4]); 1509 nc('#cm-pickup_city_state_postalcode').text(ship_city_state_postalcode); 1510 } 1511 } 1512 } 1513 }); 1514});*/ 1515 1516//Club Membership part bottom part ship tab Click on Ship Underline part 1517nc('#ship-tab1').on('click',function(){ 1518 nc('.dropdown-btn-cm').text('Choose a Shipping Address'); 1519 nc('.dropdown-content-cm').empty(); 1520 var CustomerId = nc("#hid_resultid").val(); 1521 // alert(CustomerId) 1522 nc.ajax({ 1523 type: "POST", 1524 url: "" + nc('#admin_url').val() + "", 1525 data: { 1526 action: "custom_club_membership_edit", 1527 result: "login", 1528 customerId: CustomerId, 1529 }, 1530 beforeSend: function() { 1531 nc('.loader.small-loader_sign').show(); 1532 }, 1533 success: function(msg) { 1534 if(msg){ 1535 console.log(msg); 1536 //alert(msg); 1537 var splitted = msg.split('==='); 1538 var ship_nickname= splitted[2]; 1539 var ship_companyname= splitted[3]; 1540 var ship_address1= splitted[4]+', '+splitted[5]; 1541 var ship_city_state_postalcode= splitted[6]+', '+splitted[7]+', '+splitted[8]; 1542 var ship_addressid= splitted[10]; 1543 //alert(splitted[0]) Success===Other Duplex===Candy Good===2596 Parkwood Drive======Green Bay===WI===54304===1===1561===1561===2596 Parkwood 1544 if(splitted[1] == 'Success'){ 1545 nc('.dropdown-btn-cm').empty(); 1546 nc('.dropdown-btn-cm').html(ship_nickname+' - '+splitted[12]+', '+ship_city_state_postalcode); 1547 nc('.dropdown-content-cm').empty(); 1548 nc('.dropdown-content-cm').html(splitted[0]); 1549 nc('#cm-ship-nickname').text(ship_nickname); 1550 nc('#cm-ship-address1').text(ship_address1); 1551 nc('#cm-ship_city_state_postalcode').text(ship_city_state_postalcode); 1552 } 1553 } 1554 } 1555 }); 1556}); 1557 1558//Club Membership Form bottom part pickup tab Click on select drop down section in Pickup part section dropdown-content-cm 1559nc('#pickup-tab2').on('click',function(){ 1560 nc('.dropdown-btn-cm').text('Choose a Pickup Address'); 1561 nc('.dropdown-content-cm').empty(); 1562 var select_pickuplocationaddress = nc(".hid_pickuplocation").val(); 1563 // alert(select_category_id) 1564 var CustomerId = nc("#hid_resultid").val(); 1565 1566 nc.ajax({ 1567 type: "POST", 1568 url: "" + nc('#admin_url').val() + "", 1569 data: { 1570 action: "custom_club_membership_pickup", 1571 result: "login", 1572 customerId: CustomerId, 1573 select_pickuplocationaddress:select_pickuplocationaddress, 1574 }, 1575 beforeSend: function() { 1576 nc('.loader.small-loader_sign').show(); 1577 }, 1578 success: function(msg) { 1579 if(msg){ 1580 console.log(msg); 1581 // alert(1) 1582 var splitted = msg.split('==='); 1583 //alert(splitted[0]) Success===Other Duplex===Candy Good===2596 Parkwood Drive======Green Bay===WI===54304===1===1561===1561===2596 Parkwood 1584 if(splitted[1] == 'Success'){ 1585 var ship_city_state_postalcode = splitted[4]+', '+splitted[5]+', '+splitted[6]+', '+splitted[7]; 1586 nc('.dropdown-btn-cm').empty(); 1587 nc('.dropdown-btn-cm').text(splitted[2]+' - '+splitted[3]+', '+ship_city_state_postalcode); //data display in select dropdown 1588 nc('.dropdown-content-cm').empty(); 1589 nc('.dropdown-content-cm').html(splitted[0]); 1590 nc('#cm-pickup-nickname').text(splitted[2]); 1591 nc('#cm-pickup-address1').text(splitted[3]); 1592 nc('#cm-pickup_city_state_postalcode').text(ship_city_state_postalcode); 1593 } 1594 } 1595 } 1596 }); 1597}); 1598 1599//Shipping Address Id wise select-category on change get address to display dropdown-btn-cm 1600nc("#selected_pickup_address_id-cm").on('focus', function(){ 1601 var thisValue = nc(this).val(); 1602 var CustomerId = nc("#hid_resultid").val(); 1603 var select_category_id =thisValue;
1603// nc("#select-shipping-address").val(); 1604 //alert(thisValue) 1605 nc.ajax({ 1606 type: "POST", 1607 url:""+nc('#admin_url').val()+"", 1608 data: { 1609 action: "pickupaddress_select_category", 1610 pickupaddress: select_category_id, 1611 CustomerId: CustomerId, 1612 }, 1613 beforeSend: function(){ 1614 }, 1615 success: function(msg){ 1616 if(msg){ 1617 console.log(msg); 1618 //alert(msg); 1619 // nc('#ship-addressid').val(''); 1620 nc('#new-addedit').val(''); 1621 nc('#cm-pickup-nickname').val(''); 1622 nc('#cm-pickup-address1').val(''); 1623 nc('#cm-pickup_city_state_postalcode').val(''); 1624 var splitted = msg.split('==='); 1625 //alert(splitted[0]) 1626 var ship_nickname= splitted[1]; 1627 var ship_address1= splitted[2]+', '+splitted[4]; 1628 var ship_city_state_postalcode= splitted[5]+', '+splitted[6]+', '+splitted[7]; 1629 1630 if(splitted[0] == 'Success'){ 1631 nc('.dropdown-btn-cm').empty(); 1632 nc('.dropdown-btn-cm').text(splitted[1]+' - '+ship_address1+','+ship_city_state_postalcode);//data display in select dropdown 1633 nc('.dropdown-content-cm').empty(); 1634 nc('.dropdown-content-cm').html(splitted[8]);// data list 1635 nc('#cm-pickup-nickname').text(ship_nickname); 1636 nc('#cm-pickup-address1').text(ship_address1); 1637 nc('#cm-pickup_city_state_postalcode').text(ship_city_state_postalcode); 1638 } 1639 } 1640 } 1641 }); 1642}); 1643 1644//Shipping Address Id wise select-category on change get address to display 1645nc("#selected_shipping_address_id-cm").on('focus', function(){ 1646 var thisValue = nc(this).val(); 1647 var CustomerId = nc("#hid_resultid").val(); 1648 var select_category_id =thisValue;// nc("#select-shipping-address").val(); 1649 1650 nc.ajax({ 1651 type: "POST", 1652 url:""+nc('#admin_url').val()+"", 1653 data: { 1654 action: "shippinaddress_select_category", 1655 ShipAddressId: select_category_id, 1656 CustomerId: CustomerId, 1657 }, 1658 beforeSend: function(){ 1659 }, 1660 success: function(msg){ 1661 if(msg){ 1662 console.log(msg); 1663 //alert(msg); 1664 // nc('#ship-addressid').val(''); dropdown-content-cm 1665 nc('#new-addedit').val(''); 1666 nc('#cm-ship-nickname').val(''); 1667 nc('#ship-companyname').val(''); 1668 nc('#ship-address1').val(''); 1669 nc('#ship-address2').val(''); 1670 nc('#ship-city').val(''); 1671 nc('#ship-state').val(''); 1672 nc('#ship-postalcode').val(''); 1673 var splitted = msg.split('==='); 1674 //alert(splitted[0]) 1675 var ship_nickname= splitted[1]; 1676 var ship_companyname= splitted[2]; 1677 var ship_address1= splitted[3]+', '+splitted[4]; 1678 var ship_city_state_postalcode= splitted[5]+', '+splitted[6]+', '+splitted[7]; 1679 var ship_addressid= splitted[8]; 1680 var ship_isdefault= splitted[9]; 1681 1682 if(splitted[0] == 'Success'){ 1683 nc('.dropdown-btn-cm').empty(); 1684 nc('.dropdown-btn-cm').html(ship_nickname+' - '+splitted[3]+', '+ship_city_state_postalcode); 1685 //nc('.dropdown-content-cm').empty(); 1686 //nc('.dropdown-content-cm').html(splitted[0]); 1687 nc('#cm-ship-nickname').text(ship_nickname); 1688 nc('#ship-companyname').text(ship_companyname); 1689 nc('#cm-ship-address1').text(ship_address1); 1690 nc('#cm-ship_city_state_postalcode').text(ship_city_state_postalcode); 1691 } 1692 } 1693 } 1694 }); 1695}); 1696 1697//Club membership Hold Club is No dates tr will hide 1698nc(".onhold-flexSwitch").on('change', function(){ 1699 var rowId = this.getAttribute('data-target-row'); 1700 var parts = rowId.split('_'); 1701 var afterUnderscore = parts[1]; 1702 var row = document.getElementById(rowId); 1703 1704 // Check if the row exists 1705 if (!this.checked) { 1706 row.style.display = 'none'; 1707 } else { 1708 row.style.display = ''; // Show the row when the checkbox is checked 1709 var checkboxId = 'selection-flexSwitchCheckDefault_' + afterUnderscore; 1710 var checkbox = document.getElementById(checkboxId); 1711 1712 // Unchecking the checkbox if it exists 1713 if (checkbox) { 1714 checkbox.checked = false;
1715 } 1716 1717 var currentDate = new Date().toISOString().slice(0, 10); // Get current date in YYYY-MM-DD format 1718 nc('#suspend-date_'+afterUnderscore).val(currentDate); 1719 nc('#restart-date_'+afterUnderscore).val(''); 1720 } 1721}); 1722 1723//selection switch Active or Inactive 1724nc(".selection-flexSwitch").on('change', function(){ 1725 1726 var rowId = this.getAttribute('data-target-row'); 1727 var parts = rowId.split('_'); 1728 var afterUnderscore = parts[1]; 1729 var row = document.getElementById(rowId); 1730 1731 // Check if the row exists 1732 if (!this.checked) { 1733 1734 // row.style.display = 'none'; 1735 1736 //disable on hold 1737 var checkboxId = 'hold-flexSwitchCheckDefault_' + afterUnderscore; 1738 var checkbox = document.getElementById(checkboxId); 1739 if (checkbox) { 1740 checkbox.checked = false; 1741 checkbox.disabled = true; 1742 } 1743 //end 1744 1745 var dates = document.getElementById('dates_'+afterUnderscore) 1746 if (dates) { 1747 dates.style.display = 'none'; 1748 } 1749 1750 } else { 1751 1752 var checkboxId = 'hold-flexSwitchCheckDefault_' + afterUnderscore; 1753 var checkbox = document.getElementById(checkboxId); 1754 1755 // Unchecking the checkbox if it exists 1756 if (checkbox) { 1757 checkbox.checked = false; 1758 checkbox.disabled = false; 1759 } 1760 1761 var dates = document.getElementById('dates_'+afterUnderscore) 1762 if (dates) { 1763 dates.style.display = 'none'; 1764 } 1765 } 1766}); 1767 1768//Club membership Top part data's save part 1769nc("#club_membership_savemembership").on('click', function() { 1770 1771 var CustomerId = nc("#hid_resultid").val(); 1772 var clubMembershipDetails = []; 1773 1774 nc(".club_membershiprowid").each(function() { 1775 var row = nc(this); 1776 var club_membership_id = row.attr("id"); 1777 var selection_Check = row.find(".selection-flexSwitch").is(':checked') ? 'Active' : 'Inactive'; 1778 var hold_Check = row.find(".onhold-flexSwitch").is(':checked'); 1779 var status_Check = nc("#club_membership_status_" + club_membership_id).val();
1780 var suspend_date = nc("#suspend-date_" + club_membership_id).val(); 1781 var restart_date = nc("#restart-date_" + club_membership_id).val(); 1782 1783 1784 // Debugging logs 1785 /*console.log("club_membership_id:", club_membership_id); 1786 console.log("selection_Check:", selection_Check); 1787 console.log("hold_Check:", hold_Check); 1788 console.log("status_Check:", status_Check); 1789 console.log("suspend_date:", suspend_date); 1790 console.log("restart_date:", restart_date);*/ 1791 1792 // Clear any previous error messages 1793 jQuery('#span_to_restartdate_' + club_membership_id).text(''); 1794 row.find('#span_to_restartdate_' + club_membership_id).text(''); 1795 1796 clubMembershipDetails.push({ 1797 club_membership_id: club_membership_id, 1798 selection_Check: selection_Check, 1799 hold_Check: hold_Check, 1800 status_Check:status_Check, 1801 suspend_date: suspend_date, 1802 restart_date: restart_date 1803 }); 1804 1805 // Check if restart_date is empty 1806 if (!restart_date) { 1807 // Add error message to the row 1808 //row.append('<div class="error-message" style="color: red;">Restart date cannot be empty.</div>'); 1809 jQuery('#span_to_restartdate_' + club_membership_id).text('Restart date cannot be empty') 1810 .css({ 1811 'color': 'red', 1812 'text-align': 'center' 1813 }); 1814 1815 return; // Skip the rest of the code for this row 1816 } 1817 }); 1818 console.log("clubMembershipDetails:", clubMembershipDetails); //Test output 1819 1820 //ajax save membership 1821 nc.ajax({ 1822 type: "POST", 1823 url: nc('#admin_url').val(), 1824 data: { 1825 action: "club_membership_savemembership", 1826 CustomerId: CustomerId, 1827 clubMembershipDetails: clubMembershipDetails 1828 }, 1829 beforeSend: function() { 1830 nc('.loader.small-loader_savemembership').show(); 1831 }, 1832 success: function(response) { 1833 nc('.loader.small-loader_savemembership').hide(); 1834 1835 console.log(response); 1836 //Activate tab and display "Available" label on left menu for "club membership" 1837 if (response) { 1838 if (response === 'Yes') { 1839 nc('.mem-avai').empty().html('Available'); //manange account sidebar 1840 1841 //manange account sidebar 1842 nc('#mem-chice') 1843 .attr('class', 'tab') // your custom class 1844 .attr('data-target', '#club-memberchoice') 1845 .removeAttr('data-bs-toggle') 1846 .removeAttr('data-bs-target') 1847 .off('click') // remove old click 1848 .on('click', function (e) { 1849 e.preventDefault(); 1850 1851 // Deactivate all tabs 1852 nc('.tab').removeClass('active'); 1853 1854 // Hide all .content elements (other tab content) 1855 nc('.manage-acc-content').css('display', 'none'); 1856 1857 // Activate the clicked tab 1858 nc(this).addClass('active'); 1859 1860 // Show the related tab pane 1861 var target = nc(this).attr('data-target'); 1862 nc(target).addClass('active show').css('display', 'block'); // Show the specific tab content 1863 }); 1864 1865 //Activate dropdown menu 1866 nc('.mem-chice') 1867 .attr('href', nc('#site_url').val() + '/acs-manage-account/?tab=club-memberchoice') 1868 .attr('data-tab', 'club-memberchoice') 1869 .removeAttr('data-bs-toggle') // remove modal behavior 1870 .removeAttr('data-bs-target') 1871 .css('color', '#fff'); 1872 1873 nc('.mem-avai').html('Available'); 1874 nc('.mem-chice').closest('li').addClass('bgf4'); // apply background 1875 //dropdown end. 1876 1877 } else { 1878 nc('.mem-avai').empty(); 1879 1880 nc('#mem-chice') 1881 .removeAttr('class') 1882 .removeAttr('data-target') 1883 .off('click') // remove old click 1884 .on('click', function (e) { 1885 e.preventDefault(); 1886 openModal('memberchoice-popup'); // call our custom modal 1887 }); 1888 1889 //Deactive Dropdown menu 1890 nc('.mem-chice') 1891 .attr('href', 'javascript:void(0);') 1892 .removeAttr('data-tab') 1893 .removeAttr('data-bs-toggle') 1894 .removeAttr('data-bs-target') 1895 .css('color', '') // reset color 1896 .off('click') // remove old click 1897 .on('click', function (e) { 1898 e.preventDefault(); 1899 openModal('memberchoice-popup'); // call our custom modal 1900 }); 1901 1902 1903 nc('.mem-avai').empty(); 1904 nc('.mem-chice').closest('li').removeClass('bgf4'); // remove background 1905 //Dropdown menu ends. 1906 1907 }//manange account sidebar end. 1908 }//End 1909 1910 // Handle success 1911 nc('#span_to_post_response_savemembership').text('Your account details have been saved.') 1912 .css({ 1913 'color': 'green', 1914 'text-align': 'center', 1915 'margin-bottom': '1.5rem' 1916 }) 1917 .show() 1918 .delay(3000) // Adjust the delay time in milliseconds (2000ms = 2 seconds) 1919 .fadeOut(); 1920 }, 1921 error: function(xhr, status, error) { 1922 console.error(xhr.responseText); 1923 // Handle error 1924 } 1925 }); 1926}); 1927 1928//Club membership bottom part data's save part 1929nc("#club_membership_savedetail").on('click', function() { 1930 1931 var CustomerId = nc("#hid_resultid").val(); 1932 //var billshippingto = nc("#billshippingto").val(); 1933 var billshippingto = nc('.pills-tab-edit .nav-item a.active').data('val'); 1934 var selected_shipping_address_id = nc("#selected_shipping_address_id-cm").val(); 1935 var selected_pickup_address_id = nc("#selected_pickup_address_id-cm").val(); 1936 //var deliveryinstructions = nc("#deliveryinstructions").val(); 1937 var giftmessage = nc("#giftmessage").val(); 1938 var giftemail = nc("#giftemailaddress").val(); 1939 var giftoptin = nc("#giftoptin").val(); 1940 1941 var selected_shipping_nick = nc("#selected_shipping_nick").val(); 1942 var selected_shipping_company = nc("#selected_shipping_company").val(); 1943 var selected_shipping_address1 = nc("#selected_shipping_address1").val();
1944 var selected_shipping_address2 = nc("#selected_shipping_address2").val(); 1945 var selected_shipping_city = nc("#selected_shipping_city").val(); 1946 var selected_shipping_state = nc("#selected_shipping_state").val(); 1947 var selected_shipping_postal = nc("#selected_shipping_postal").val(); 1948 var selected_shipping_phone = nc("#selected_shipping_phone").val(); 1949 var selected_shipping_email = nc("#selected_shipping_email").val(); 1950 var selected_shipping_fname = nc("#selected_shipping_fname").val(); 1951 var selected_shipping_lname = nc("#selected_shipping_lname").val(); 1952 var selected_shipping_dob = nc("#selected_shipping_dob").val(); 1953 1954 nc.ajax({ 1955 type: "POST", 1956 url: nc('#admin_url').val(), 1957 data: { 1958 action: "club_membership_savedetail", 1959 CustomerId: CustomerId, 1960 billshippingto: billshippingto, 1961 selected_shipping_address_id: selected_shipping_address_id, 1962 selected_pickup_address_id: selected_pickup_address_id, 1963 //deliveryinstructions: deliveryinstructions, 1964 giftoptin: giftoptin, 1965 giftemail: giftemail, 1966 giftmessage: giftmessage, 1967 selected_shipping_nick:selected_shipping_nick, 1968 selected_shipping_company:selected_shipping_company, 1969 selected_shipping_address1:selected_shipping_address1, 1970 selected_shipping_address2:selected_shipping_address2, 1971 selected_shipping_city:selected_shipping_city, 1972 selected_shipping_state:selected_shipping_state, 1973 selected_shipping_postal:selected_shipping_postal, 1974 selected_shipping_phone:selected_shipping_phone, 1975 selected_shipping_email:selected_shipping_email, 1976 selected_shipping_fname:selected_shipping_fname, 1977 selected_shipping_lname:selected_shipping_lname, 1978 selected_shipping_dob:selected_shipping_dob, 1979 }, 1980 beforeSend: function() { 1981 nc('.loader.small-loader_savedetail').show(); 1982 }, 1983 success: function(response) { 1984 console.log(response); 1985 1986 nc('.loader.small-loader_savedetail').hide(); 1987 1988 // Handle success 1989 nc('#span_to_post_response_savedetail').text('Your account details have been saved.') 1990 .css({ 1991 'color': 'green', 1992 'text-align': 'center', 1993 'margin-bottom': '1.5rem' 1994 }) 1995 .show() 1996 .delay(3000) // Adjust the delay time in milliseconds (2000ms = 2 seconds) 1997 .fadeOut(); 1998 }, 1999 error: function(xhr, status, error) { 2000 console.error(xhr.responseText); 2001 // Handle error 2002 } 2003 }); 2004}); 2005 2006//Member choice available add more button click part started 2007nc(document).on('click', '#add-more-btn', function(){ 2008 2009 var CustomerId = nc("#hid_resultid").val(); 2010 var sourcecode = nc("#sourcecode").val(); 2011 var totalqty = nc("#total_qty").val(); 2012 var maxqty = nc("#max_qty").val(); 2013 2014 //alert(CustomerId) 2015 nc.ajax({ 2016 type: "POST", 2017 url: nc('#admin_url').val(), 2018 data: { 2019 action: "club_memberchoice_available_addmorebtn", 2020 CustomerId: CustomerId, 2021 sourcecode: sourcecode, 2022 totalqty:totalqty, 2023 maxqty:maxqty 2024 }, 2025 beforeSend: function() { 2026 nc('.cart-section.addmore, .catalog-title.addmore-replace').empty(); 2027 nc('.small-loader').show(); 2028 }, 2029 success: function(response) { 2030 //console.log(response); 2031 nc('.small-loader').hide('slow'); 2032 2033 if(response){ 2034 //alert(response); 2035 nc('.catalog-title.addmore-replace').empty().html('Add More'); 2036 nc('.cart-section.addmore').empty().html(response); 2037 } 2038 }, 2039 error: function(xhr, status, error) { 2040 console.error(xhr.responseText); 2041 // Handle error 2042 } 2043 }); 2044}); 2045 2046//Replace button 2047nc(document).on('click', '.replace-btn', function(){ 2048 2049 var CustomerId = nc("#hid_resultid").val();
2050 var sourcecode = nc("#sourcecode").val(); 2051 var inventoryId = nc(this).data('id'); 2052 2053 nc.ajax({ 2054 type: "POST", 2055 url: nc('#admin_url').val(), 2056 data: { 2057 action: "club_memberchoice_available_replacebtn", 2058 CustomerId: CustomerId, 2059 sourcecode: sourcecode, 2060 inventoryId: inventoryId, 2061 }, 2062 beforeSend: function() { 2063 nc('.cart-section.addmore, .catalog-title.addmore-replace').empty(); 2064 nc('.small-loader').show(); 2065 }, 2066 success: function(response) { 2067 console.log(response); 2068 nc('.small-loader').hide('slow'); 2069 2070 if(response){ 2071 //alert(response); 2072 nc('.catalog-title.addmore-replace').empty().html('Replace'); 2073 nc('.cart-section.addmore').empty().html(response); 2074 } 2075 }, 2076 error: function(xhr, status, error) { 2077 console.error(xhr.responseText); 2078 // Handle error 2079 } 2080 }); 2081}); 2082 2083//Member Choice Quantity +/- deisgn modified. Find the input[type=number] element decrease its value 2084nc(document).on('click', '.mem-minus', function() { 2085 jQuery(this).parent().find('input[type=number]').get(0).stepDown(); 2086}); 2087 2088//Member Choice Quantity +/- deisgn modified. Find the input[type=number] element increase its value 2089nc(document).on('click', '.mem-plus', function() { 2090 jQuery(this).parent().find('input[type=number]').get(0).stepUp(); 2091}); 2092 2093//Request Email confirmation 2094nc('#request-email-confirmation').on('click', function(){ 2095 2096 var CustomerId = nc("#hid_resultid").val(); 2097 2098 nc.ajax({ 2099 type: "POST", 2100 url: nc('#admin_url').val(), 2101 data: { 2102 action: "club_memberchoice_emailconfirmation", 2103 result: 'email', 2104 CustomerId: CustomerId, 2105 }, 2106 beforeSend: function() { 2107 nc('#request-email-confirmation').empty().html('L o a d i n g...'); 2108 }, 2109 success: function(response) { 2110 console.log(response); 2111 nc('#request-email-confirmation').empty().html('Requst Email Confirmation'); 2112 2113 if(response){ 2114 //alert(response);exit; 2115 nc('.email-confirmation-response').empty().html(response) 2116 .show() 2117 .delay(3000) // Adjust the delay time in milliseconds (2000ms = 2 seconds) 2118 .fadeOut(); 2119 } 2120 }, 2121 error: function(xhr, status, error) { 2122 console.error(xhr.responseText); 2123 // Handle error 2124 } 2125 }); 2126}); 2127 2128//Clear Choices Button 2129nc('#clear-btn').on('click', function(){ 2130 var CustomerId = nc("#hid_resultid").val(); 2131 2132 nc.ajax({ 2133 type: "POST", 2134 url: nc('#admin_url').val(), 2135 data: { 2136 action: "club_memberchoice_clear", 2137 result: 'clear', 2138 CustomerId: CustomerId, 2139 }, 2140 beforeSend: function() { 2141 nc('#clear-btn').empty().html('Loading...'); 2142 }, 2143 success: function(msg) { 2144 console.log(msg); 2145 nc('#clear-btn').empty().html('Clear Choices'); 2146 2147 if(msg){ 2148 //alert(msg); 2149 var splitted = msg.split('==='); 2150 2151 var weight = parseFloat(splitted[5]).toFixed(2); 2152 var subtotal = parseFloat(splitted[7]).toFixed(2); 2153 var discount = parseFloat(splitted[8]).toFixed(2); 2154 var sellprice = parseFloat(splitted[9]).toFixed(2); 2155 var shipping = parseFloat(splitted[10]).toFixed(2); 2156 var tax = parseFloat(splitted[11]).toFixed(2); 2157 var total = parseFloat(splitted[12]).toFixed(2); 2158 2159 nc('#mem-choice-shipmethod').empty().html(splitted[2]); //Shipping Method 2160 nc('#mem-choice-packages').empty().html(splitted[3]); //No. of packages 2161 nc('#mem-choice-service').empty().html(splitted[4]); //Shipping service 2162 nc('#mem-choice-qty').empty().html(splitted[6]); //Quantity Total 2163 nc('#mem-choice-weight').empty().html(weight +'lbs'); //Weight 2164 nc('#mem-choice-subtotal').empty().html('$'+ subtotal); //Retail Price 2165 nc('#mem-choice-discount').empty().html('$'+ discount); //Discount 2166 nc('#mem-choice-sellprice').empty().html('$'+ sellprice); //Your Price 2167 nc('#mem-choice-shipping').empty().html('$'+ shipping); //Shipping 2168 nc('#mem-choice-tax').empty().html('$'+ tax); //Sales Tax 2169 nc('#mem-choice-total').empty().html('$'+ total); //ORDER TOTAL 2170 2171 nc('.member-choice-container .member-choice-lists').empty().html(splitted[0]); 2172 } 2173 }, 2174 error: function(xhr, status, error) { 2175 console.error(xhr.responseText); 2176 // Handle error 2177 } 2178 }); 2179}); 2180 2181//Left Sidebar hide/show Start 2182nc('.tab').click(function() { 2183 // Hide all content divs 2184 nc('.manage-acc-content').hide(); 2185 nc('.tab').removeClass('active'); 2186 2187 nc(this).addClass('active'); 2188 2189 // Show the content div related to the clicked tab 2190 var target = nc(this).data('target'); 2191 nc(target).show().addClass('active'); 2192}); 2193//END 2194 2195//Main menu User icon drop-down on click, activate the tabs Start 2196 // Check the URL for the tab parameter or hash
2197 var urlParams = new URLSearchParams(window.location.search); 2198 var tabParam = urlParams.get('tab'); 2199 var hash = window.location.hash; //not used. 2200 2201 // Hide all content divs 2202 nc('.manage-acc-content').hide(); 2203 nc('.tab').removeClass('active'); 2204 nc('.dropdown-item').removeClass('active'); //dropdown menu remove class active default. 2205 2206 nc('.tab[data-target="#'+tabParam+'"]').addClass('active'); //side-menu add class active. 2207 nc('.dropdown-item[data-tab="'+tabParam+'"]').addClass('active'); //dropdown add class active. 2208 2209 if (tabParam) { 2210 //showTab('#' + tabParam); 2211 nc('#' + tabParam).show().addClass('active'); 2212 } else if (hash) { 2213 //showTab(hash); 2214 nc(hash).show().addClass('active'); 2215 } else { 2216 // Show the first tab by default if no tab parameter or hash is found 2217 nc('.manage-acc-content:first').show().addClass('active'); 2218 nc('.tab:first').addClass('active'); 2219 } 2220//End 2221 2222//My account login page 2223nc('#btncreate_an_account').on('click',function(){ 2224 jQuery("#create_an_account").show(); 2225 jQuery("#member_benefits_hide").hide(); 2226}); 2227//END 2228 2229//Payment billing address Zipcode and City auto fill input fields from API RetrieveCityStateForZipcode. 2230nc('#avs-postalcode').on('blur',function(){ 2231 var avspostalcode = jQuery('#avs-postalcode').val(); 2232 //nc('#avserrorwarn_postal').hide(); 2233 2234 nc.ajax({ 2235 type: "POST", 2236 url:""+nc('#admin_url').val()+"", 2237 data:"action=custom_retrieve_city_state_zipcode&result=zipcode&zipcode="+avspostalcode, 2238 beforeSend: function(){ 2239 jQuery("#avs-city").attr("placeholder", "Loading..."); 2240 jQuery("#avs-state").attr("placeholder", "Loading..."); 2241 }, 2242 success: function(msg){ 2243 2244 if(msg){ 2245 2246 //alert(msg); 2247 //console.log(msg); 2248 2249 var splitted = msg.split('==='); 2250 var splitted_state_available = msg.split('###'); 2251 2252 //if(splitted[2] ){ 2253 nc('#avs-city').empty(); 2254 nc('#avs-city').val(splitted[2]); //city 2255 //} 2256 2257 //if(splitted[3] ){ 2258 nc('#avs-state').empty(); 2259 nc('#avs-state').val(splitted[3]); //state 2260 //} 2261 2262 if(splitted_state_available[1] =='Yes'){ 2263 //Check state available 2264 2265 //jQuery("#avsstate").removeClass("error"); 2266 jQuery('#avserrorwarn_postal').hide(); 2267 2268 }else if(splitted_state_available[1] =='No'){ 2269 //Check state available 2270 2271 //jQuery("#avsstate").addClass("error"); 2272 var state_name_available="" 2273 if(splitted_state_available[2]!="") { 2274 2275 // state_name_available=splitted_state_available[2]; 2276 // jQuery('#avserrorwarn_postal').show(); 2277 // jQuery("#avserrorwarn_postal").html("We currently cannot ship items with alcohol to "+state_name_available+"."); 2278 } 2279 2280 }else{ 2281 //Check state available 2282 nc('#avsstate_available').empty(); 2283 nc('#avsstate_available').val(splitted_state_available[1]); 2284 2285 jQuery("#avs-city").attr("placeholder", "City"); 2286 jQuery("#avs-state").attr("placeholder", "State"); 2287 2288 jQuery('#avserrorwarn_postal').show(); 2289 jQuery("#avserrorwarn_postal").html(msg); 2290 } 2291 } 2292 } 2293 }); 2294}); 2295 2296//Get payment bill cityand state 2297nc('#avs-city,#avs-state').on('blur',function(){ 2298 var shipcity=jQuery('#avs-city').val(); 2299 var shippostalcode = jQuery('#avspostalcode').val(); 2300 nc('#avserrorwarn_postal').hide(); 2301 2302 nc.ajax({ 2303 type: "POST", 2304 url:""+nc('#admin_url').val()+"", 2305 data:"action=custom_retrieve_city_state_zipcode&result=zipcode&zipcode="+shippostalcode+"&city="+shipcity, 2306 beforeSend: function(){ 2307 //jQuery("#avscity").attr("placeholder", "Loading..."); 2308 //jQuery("#avsstate").attr("placeholder", "Loading..."); 2309 }, 2310 success: function(msg){ 2311 2312 if(msg){ 2313 //alert(msg); 2314 2315 //console.log(msg); 2316 var splitted = msg.split('==='); 2317 var splitted_state_available = msg.split('###'); 2318 2319 if(splitted[2] ){ 2320 nc('#avs-city').empty(); 2321 nc('#avs-city').val(splitted[2]); 2322 } 2323 if(splitted[3] ){ 2324 nc('#avs-state').empty(); 2325 nc('#avs-state').val(splitted[3]); 2326 } 2327 2328 if(splitted_state_available[1] =='Yes'){ 2329 2330 //Check state available 2331 nc('#avsstate_available').empty(); 2332 nc('#avsstate_available').val(splitted_state_available[1]); 2333 2334 //jQuery("#shipstate").removeClass("error");
2335 jQuery('#avserrorwarn_postal').hide(); 2336 2337 }else if(splitted_state_available[1] =='No'){ 2338 //Check state available 2339 nc('#avsstate_available').empty(); 2340 nc('#avsstate_available').val(splitted_state_available[1]); 2341 2342 //jQuery("#avsstate").addClass("error"); 2343 var state_name_available="" 2344 if(splitted_state_available[2]!="") { 2345 2346 // state_name_available=splitted_state_available[2]; 2347 // jQuery('#avserrorwarn_postal').show(); 2348 // jQuery("#avserrorwarn_postal").html("We currently cannot ship items with alcohol to "+state_name_available+"."); 2349 } 2350 2351 }else{ 2352 //Check state available 2353 nc('#avsstate_available').empty(); 2354 nc('#avsstate_available').val(''); 2355 2356 //jQuery("#avscity").attr("placeholder", "City"); 2357 //jQuery("#avsstate").attr("placeholder", "State"); 2358 jQuery('#avserrorwarn_postal').show(); 2359 jQuery("#avserrorwarn_postal").html(msg); 2360 } 2361 } 2362 } 2363 }); 2364}); 2365 2366//On blur Shipping Address add/edit ship-postalcode get city and state 2367nc('#ship-postalcode').on('blur',function(){ 2368 var avspostalcode = jQuery('#ship-postalcode').val(); 2369 2370 //State availablity validation 2371 nc('#ship-city, #ship-state').val(''); 2372 nc.ajax({ 2373 type: "POST", 2374 url:""+nc('#admin_url').val()+"", 2375 data:"action=custom_retrieve_city_state_zipcode&result=zipcode&zipcode="+avspostalcode, 2376 beforeSend: function(){ 2377 jQuery("#ship-city").attr("placeholder", "Loading..."); 2378 jQuery("#ship-state").attr("placeholder", "Loading..."); 2379 }, 2380 success: function(msg){ 2381 2382 if(msg){ 2383 2384 //alert(msg); 2385 console.log(msg); 2386 2387 var splitted = msg.split('==='); 2388 var splitted_state_available = msg.split('###'); 2389 2390 //validation 2391 if(splitted[2] === "" || splitted[3] === ""){ 2392 jQuery("#ship-city").attr("placeholder", "City"); 2393 jQuery("#ship-state").attr("placeholder", "State"); 2394 jQuery('#shiperrorwarn_postal').show(); 2395 jQuery("#shiperrorwarn_postal").html("Please enter valid Zip Code / City."); 2396 return false; 2397 }else{ 2398 2399 nc('#ship-city').empty(); 2400 nc('#ship-city').val(splitted[2]); //city 2401 2402 nc('#ship-state').empty(); 2403 nc('#ship-state').val(splitted[3]); //state 2404 2405 if(splitted_state_available[1] == 'Yes'){ 2406 //Check state available 2407 nc('#avsstate_available').empty(); 2408 nc('#avsstate_available').val(splitted_state_available[1]); 2409 2410 //jQuery("#avsstate").removeClass("error"); 2411 jQuery('#shiperrorwarn_postal').hide(); 2412 2413 }else if(splitted_state_available[1] == 'No'){ 2414 //Check state available 2415 nc('#avsstate_available').empty(); 2416 nc('#avsstate_available').val(splitted_state_available[1]); 2417 2418 //jQuery("#avsstate").addClass("error"); 2419 var state_name_available="" 2420 if(splitted_state_available[2] != ""){ 2421 2422 state_name_available=splitted_state_available[2]; 2423 jQuery('#shiperrorwarn_postal').show(); 2424 jQuery("#shiperrorwarn_postal").html("We currently cannot ship items with alcohol to "+state_name_available+"."); 2425 } 2426 2427 }else{ 2428 //Check state available 2429 nc('#avsstate_available').empty(); 2430 nc('#avsstate_available').val(splitted_state_available[1]); 2431 2432 jQuery("#ship-city").attr("placeholder", "City"); 2433 jQuery("#ship-state").attr("placeholder", "State"); 2434 2435 jQuery('#shiperrorwarn_postal').show(); 2436 jQuery("#shiperrorwarn_postal").html(msg); 2437 } 2438 }//Validation end. 2439 } 2440 } 2441 }); 2442}); 2443 2444//Shipping Address Get payment bill cityand state 2445nc('#ship-city,#ship-state').on('blur',function(){ 2446 var shipcity=jQuery('#ship-city').val(); 2447 var shippostalcode = jQuery('#ship-postalcode').val(); 2448 2449 nc.ajax({ 2450 type: "POST", 2451 url:""+nc('#admin_url').val()+"", 2452 data:"action=custom_retrieve_city_state_zipcode&result=zipcode&zipcode="+shippostalcode+"&city="+shipcity, 2453 beforeSend: function(){ 2454 //jQuery("#avscity").attr("placeholder", "Loading..."); 2455 //jQuery("#avsstate").attr("placeholder", "Loading..."); 2456 }, 2457 success: function(msg){ 2458 2459 if(msg){ 2460 //alert(msg); 2461 2462 //console.log(msg); 2463 var splitted = msg.split('==='); 2464 var splitted_state_available = msg.split('###'); 2465 2466 //validation 2467 if(splitted[2] === "" || splitted[3] === ""){ 2468 jQuery('#shiperrorwarn_postal').show(); 2469 jQuery("#shiperrorwarn_postal").html("Please enter valid Zip Code / City."); 2470 return false;
2471 }else{ 2472 2473 //if(splitted[2] ){ 2474 nc('#ship-city').empty(); 2475 nc('#ship-city').val(splitted[2]); 2476 //} 2477 2478 //if(splitted[3] ){ 2479 nc('#ship-state').empty(); 2480 nc('#ship-state').val(splitted[3]); 2481 //} 2482 2483 if(splitted_state_available[1] == 'Yes'){ 2484 2485 //Check state available 2486 nc('#avsstate_available').empty(); 2487 nc('#avsstate_available').val(splitted_state_available[1]); 2488 2489 //jQuery("#shipstate").removeClass("error"); 2490 jQuery('#shiperrorwarn_postal').hide(); 2491 2492 }else if(splitted_state_available[1] =='No'){ 2493 //Check state available 2494 nc('#avsstate_available').empty(); 2495 nc('#avsstate_available').val(splitted_state_available[1]); 2496 2497 //jQuery("#avsstate").addClass("error"); 2498 var state_name_available="" 2499 if(splitted_state_available[2]!="") { 2500 2501 state_name_available=splitted_state_available[2]; 2502 jQuery('#shiperrorwarn_postal').show(); 2503 jQuery("#shiperrorwarn_postal").html("We currently cannot ship items with alcohol to "+state_name_available+"."); 2504 } 2505 2506 }else{ 2507 //Check state available 2508 nc('#avsstate_available').empty(); 2509 nc('#avsstate_available').val(''); 2510 2511 //jQuery("#avscity").attr("placeholder", "City"); 2512 //jQuery("#avsstate").attr("placeholder", "State"); 2513 jQuery('#shiperrorwarn_postal').show(); 2514 jQuery("#shiperrorwarn_postal").html(msg); 2515 } 2516 } 2517 } 2518 } 2519 }); 2520}); 2521 2522//Get cart-create-user-info-form createpassword Encrypt 2523nc('#cart-create-user-info-form #password').on('input',function(){ 2524 var createpassword = nc('#password').val(); 2525 nc.ajax({ 2526 type: "POST", 2527 url:""+nc('#admin_url').val()+"", 2528 data:"action=get_password_encrypt&result=passenc&webpassword="+createpassword, 2529 beforeSend: function(){ 2530 }, 2531 success: function(msg){ 2532 if(msg){ 2533 console.log(msg); 2534 nc('.cart-checkout #encryptcreatepassword').val(msg); 2535 } 2536 } 2537 }); 2538}); 2539 2540/*//Get signinpassword Encrypt 2541nc('#signin-password').on('input change keyup',function(){ 2542 var signinpassword = nc('#signin-password').val(); 2543 // alert(signinpassword); 2544 nc.ajax({ 2545 type: "POST", 2546 url:""+nc('#admin_url').val()+"", 2547 data:"action=get_password_encrypt&result=passenc&webpassword="+signinpassword, 2548 beforeSend: function(){ 2549 }, 2550 success: function(msg){ 2551 if(msg){ 2552 console.log(msg); 2553 // alert(msg); 2554 nc('#encryptsigninpassword').empty(); 2555 nc('#encryptsigninpassword').val(msg); 2556 } 2557 } 2558 }); 2559}); 2560 2561//Get new resetpassword Encrypt 2562nc('#new-reset-password').on('input',function(){ 2563 var resetpassword = nc('#new-reset-password').val(); 2564 // alert(resetpassword); 2565 nc.ajax({ 2566 type: "POST", 2567 url:""+nc('#admin_url').val()+"", 2568 data:"action=get_password_encrypt&result=passenc&webpassword="+resetpassword, 2569 beforeSend: function(){ 2570 }, 2571 success: function(msg){ 2572 if(msg){ 2573 console.log(msg); 2574 // alert(msg); 2575 nc('#encryptresetpassword').val(msg); 2576 } 2577 } 2578 }); 2579});*/ 2580 2581// Apply for input events
2582nc('#password, #signin-password, #new-reset-password').on('input', function() { 2583 var id = nc(this).attr('id'); 2584 var value = nc(this).val(); 2585 2586 // Map input fields to their hidden encrypted counterparts 2587 var mapping = { 2588 'password': '#encryptcreatepassword', 2589 'signin-password': '#encryptsigninpassword', 2590 'new-reset-password': '#encryptresetpassword' 2591 }; 2592 2593 var target = mapping[id]; 2594 2595 if (value === '') { 2596 // Clear encrypted hidden field if password input is empty 2597 nc(target).val('').removeData('source'); 2598 return; 2599 } 2600}); 2601/*ecnrypt password end*/ 2602 2603//Password hide/show 2604nc('#toggle-password').click(function() { 2605 var passwordInput = jQuery('#signin-password'); 2606 var icon = jQuery(this); 2607 2608 // Toggle the password field type 2609 if (passwordInput.attr('type') === 'password') { 2610 passwordInput.attr('type', 'text'); 2611 icon.removeClass('fa-eye').addClass('fa-eye-slash'); 2612 } else { 2613 passwordInput.attr('type', 'password'); 2614 icon.removeClass('fa-eye-slash').addClass('fa-eye'); 2615 } 2616}); 2617 2618nc('#toggle-password-create').click(function() { 2619 var passwordInput = jQuery('#password'); 2620 var icon = jQuery(this); 2621 2622 // Toggle the password field type 2623 if (passwordInput.attr('type') === 'password') { 2624 passwordInput.attr('type', 'text'); 2625 icon.removeClass('fa-eye').addClass('fa-eye-slash'); 2626 } else { 2627 passwordInput.attr('type', 'password'); 2628 icon.removeClass('fa-eye-slash').addClass('fa-eye'); 2629 } 2630}); 2631 2632nc('#toggle-reset-password').click(function() { 2633 var passwordInput = jQuery('#new-reset-password'); 2634 var icon = jQuery(this); 2635 2636 // Toggle the new-reset-password field type 2637 if (passwordInput.attr('type') === 'password') { 2638 passwordInput.attr('type', 'text'); 2639 icon.removeClass('fa-eye').addClass('fa-eye-slash'); 2640 } else { 2641 passwordInput.attr('type', 'password'); 2642 icon.removeClass('fa-eye-slash').addClass('fa-eye'); 2643 } 2644}); 2645 2646//Credit card month/year/cvv validate. Allow only numeric. 2647nc('#expirationmonth, #expirationyear, #creditcardcvv2, #creditcardnum').keypress(function(event){ 2648 if(event.which != 8 && isNaN(String.fromCharCode(event.which))){ 2649 event.preventDefault(); 2650 } 2651}); 2652 2653//Credit Card Number creditcardnum nc("#creditcardnum") 2654nc('#creditcardnum_edit').on('change',function(){ 2655 2656 var creditcardnum=nc('#creditcardnum_edit').val(); 2657 2658 nc.ajax({ 2659 type: "POST", 2660 url:""+nc('#admin_url').val()+"", 2661 data:"action=get_credit_encrypt&result=creditenc&creditcardnum="+creditcardnum, 2662 beforeSend: function(){ 2663 }, 2664 success: function(msg){ 2665 if(msg){ 2666 //alert(msg); 2667 console.log(msg); 2668 nc('#encrypt_creditcardnum').empty(); 2669 nc('#encrypt_creditcardnum').val(msg); 2670 } 2671 } 2672 }); 2673}); 2674 2675//Give Space in Credit card and maximum limit card number. 2676nc('#creditcardnum_edit').on('keyup',function(){ 2677 var creditcardnum=jQuery('#creditcardnum_edit').val(); 2678 var maxCount = jQuery('#creditcardnum_edit').attr('maxlength'); 2679 2680 var numbers = creditcardnum.replace(/\D/g, ''); // Remove non-numeric characters 2681 // Format the number as XXXX-XXXX-XXXX-XXXX 2682 if (numbers.length >= 4) { 2683 numbers = numbers.substring(0, 4) + ' ' + numbers.substring(4); 2684 } 2685 if (numbers.length >= 9) { 2686 numbers = numbers.substring(0, 9) + ' ' + numbers.substring(9); 2687 } 2688 if (numbers.length >= 14) { 2689 numbers = numbers.substring(0, 14) + ' ' + numbers.substring(14); 2690 } 2691 2692 //Maximum limit credit card is 16 digit + 3 space. Total:19 2693 if(numbers.length > maxCount){ 2694 jQuery(this).val(jQuery(this).val().substring(0,maxCount)); 2695 } 2696 2697 //Converted Credit Card display into input field 2698 jQuery('#creditcardnum_edit').val(numbers); 2699}); 2700 2701//Disable browser autocomplete for all age verification date fields 2702nc('input[data-ageverify="yes"]').attr('autocomplete', 'new-birthdate'); 2703 2704//Datepicker function call. 2705function verifyAge(inputSelector, errorSelector) { 2706 let dateText = nc(inputSelector).val().trim(); 2707 if (!dateText) return; // no date entered 2708 2709 let parts = dateText.split('/'); 2710 if (parts.length !== 3) return; // invalid format 2711 2712 let birthDate = new Date(parts[2], parts[1] - 1, parts[0]); // yyyy, mm-1, dd 2713 if (isNaN(birthDate)) return; // invalid date 2714 2715 let today = new Date(); 2716 let age = today.getFullYear() - birthDate.getFullYear(); 2717 let m = today.getMonth() - birthDate.getMonth(); 2718 2719 if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) { 2720 age--; 2721 } 2722 2723 if (age < 21) { 2724 nc(errorSelector).show().text("You must be 21 years old to purchase from this website."); 2725 nc(inputSelector).val(''); // Clear invalid date 2726 } else { 2727 nc(errorSelector).hide().text(''); 2728 } 2729} 2730 2731//Datepicker for delivery and copy to pickup. 2732nc('#birthdate').datepicker({ 2733 changeMonth: true, 2734 changeYear: true, 2735 yearRange: "1950:c", 2736 onSelect: function(dateText) { 2737 nc('#shipbirthdate').val(dateText); 2738 if (nc('#birthdate').data('ageverify') === 'yes') { 2739 verifyAge('#birthdate', '#errorwarn_birthdate', '#shipbirthdate'); 2740 } 2741 } 2742}); 2743 2744// Trigger validation on manual typing (blur or change) 2745nc('#birthdate').on('blur change', function() { 2746 if (nc(this).data('ageverify') === 'yes') { 2747 verifyAge('#birthdate', '#errorwarn_birthdate', '#shipbirthdate'); 2748 } 2749}); 2750 2751//Datepicker for pickup and copy to delivery. 2752nc('#shipbirthdate').datepicker({ 2753 changeMonth: true, 2754 changeYear: true, 2755 yearRange: "1950:c", 2756 onSelect: function(dateText) { 2757 nc('#birthdate').val(dateText); 2758 if (nc('#shipbirthdate').data('ageverify') === 'yes') { 2759 verifyAge('#shipbirthdate', '#errorwarn_shipbirthdate', '#birthdate'); 2760 } 2761 } 2762}); 2763 2764// Trigger validation on manual typing (blur or change) 2765nc('#shipbirthdate').on('blur change', function() { 2766 if (nc(this).data('ageverify') === 'yes') { 2767 verifyAge('#shipbirthdate', '#errorwarn_shipbirthdate', '#birthdate'); 2768 } 2769}); 2770 2771//validate ship phone 2772function validatePhoneNumber(phoneNumber) { 2773 // Define the regular expression for the desired format 2774 var phoneRegex = /^\d{3}-\d{3}-\d{4}$/; 2775 // Test the phone number against the regular expression 2776 return phoneRegex.test(phoneNumber); 2777} 2778 2779//Validate Phone number 2780nc('#phone-number').on('blur',function(){ 2781 var phonenumber = jQuery('#phone-number').val(); 2782 var maxCount = jQuery('#phone-number').attr('maxlength'); 2783 var numbers = ''; 2784 2785 //var isValid = validatePhoneNumber(pickupphone); 2786 var onlynumber = phonenumber.replace(/\D/g, ''); // Remove non-numeric characters 2787 var isValid = onlynumber.length; //validatePhoneNumber(pickupphone); 2788 2789 if (isValid > 12) { 2790 jQuery('#errorwarn_phone_numbe').hide(); 2791 } else { 2792 2793 if( phonenumber.length > 0 ){ 2794 var numbers = phonenumber.replace(/\D/g, ''); // Remove non-numeric characters 2795 // Format the number as XXX-XXX-XXXX 2796 if (numbers.length >= 3) { 2797 numbers = numbers.substring(0, 3) + '-' + numbers.substring(3); 2798 } 2799 if (numbers.length >= 7) { 2800 numbers = numbers.substring(0, 7) + '-' + numbers.substring(7); 2801 } 2802 //Converted phone display into input field 2803 jQuery('#phone-number').val(numbers); 2804 //After change format check validation 2805 var isValid_new = validatePhoneNumber(numbers); 2806 if (isValid_new) { 2807 jQuery('#errorwarn_phone_numbe').hide(); 2808 } else { 2809 jQuery('#errorwarn_phone_numbe').show(); 2810 jQuery("#errorwarn_phone_numbe").html("Invalid phone number. Please use the format XXX-XXX-XXXX."); 2811 } 2812 }else{ 2813 jQuery('#errorwarn_phone_numbe').hide(); 2814 } 2815 2816 //Maximum limit phone is 10 digit. Total:10 2817 if(numbers.length > maxCount){ 2818 jQuery(this).val(jQuery(this).val().substring(0,maxCount)); 2819 } 2820 } 2821}); 2822 2823//Validate Shipping phone number 2824nc('#ship-phone-number').on('blur',function(){ 2825 var phonenumber = jQuery('#ship-phone-number').val(); 2826 var maxCount = jQuery('#ship-phone-number').attr('maxlength'); 2827 var numbers = ''; 2828 2829 // alert(phonenumber) 2830 //var isValid = validatePhoneNumber(pickupphone); 2831 var onlynumber = phonenumber.replace(/\D/g, ''); // Remove non-numeric characters 2832 var isValid = onlynumber.length; //validatePhoneNumber(pickupphone); 2833 2834 if (isValid > 12) { 2835 jQuery('#errorwarn_shipphone').hide(); 2836 2837 } else { 2838 2839 if( phonenumber.length > 0 ){ 2840 var numbers = phonenumber.replace(/\D/g, ''); // Remove non-numeric characters 2841 // Format the number as XXX-XXX-XXXX 2842 if (numbers.length >= 3) { 2843 numbers = numbers.substring(0, 3) + '-' + numbers.substring(3); 2844 } 2845 if (numbers.length >= 7) { 2846 numbers = numbers.substring(0, 7) + '-' + numbers.substring(7); 2847 } 2848 //Converted phone display into input field 2849 jQuery('#ship-phone-number').val(numbers); 2850 //After change format check validation 2851 var isValid_new = validatePhoneNumber(numbers); 2852 if (isValid_new) { 2853 jQuery('#errorwarn_shipphone').hide(); 2854 } else { 2855 jQuery('#errorwarn_shipphone').show(); 2856 jQuery("#errorwarn_shipphone").html("Invalid phone number. Please use the format XXX-XXX-XXXX."); 2857 } 2858 }else{ 2859 jQuery('#errorwarn_shipphone').hide(); 2860 } 2861 2862 //Maximum limit phone is 10 digit. Total:10 2863 if(numbers.length > maxCount){ 2864 jQuery(this).val(jQuery(this).val().substring(0,maxCount)); 2865 } 2866 } 2867}); 2868 2869//validate date field 2870function validateDate(date) { 2871 // Define the regular expression for the desired format 2872 var dateRegex = /^\d{2}\/\d{2}\/\d{4}$/; 2873 // Test the date against the regular expression 2874 return dateRegex.test(date); 2875} 2876 2877//Validate date field to date format (pickup) 2878nc('#shipbirthdate').on('keyup',function(){ 2879 var shipbirthdate = jQuery('#shipbirthdate').val(); 2880 var maxCount = jQuery('#shipbirthdate').attr('maxlength'); 2881 var numbers = ''; 2882 2883 var isValid = validateDate(shipbirthdate); 2884 if (isValid) { 2885 jQuery('#errorwarn_shipbirthdate').hide(); 2886 } else { 2887 2888 if( shipbirthdate.length > 0 ){ 2889 var numbers = shipbirthdate.replace(/\D/g, ''); // Remove non-numeric characters 2890 // Format the number as dd-mm-yyyy 2891 if (numbers.length >= 2) { 2892 numbers = numbers.substring(0, 2) + '/' + numbers.substring(2); 2893 } 2894 if (numbers.length >= 5) { 2895 numbers = numbers.substring(0, 5) + '/' + numbers.substring(5); 2896 } 2897 //Converted phone display into input field 2898 jQuery('#shipbirthdate').val(numbers); 2899 //After change format check validation 2900 var isValid_new = validateDate(numbers); 2901 if (isValid_new) { 2902 jQuery('#errorwarn_shipbirthdate').hide(); 2903 } else { 2904 jQuery('#errorwarn_shipbirthdate').show(); 2905 jQuery("#errorwarn_shipbirthdate").html("Invalid date format. Please use the format dd/mm/yyyy."); 2906 } 2907 }else{ 2908 jQuery('#errorwarn_shipbirthdate').hide(); 2909 } 2910 2911 //Maximum limit birthdate is 8 digit + 2 slash. Total:10 2912 if(numbers.length > maxCount){ 2913 jQuery(this).val(jQuery(this).val().substring(0,maxCount)); 2914 } 2915 } 2916}); 2917 2918//Validate date field to date format (shipping) 2919nc('#birthdate').on('keyup',function(){ 2920 var birthdate = jQuery('#birthdate').val(); 2921 var maxCount = jQuery('#birthdate').attr('maxlength'); 2922 var numbers = ''; 2923 2924 var isValid = validateDate(birthdate); 2925 if (isValid) { 2926 jQuery('#errorwarn_birthdate').hide(); 2927 } else { 2928 2929 if( birthdate.length > 0 ){ 2930 var numbers = birthdate.replace(/\D/g, ''); // Remove non-numeric characters 2931 // Format the number as dd-mm-yyyy 2932 if (numbers.length >= 2) { 2933 numbers = numbers.substring(0, 2) + '/' + numbers.substring(2); 2934 } 2935 if (numbers.length >= 5) { 2936 numbers = numbers.substring(0, 5) + '/' + numbers.substring(5); 2937 } 2938 //Converted phone display into input field 2939 jQuery('#birthdate').val(numbers); 2940 //After change format check validation 2941 var isValid_new = validateDate(numbers); 2942 if (isValid_new) { 2943 jQuery('#errorwarn_birthdate').hide(); 2944 } else { 2945 jQuery('#errorwarn_birthdate').show(); 2946 jQuery("#errorwarn_birthdate").html("Invalid date format. Please use the format dd/mm/yyyy."); 2947 } 2948 }else{ 2949 jQuery('#errorwarn_birthdate').hide(); 2950 } 2951 2952 //Maximum limit birthdate is 8 digit + 2 slash. Total:10 2953 if(numbers.length > maxCount){ 2954 jQuery(this).val(jQuery(this).val().substring(0,maxCount)); 2955 } 2956 } 2957}); 2958 2959//Validate date field to date format (shipping) 2960nc('#shipbirthdate').on('keyup',function(){ 2961 var birthdate = jQuery('#shipbirthdate').val(); 2962 var maxCount = jQuery('#shipbirthdate').attr('maxlength'); 2963 var numbers = ''; 2964 2965 var isValid = validateDate(birthdate); 2966 if (isValid) { 2967 jQuery('#errorwarn_shipbirthdate').hide(); 2968 } else { 2969 2970 if( birthdate.length > 0 ){ 2971 var numbers = birthdate.replace(/\D/g, ''); // Remove non-numeric characters 2972 // Format the number as dd-mm-yyyy 2973 if (numbers.length >= 2) { 2974 numbers = numbers.substring(0, 2) + '/' + numbers.substring(2); 2975 } 2976 if (numbers.length >= 5) { 2977 numbers = numbers.substring(0, 5) + '/' + numbers.substring(5); 2978 } 2979 //Converted phone display into input field 2980 jQuery('#birthdate').val(numbers); 2981 //After change format check validation 2982 var isValid_new = validateDate(numbers); 2983 if (isValid_new) { 2984 jQuery('#errorwarn_shipbirthdate').hide(); 2985 } else { 2986 jQuery('#errorwarn_shipbirthdate').show(); 2987 jQuery("#errorwarn_shipbirthdate").html("Invalid date format. Please use the format dd/mm/yyyy."); 2988 } 2989 }else{ 2990 jQuery('#errorwarn_shipbirthdate').hide(); 2991 } 2992 2993 //Maximum limit birthdate is 8 digit + 2 slash. Total:10 2994 if(numbers.length > maxCount){ 2995 jQuery(this).val(jQuery(this).val().substring(0,maxCount)); 2996 } 2997 } 2998}); 2999 3000//Give Space in Credit card and maximum limit card number. 3001nc('#creditcardnum').on('keyup',function(){ 3002 var creditcardnum=jQuery('#creditcardnum').val(); 3003 var maxCount = jQuery('#creditcardnum').attr('maxlength'); 3004 3005 var numbers = creditcardnum.replace(/\D/g, ''); // Remove non-numeric characters 3006 // Format the number as XXXX-XXXX-XXXX-XXXX 3007 if (numbers.length >= 4) { 3008 numbers = numbers.substring(0, 4) + ' ' + numbers.substring(4); 3009 } 3010 if (numbers.length >= 9) { 3011 numbers = numbers.substring(0, 9) + ' ' + numbers.substring(9); 3012 } 3013 if (numbers.length >= 14) { 3014 numbers = numbers.substring(0, 14) + ' ' + numbers.substring(14); 3015 } 3016 3017 //Maximum limit credit card is 16 digit + 3 space. Total:19 3018 if(numbers.length > maxCount){ 3019 jQuery(this).val(jQuery(this).val().substring(0,maxCount)); 3020 } 3021 3022 //Converted Credit Card display into input field 3023 jQuery('#creditcardnum').val(numbers); 3024}); 3025 3026//Date validate 3027nc('.restart-date, .suspend-date').on('focusout', function() { 3028 var dynamicId = nc(this).attr('id'); 3029 var parts = dynamicId.split
3029('_'); 3030 var afterUnderscore = parts[1]; 3031 var stopDate = nc('#suspend-date_' + afterUnderscore).val(); 3032 var restartDate = nc('#restart-date_' + afterUnderscore).val(); 3033 var validationMessage = ''; 3034 3035 // Regular expression to match the date format YYYY-MM-DD 3036 var dateFormat = /^\d{4}-\d{2}-\d{2}$/; 3037 3038 // Ensure dates are in the format YYYY-MM-DD 3039 if (stopDate.match(dateFormat) && restartDate.match(dateFormat)) { 3040 // Ensure dates are fully entered and valid 3041 if (new Date(restartDate) <= new Date(stopDate)) { 3042 validationMessage = 'Restart date must be a date after the stop date.'; 3043 nc('#restart-date_' + afterUnderscore).val(''); 3044 } 3045 nc('#span_to_restartdate_' + afterUnderscore).text(validationMessage); 3046 } else if (stopDate && !stopDate.match(dateFormat)) { 3047 validationMessage = 'Stop date must be in the format YYYY-MM-DD.'; 3048 nc('#span_to_restartdate_' + afterUnderscore).text(validationMessage); 3049 } else if (restartDate && !restartDate.match(dateFormat)) { 3050 validationMessage = 'Restart date must be in the format YYYY-MM-DD.'; 3051 nc('#span_to_restartdate_' + afterUnderscore).text(validationMessage); 3052 } else { 3053 nc('#span_to_restartdate_' + afterUnderscore).text(''); 3054 } 3055}); 3056 3057//showing notification below "Add to Cart" button on allocations available section. 3058nc(document).on('click', "#club-allocations .allocation-details-container .add-to-cart", function(){ 3059 var stockid = nc(this).data('stockid'); 3060 var all_mqty = nc("#club-allocations .allocation-details-container #inventory-"+stockid).val(); 3061 var abve_allo_mqty = nc("#club-allocations .allocation-details-container #abve-allocation-"+stockid).val(); 3062 3063 if(all_mqty > 0){ 3064 3065 nc('#club-allocations .allocation-details-container .qtymsg-'+stockid).slideDown('slow'); 3066 nc("#club-allocations .allocation-details-container .qtymsg #mqty-"+stockid).html(all_mqty); 3067 setTimeout(function() { 3068 nc('#club-allocations .allocation-details-container .qtymsg-'+stockid).slideUp('slow'); 3069 }, 5000); 3070 3071 }else{ 3072 3073 nc('#club-allocations .allocation-details-container .above-qtymsg-'+stockid).slideDown('slow'); 3074 nc("#club-allocations .allocation-details-container .above-qtymsg #mqty-"+stockid).html(abve_allo_mqty); 3075 setTimeout(function() { 3076 nc('#club-allocations .allocation-details-container .above-qtymsg-'+stockid).slideUp('slow'); 3077 }, 5000); 3078 } 3079}); 3080//end allocation page. 3081 3082//Isgift hide/show on 3083nc('#giftoptin').change(function(){ 3084 if(nc(this).is(':checked')){ 3085 nc('#giftmail, #giftmsg').show(); 3086 nc('#giftoptin').val('Yes'); 3087 } else { 3088 nc('#giftmail, #giftmsg').hide(); 3089 nc('#giftoptin').val('No'); 3090 nc('#giftemailaddress').val(''); 3091 nc('#giftmessage').val(''); 3092 } 3093}); 3094 3095//Favorites section 3096// slick slider 3097var breakpoint = { 3098 // Small screen / phone 3099 sm: 576, // Updated to match typical bootstrap sm breakpoint 3100 // Medium screen / tablet 3101 md: 768, 3102 // Large screen / desktop 3103 lg: 992, 3104 // Extra large screen / wide desktop 3105 xl: 1200 3106}; 3107 3108nc('#slick').slick({ 3109 autoplay: false, 3110 autoplaySpeed: 1500, 3111 pauseOnFocus: true, 3112 draggable: true, 3113 infinite: true, 3114 dots: false, 3115 arrows: false, 3116 speed: 1500, 3117 mobileFirst: true, // This means we start from the smallest breakpoint 3118 slidesToShow: 1, 3119 slidesToScroll: 1, 3120 responsive: [ 3121 { 3122 breakpoint: breakpoint.sm, // Matches 576px and below 3123 settings: { 3124 slidesToShow: 1, 3125 slidesToScroll: 1, 3126 arrows: true 3127 } 3128 }, 3129 { 3130 breakpoint: breakpoint.md, // Matches 768px and below 3131 settings: { 3132 slidesToShow: 2, // Adjust if needed 3133 slidesToScroll: 1, 3134 arrows: true 3135 } 3136 }, 3137 { 3138 breakpoint: breakpoint.lg, // Matches 992px and below 3139 settings: { 3140 slidesToShow: 3, // Adjust to fit this size better 3141 slidesToScroll: 1, 3142 arrows: true 3143 } 3144 }, 3145 { 3146 breakpoint: breakpoint.xl, // Matches 1200px and below 3147 settings: { 3148 slidesToShow: 3, // Adjust to fit this size better 3149 slidesToScroll: 1, 3150 arrows: true 3151 } 3152 } 3153 ] 3154}); 3155 3156//Order history - past orders dropdown lists results. 3157nc('#past_orders').on('change',function(){ 3158 3159 var past_orders=nc(this).val(); 3160 var CustomerId = nc("#hid_resultid").val(); 3161 3162 nc.ajax({ 3163 type: "POST", 3164 url:""+nc('#admin_url').val()+"",
3165 data:"action=get_past_orders_history&result=orders&past_orders="+past_orders+"&CustomerId="+CustomerId, 3166 beforeSend: function(){ 3167 nc('#orders-history').hide(); 3168 nc('.orders-small-loader').show(); 3169 }, 3170 success: function(msg){ 3171 if(msg){ 3172 //alert(msg); 3173 console.log(msg); 3174 nc('.orders-small-loader').hide(); 3175 nc('#orders-history').show(); 3176 nc('#orders-history').empty().html(msg); 3177 } 3178 } 3179 }); 3180}); 3181 3182//My account Dropdown menu toggle 3183nc('.custom-dropdown').on('click', function(e) { 3184 if (window.innerWidth <= 991) { // mobile only 3185 e.preventDefault(); 3186 e.stopPropagation(); 3187 3188 var $menu = nc(this).find('.dropdown-menu'); 3189 3190 // Close all other dropdowns 3191 nc('.dropdown-menu').not($menu).removeClass('show'); 3192 3193 // Toggle current dropdown 3194 $menu.toggleClass('show'); 3195 } 3196}); 3197 3198// Close dropdown if clicking anywhere else 3199nc(document).on('click', function() { 3200 if (window.innerWidth <= 991) { 3201 nc('.dropdown-menu').removeClass('show'); 3202 } 3203}); 3204 3205//manage account Edit/Done notification. 3206// Detect input change 3207nc('#manage_account_editpg form').on('input change', 'input', function() { 3208 nc('#manage_account_savedetail').addClass('nt-sve'); // Add class to Save button 3209 nc('#manage_account_savedetail').data('edited', true); // Store edited state on button 3210}); 3211 3212}); //******End of main document****** 3213 3214//Address drop-down data start 3215//use for select drop down address on change section 3216//Setting event listeners for all dropdown buttons. 3217document.querySelectorAll('.dropdown-btn').forEach(function(button) { 3218 button.addEventListener('click', function() { 3219 // This targets the next sibling of the button which is the dropdown-content 3220 const content = this.nextElementSibling; 3221 content.style.display = content.style.display === 'block' ? 'none' : 'block'; 3222 }); 3223}); 3224 3225function selectOption(value, text) { 3226 const button = document.querySelector('.dropdown-btn'); // This needs to target the correct dropdown 3227 button.textContent = text; // Removes the icon when an option is selected 3228 console.log('Selected value:', value); // Replace with actual form field assignment if needed 3229 // alert(11) 3230 nc("#selected_shipping_address_id").val(value); 3231 nc("#selected_shipping_address_id").focus(); 3232 nc('.dropdown-content').css('display', 'none'); 3233} 3234 3235//Club membership part as cm 3236document.querySelectorAll('.dropdown-btn-cm').forEach(function(button) { 3237 button.addEventListener('click', function() { 3238 // This targets the next sibling of the button which is the dropdown-content 3239 const content = this.nextElementSibling; 3240 content.style.display = content.style.display === 'block' ? 'none' : 'block'; 3241 }); 3242}); 3243 3244//Club Membership select Ship address 3245function selectOption_shippingcm(value, text, nick, company, address2, city, state, postal, phone, email, firstname, lastname, dob) { 3246 const button = document.querySelector('.dropdown-btn-cm'); // This needs to target the correct dropdown 3247 button.textContent = text; // Removes the icon when an option is selected 3248 console.log('Selected value:', value); // Replace with actual form field assignment if needed 3249 //alert(value) 3250 nc("#selected_shipping_address_id-cm").val(value); 3251 nc("#selected_shipping_address_id-cm").focus(); 3252 3253 nc("#selected_shipping_nick").empty().val(nick); 3254 nc("#selected_shipping_company").empty().val(company); 3255 nc("#selected_shipping_address1").empty().val(text); 3256 nc("#selected_shipping_address2").empty().val(address2); 3257 nc("#selected_shipping_city").empty().val(city); 3258 nc("#selected_shipping_state").empty().val(state); 3259 nc("#selected_shipping_postal").empty().val(postal); 3260 nc("#selected_shipping_phone").empty().val(phone); 3261 nc("#selected_shipping_email").empty().val(email); 3262 nc("#selected_shipping_fname").empty().val(firstname); 3263 nc("#selected_shipping_lname").empty().val(lastname); 3264 nc("#selected_shipping_dob").empty().val(dob); 3265 3266 nc('.dropdown-content-cm').css('display', 'none'); 3267} 3268 3269//Club Membership select Pickup address 3270function selectOptionpickupcm(value, text) { 3271 const button = document.querySelector('.dropdown-btn-cm'); // This needs to target the correct dropdown 3272 button.textContent = text;
3272 // Removes the icon when an option is selected 3273 console.log('Selected value:', value); // Replace with actual form field assignment if needed 3274 // alert(value) 3275 nc("#selected_pickup_address_id-cm").val(value); 3276 nc("#selected_pickup_address_id-cm").focus(); 3277 nc('.dropdown-content-cm').css('display', 'none'); 3278} 3279 3280//Add more button click Slide open 3281function openAddmore() { 3282 var nc = jQuery.noConflict(); 3283 nc('.c7-add-more').css('right','0px'); 3284} 3285 3286//close X click. 3287function closeAddmore() { 3288 var nc = jQuery.noConflict(); 3289 nc('.c7-add-more').css('right','-510px'); 3290} 3291 3292//Replace button click slide open. 3293function openReplace() { 3294 var nc = jQuery.noConflict(); 3295 nc('.c7-add-more').css('right','0px'); 3296} 3297 3298//Order History "view details" click slide open. 3299function openOrderHistory(id) { 3300 var nc = jQuery.noConflict(); 3301 nc('.c7-history-'+id).css('right','0px'); 3302} 3303 3304//close order history view details X click. 3305function closeHistory() { 3306 var nc = jQuery.noConflict(); 3307 nc('.c7-cart.order').css('right','-510px'); 3308} 3309 3310/*Add/Remove/Replace Item to member Choice*/ 3311function addRemoveReplaceItemToMemberchoice(id, add_remove_replace){ 3312 3313 //check cookies disabled. 3314 if(checkCookie() != true){ 3315 return; 3316 } 3317 3318 var nc = jQuery.noConflict(); 3319 3320 var customerid = nc("#hid_resultid").val(); 3321 var minqty = nc("#min_qty").val(); 3322 var maxqty = nc("#max_qty").val(); 3323 3324 //query string parameter check. Using in url by users. 3325 var sourcecode = nc("#add-remove-replace-item-"+id).data('sourcecode'); 3326 var replacementInventoryId = nc("#add-remove-replace-item-"+id).data('replacement-inventory-id'); 3327 3328 if(add_remove_replace === 'Add' ){ 3329 var qty = nc(".cart-section.addmore #inventory-"+id).val(); 3330 var operation = 'Add'; 3331 3332 }else if(add_remove_replace === 'Remove'){ 3333 var qty = nc(".active8-accountinfo-container .number #inventory-"+id).val(); 3334 var operation = 'Remove'; 3335 3336 }else if(add_remove_replace === 'Replace'){ 3337 var qty = nc(".cart-section.addmore #inventory-"+id).val(); 3338 var operation = 'Replace'; 3339 var replacementInventoryId = nc(".cart-section.addmore #add-remove-replace-item-"+id).data('replacement-inventory-id'); 3340 } 3341 3342 //Quantity plus/minu 3343 if (add_remove_replace === 'Removeqty'){ 3344 var current_qty = nc(".active8-accountinfo-container .number #inventory-"+id).val(); 3345 if(current_qty > 1){ 3346 var qty = 1; 3347 var operation = 'Remove'; 3348 }else{ 3349 return false; 3350 } 3351 }else if(add_remove_replace === 'Addqty'){ 3352 var qty = 1; 3353 var operation = 'Add'; 3354 } 3355 3356 //Check acs-allocations page is used and add to cart button is clicked, check allocation is removed from slide cart. 3357 var action = "action=customize_add_remove_replace_itemto_memberchoice_info&result=memberchoice&qty="+qty+"&invid="+id+"&operation="+operation+"&sourcecode="+sourcecode+"&customerid="+customerid+"&repinvid="+replacementInventoryId+"&minqty="+minqty+"&maxqty="+maxqty; 3358 3359 nc.ajax({ 3360 type: "POST", 3361 url:""+nc('#admin_url').val()+"", 3362 data: action, 3363 beforeSend: function(){ 3364 nc('.small-loader-'+id).show(); 3365 if (add_remove_replace === 'Remove') { 3366 nc('.mem-remove-loader-'+id).show(); 3367 nc('.remove-btn').addClass('temp-dis'); 3368 } 3369 if (add_remove_replace === 'Removeqty' || add_remove_replace === 'Addqty'){ 3370 nc('.qty-small-loader-'+id).show(); 3371 } 3372 }, 3373 success: function(msg){ 3374 3375 //console.log(msg); 3376 nc('.small-loader-'+id).hide(); 3377 nc('.mem-remove-loader-'+id).hide(); 3378 nc('.qty-small-loader-'+id).hide(); 3379 nc('.remove-btn').removeClass('temp-dis'); 3380 3381 if(msg){ 3382 var splitted = msg.split('==='); 3383 3384 var weight = parseFloat(splitted[5]).toFixed(2); 3385 var subtotal = parseFloat(splitted[7]).toFixed(2); 3386 var discount = parseFloat(splitted[8]).toFixed(2); 3387 var sellprice = parseFloat(splitted[9]).toFixed(2); 3388 var shipping = parseFloat(splitted[10]).toFixed(2); 3389 var tax = parseFloat(splitted[11]).toFixed(2); 3390 var total = parseFloat(splitted[12]).toFixed(2); 3391 3392 nc('#mem-choice-shipmethod').empty().html(splitted[2]); //Shipping Method 3393 nc('#mem-choice-packages').empty().html(splitted[3]); //No. of packages 3394 nc('#mem-choice-service').empty().html(splitted[4]); //Shipping service 3395 //nc('#mem-choice-qty').empty().html(splitted[6]).addClass('red'); //Quantity Total 3396 nc('#mem-choice-weight').empty().html(weight +'lbs'); //Weight 3397 nc('#mem-choice-subtotal').empty().html('$'+ subtotal); //Retail Price 3398 nc('#mem-choice-discount').empty().html('$'+ discount); //Discount 3399 nc('#mem-choice-sellprice').empty().html('$'+ sellprice); //Your Price 3400 nc('#mem-choice-shipping').empty().html('$'+ shipping); //Shipping 3401 nc('#mem-choice-tax').empty().html('$'+ tax); //Sales Tax 3402 nc('#mem-choice-total').empty().html('$'+ total); //ORDER TOTAL 3403 3404 //Add/remove class red for min total quantity 3405 var qtyElem = nc('#mem-choice-qty'); 3406 qtyElem.empty().html(splitted[6]); // Update the content 3407 3408 if (splitted[6] < minqty) { 3409 qtyElem.addClass('red').removeClass('blue'); 3410 } else if (splitted[6] >= maxqty) { 3411 qtyElem.addClass('blue').removeClass('red'); 3412 } else { 3413 qtyElem.removeClass('red blue'); // In between: remove both 3414 } 3415 3416 //Add more btn class 3417 if(splitted[13] == ''){ //splitted[13] disable add more 3418 nc('.addmore-btn').removeClass('disabled-addmore'); //Enable_add_more 3419 nc('.addmore-btn').attr('id', splitted[14]); //enable_add_more 3420 }else{ 3421 nc('.addmore-btn').addClass('disabled-addmore'); //Disable_add_more 3422 nc('.addmore-btn').attr('id', splitted[14]); //disable_add_more 3423 } 3424 3425 3426 //Re-fill current total qty. 3427 nc('#total_qty').val('').val(splitted[6]); //Current total quality. 3428 3429 if(splitted[1] === "Add"){ 3430 3431 nc('.member-choice-container .member-choice-lists').empty().html(splitted[0]); 3432 nc('.succ-msg-'+id).empty().html('Added.').show(); 3433 setTimeout(function() { 3434 nc('.succ-msg-'+id).hide('slow'); 3435 }, 1500); 3436 3437 }else if(splitted[1] === "Replace"){ 3438 3439 nc('.member-choice-container .member-choice-lists').empty().html(splitted[0]); 3440 3441 if(splitted[15] == 1){ //check StatusDescription is not 0. 3442 3443 nc('.succ-msg-'+id).empty().html(splitted[16]).css({ 'color': 'green','font-size': '12px','font-weight': '600'}).show(); //success message show. 3444 setTimeout(function() { 3445 nc('.succ-msg-'+id).hide('slow'); //success message hide. 3446 nc('.c7-add-more').css('right','-510px'); //Close slide. 3447 }, 1500); 3448 3449 }else{ //No stock is available for this product 3450 3451 nc('.succ-msg-' + id).empty().html(splitted[16]).css({ 'color': 'red','font-size': '12px','font-weight': '600'}).show(); //No stock is available for this product message show. 3452 setTimeout(function() { 3453 nc('.succ-msg-'+id).hide('slow'); //message hide. 3454 }, 3500); 3455 } 3456 3457 }else{ 3458 nc('.member-choice-container .member-choice-lists').empty().html(splitted[0]); 3459 } 3460 } 3461 } 3462 }); 3463} 3464 3465//Hide/Show product description on member choice slide opened. 3466function showCartPdtDesc(id){ 3467 var nc = jQuery.noConflict(); 3468 nc('.desc').hide('slow'); 3469 nc('#desc-'+id).toggle('slow'); 3470} 3471 3472//Custom popup for Allocation and Memberchoice. 3473function openModal(id) { 3474 const modal = document.getElementById(id); //dfine modal 3475 modal.style.display = "flex"; 3476 setTimeout(() => modal.classList.add("show"), 10); 3477} 3478 3479/*function closeModal(id) { 3480 const modal = document.getElementById(id); //define modal 3481 modal.classList.remove("show"); 3482 setTimeout(() => modal.style.display = "none", 300); 3483}*/ 3484document.addEventListener("DOMContentLoaded", function() { 3485 window.closeModal = function(id) { 3486 const modal = document.getElementById(id); 3487 modal.classList.remove("show"); 3488 setTimeout(() => modal.style.display = "none", 300); 3489 }; 3490}); 3491 3492// Close when clicking outside 3493document.addEventListener("click", function (event) { 3494 // Ensure target is an element and has classList 3495 if (!event.target || !event.target.classList) return; 3496 3497 if (event.target.classList.contains("acs_modal")) { 3498 closeModal(event.target.id); 3499 } 3500});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.