1'use strict' 2let OPT_BILLING_ADDRESS = 0; 3let cart_l = 0; 4let Cart = (function() { 5 let cookieName; 6 let read_cart = (cart_cookie)?JSON.parse(cart_cookie):{}; 7 let cookie_act = ''; 8 function Cart(cookieName = 'dssf_cart') { 9 this.cookieName = 'dssf_cart'; 10 this.readCookie = function() { 11 return read_cart; 12 //return Cookies.getJSON(cookieName); 13 } 14 } 15 16 function _switchCartButtons(status) { 17 status = Number(status); 18 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 19 var html = "<button class='btn btn-warning btn-buy-cart'><i class='fa fa-fw fa-shopping-cart'></i>"+ GO_TO_CART_TEXT +"</button>"; 20 if (status === 1) { 21 html = "<button class='btn btn-info disabled'><i class='fa fa-fw fa-shopping-cart'></i> "+ ADDING_TO_CART_TEXT +"</button>"; 22 } 23 } else { 24 var html = "<button class='btn btn-warning btn-buy-cart'><i class='fa fa-fw fa-shopping-cart'></i> GO TO CART</button>"; 25 if (status === 1) { 26 html = "<button class='btn btn-info disabled'><i class='fa fa-fw fa-shopping-cart'></i> ADDING TO CART</button>"; 27 } 28 } 29 $(".cart-btn-container").html(html); 30 } 31 32 Cart.prototype.showAlert = function(msg, type) { 33 $(".alert-" + type).html(msg).show(); 34 setTimeout(function() { 35 $(".alert-" + type).hide(); 36 }, 10000); 37 } 38 39 Cart.prototype.addPart = function(part) { 40 let cart = this.readCookie(); 41 let products = {}; 42 if (cart!==null && cart !== '' && typeof cart !== 'undefined') 43 { 44 products = cart; 45 } 46 if (part.gc_unique_id) { 47 products[part.gc_unique_id] = part; 48 } else { 49 products[part.uuid] = part; 50 } 51 this.setCookie(products); 52 _switchCartButtons(3); 53 this.showAlert('Product added To Cart', 'info'); 54 } 55 56 Cart.prototype.removePart = function(uuid) { 57 let cart = this.readCookie(); 58 if (uuid in cart) { 59 for (let key in cart) { 60 if(cart[key].is_addon && cart[key].parent_uuid == uuid) 61 { 62 delete cart[cart[key].uuid]; 63 } 64 } 65 delete cart[uuid]; 66 cookie_act = 'delete'; 67 this.setCookie(cart); 68 this.checkCart(); 69 return true; 70 } 71 return false; 72 } 73 74 Cart.prototype.updatePart = function(part) { 75 let uuid = part.uuid; 76 let cart = this.readCookie(); 77 if (part.part_type == "GiftCertificate") { 78 uuid = part.gc_unique_id; 79 } 80 if (uuid in cart) { 81 cart[uuid] = part; 82 } 83 this.setCookie(cart); 84 } 85 86 Cart.prototype.isUUIDExists = function(uuid) { 87 let cart = this.readCookie(); 88 if (uuid in cart) { 89 return true; 90 } 91 return false; 92 } 93 94 Cart.prototype.checkCart = function() { 95 if (this.cartCount() === 0) { 96 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 97 $(".con-cart").html('<h3 class="text-center text-banner text-muted">'+CART_EMPTY_TEXT+'</h3>'); 98 } else { 99 $(".con-cart").html('<h3 class="text-center text-banner text-muted">Cart is Empty!</h3>'); 100 } 101 } 102 } 103 104 Cart.prototype.cartCount = function() { 105 let cart = this.readCookie(); 106 return cart ? Object.keys(cart).length : 0; 107 } 108 109 Cart.prototype.cartTotal = function() { 110 let cart = this.readCookie(); 111 if (typeof cart !== 'undefined') { 112 let subTotal = 0.0; 113 let ship_cost = 0; 114 for (let key in cart) { 115 let prod = cart[key]; 116 if($("#ssi_course_bundle").length>0 && $("#ssi_course_bundle").val()==1){ //FeatureTag 117 console.log(prod); 118 var prod_count = prod.count; 119 if(prod.ssi_course_bundle_price_exp_qty && prod.ssi_course_bundle_price_exp_qty!=0){ 120 prod_count = Number(prod.count)-Number(prod.ssi_course_bundle_price_exp_qty); 121 } 122 if(prod.part_type=="GiftCertificate"){ 123 subTotal += Number(prod.price) * Number(prod_count); 124 }else{ 125 if(is_tax_inclusive==1){ 126 subTotal += Number(prod.tax_inclusive_price) * Number(prod_count); 127 }else{ 128 subTotal += Number(prod.price) * Number(prod_count); 129 } 130 } 131 132 133 }else{ 134 135 if(prod.part_type=="GiftCertificate"){ 136 subTotal += Number(prod.price) * Number(prod.count); 137 }else{ 138 if(is_tax_inclusive==1){ 139 subTotal += Number(prod.tax_inclusive_price) * Number(prod.count); 140 }else{ 141 subTotal += Number(prod.price) * Number(prod.count); 142 } 143 } 144 145 } 146 } 147 subTotal = subTotal.toFixed(2); 148 subTotal = formatMoney(subTotal); 149 $("#amountPayable").html(subTotal); 150 } else { 151 $("#amountPayable").html($("#currency_symbol").val()+'0.00'); 152 } 153 } 154 155 Cart.prototype.assignTotal = function() { 156 this.cartTotal(); 157 //$("#amountPayable").html(this.cartTotal()); 158 } 159 160 Cart.prototype.assignCount = function() { 161 $(".cart-count").html(this.cartCount()); 162 } 163 164 Cart.prototype.setCookie = function(value) { 165 if($("#enable_maintenance_mode_in_add_to_cart_on_sf").length>0 && $("#enable_maintenance_mode_in_add_to_cart_on_sf").val()==1) //FeatureTag 166 { 167 if(ADD_TO_CART_MAINTENANCE_MODE==1){ 168 169 }else{ 170 var data = JSON.stringify(value); 171 this.clearCookie(); 172 $.ajax({ 173 url: BASE_PATH + '/site/cart_cookie', 174 type: "post", 175 data: { 176 'name': this.cookieName, 177 'arg': data,
178 'cookie_act' : cookie_act 179 }, 180 success: function (data) { 181 if(data==true){ 182 183 cart_l++; 184 } 185 } 186 }); 187 this.assignTotal(); 188 this.assignCount(); 189 } 190 }else{ 191 var data = JSON.stringify(value); 192 this.clearCookie(); 193 // Cookies.set(this.cookieName, data, { 194 // expires: 7 195 // }, { 196 // domain: DOMAIN_NAME 197 // }); 198 // cart_l++; 199 $.ajax({ 200 url: BASE_PATH + '/site/cart_cookie', 201 type: "post", 202 data: { 203 'name': this.cookieName, 204 'arg': data, 205 'cookie_act' : cookie_act 206 }, 207 success: function (data) { 208 if(data==true){ 209 210 cart_l++; 211 } 212 } 213 }); 214 this.assignTotal(); 215 this.assignCount(); 216 } 217 } 218 219 Cart.prototype.clearCookie = function() { 220 Cookies.set(this.cookieName, '', { 221 expires: -1 222 }, { 223 domain: DOMAIN_NAME 224 }); 225 this.assignTotal(); 226 this.assignCount(); 227 } 228 return Cart; 229})(); 230 231let XHR = (function() { 232 let params, type, async, method, baseUrl; 233 234 function XHR(baseUrl) { 235 this.baseUrl = baseUrl; 236 } 237 238 let _toParam = (ary) => { 239 if (!(ary instanceof Array)) { 240 console.warn('Exception: Not an array'); 241 return false; 242 } 243 var str = ''; 244 for (var len = ary.length, i = 0; i < len; i++) { 245 246 str += ary[i].join('='); 247 str += (i === len - 1) ? '' : '&'; 248 } 249 return str; 250 } 251 252 XHR.prototype.call = function(method, params = {}, type = 'GET', async = true) { 253 this.method = method; 254 this.params = Object.keys(params).map((i) => { 255 return [i, params[i]] 256 }); 257 this.type = type; 258 this.async = async; 259 260 return new Promise((resolve, reject) => { 261 let url = this.baseUrl + method; 262 let xhr = new XMLHttpRequest(); 263 264 265 xhr.open(this.type, url, this.async); 266 xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 267 xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); 268 xhr.send(_toParam(this.params)); 269 xhr.onload = () => { 270 if (xhr.status >= 200 && xhr.status < 400) { 271 resolve(JSON.parse(xhr.response)); 272 } else { 273 reject(new Error(`${xhr.status} - Error Fetching Data form Server`)); 274 } 275 }; 276 xhr.onerror = () => { 277 reject(new Error(`${xhr.status} - Error Fetching Data form Server`)); 278 }; 279 }); 280 } 281 282 return XHR; 283})(); 284 285let cart = new Cart(); 286let xhr = new XHR(BASE_PATH + '/api/'); 287 288function init_cart() { 289 cart.assignTotal(); 290 cart.assignCount(); 291} 292window.onload = function() { 293 init_cart(); 294} 295 296$( document ).ready(function() { 297 298 $('.allowdec').keypress(function(event){ 299 if ((event.which != 46 || $(this).val().indexOf('.') != -1)&& (event.which < 48 || event.which > 57)) 300 { 301 if((event.which != 46 || $(this).val().indexOf('.') != -1)) 302 { 303 //alert('Multiple Decimals are not allowed'); 304 } 305 event.preventDefault(); 306 } 307 if(this.value.indexOf(".")>-1 && (this.value.split('.')[1].length > 1)) 308 { 309 //alert('Two numbers only allowed after decimal point'); 310 //event.preventDefault(); 311 } 312 }); 313 $(document).on('click', '.travel_deposit_btn', function(){ 314 var px = 0; 315 $('.paytravelcart').each(function () { 316 if (this.checked) { 317 var travel_cart_id = $(this).attr("data_id"); 318 var tr_obj = "#trip_due_"+travel_cart_id; 319 var trip_due = parseFloat($(tr_obj).val()); 320 if(parseFloat(trip_due) == 0 || $(tr_obj).val()==''){ 321 px++; 322 } 323 } 324 }); 325 if(px==0) 326 { 327 $('.paytravelcart').each(function () { 328 if (this.checked) { 329 var travel_cart_id = $(this).attr("data_id"); 330 // var obj = this; 331 // var travel_cart_id = $(obj).attr("data_travel_cart_id"); 332 trip_balance_add_to_cart(travel_cart_id); 333 } 334 }); 335 }else{ 336 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 337 alert(VALID_TRIP_BALANCE_TEXT); 338 } else { 339 alert("Enter valid Pay Trip Balance."); 340 } 341 return false; 342 } 343 }); 344 $(document).on('click', '.travel_deposit_by_btn', function(){ 345 var obj = this; 346 var travel_cart_id = $(obj).attr("data_travel_cart_id"); 347 var trip_due = parseFloat($("#trip_due_"+travel_cart_id).val()); 348 var trip_due_max = parseFloat($("#trip_due_"+travel_cart_id).attr("data_max")); 349 if(trip_due_max<trip_due){ 350 $("#trip_due_"+travel_cart_id).val(trip_due_max); 351 } 352 trip_balance_add_to_cart(travel_cart_id,obj); 353 354 }); 355 356}); 357 358function trip_balance_add_to_cart(travel_cart_id, obj){ 359 var trip_due = parseFloat($("#trip_due_"+travel_cart_id).val()); 360 var trip_due_max = parseFloat($("#trip_due_"+travel_cart_id).attr("data_max")); 361 // var trip_due_min = 1; //parseFloat($("#trip_due_"+travel_cart_id).attr("data_min")); 362 // if(trip_due_min>0 && trip_due_min>trip_due) 363 // { 364 // var min_pay = $("#trip_due_"+travel_cart_id).attr("data_min_pay"); 365 // alert("The minimum payment should be "+min_pay); 366 // return false;
367 // } 368 if(trip_due>0){ 369 if(obj!=''){ 370 var contact_uuid = $(obj).attr("data_contact_uuid"); 371 var data_travel_cart_store_url = $(obj).attr("data_travel_cart_store_url"); 372 var travel_cart_id = $(obj).attr("data_travel_cart_id"); 373 var trip_due = parseFloat($("#trip_due_"+travel_cart_id).val()); 374 var str_url = data_travel_cart_store_url+"/auto_login/"+contact_uuid+"/"+travel_cart_id+"/"+trip_due; 375 if($(".page-numbers .current").length>0){ 376 str_url += "?page="+$(".page-numbers .current").html(); 377 } 378 } 379 if(data_travel_cart_store_url){ 380 var sub_store_name = $(obj).attr("data_sub_store"); 381 var r = confirm("You are being redirected to "+sub_store_name+" to complete your payment"); 382 if(r){ 383 window.open(str_url, '_blank'); 384 }else{ 385 $("#trip_due_"+travel_cart_id).val(''); 386 } 387 388 return false; 389 }else{ 390 var trip_deposit = JSON.parse($("#trip_deposit_"+travel_cart_id).val()); 391 trip_deposit[travel_cart_id].price = trip_due; 392 if($("#tax_inclusive_traveldeposit_variance_issue").length>0 && $("#tax_inclusive_traveldeposit_variance_issue").val()==1) //FeatureTag 393 { 394 if (typeof is_tax_inclusive !== "undefined" && is_tax_inclusive == 1) { 395 trip_deposit[travel_cart_id].tax_inclusive_price = trip_due; 396 } 397 } 398 cart.addPart(trip_deposit[travel_cart_id]); 399 var trip_deposit_cart_interval = setInterval(function () { 400 if(cart_l>0) 401 { 402 clearInterval(trip_deposit_cart_interval); 403 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 404 $.notify({ 405 from: "bottom", 406 title: "<strong></strong> ", 407 icon: 'glyphicon glyphicon-shopping-cart', 408 message: CART_ADDED_SUCCESS_TEXT 409 },{timer: 1000,type: 'success',animate: {enter: 'animated lightSpeedIn',exit: 'animated lightSpeedOut'}}); 410 } else { 411 $.notify({ 412 from: "bottom", 413 title: "<strong></strong> ", 414 icon: 'glyphicon glyphicon-shopping-cart', 415 message: "Added to your cart successfully...!" 416 },{timer: 1000,type: 'success',animate: {enter: 'animated lightSpeedIn',exit: 'animated lightSpeedOut'}}); 417 } 418 419 //window.location.reload(); 420 window.location = BASE_PATH+"/checkout"; 421 } 422 },1000); 423 } 424 425 }else{ 426 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 427 alert(VALID_TRIP_BALANCE_TEXT); 428 } else { 429 alert("Enter valid Pay Trip Balance"); 430 } 431 $("#trip_due_"+travel_cart_id).focus(); 432 return false; 433 } 434} 435 436function addToCart(handle, count, cInv,part_type='') { 437 if($("#enable_maintenance_mode_in_add_to_cart_on_sf").length>0 && $("#enable_maintenance_mode_in_add_to_cart_on_sf").val()==1) //FeatureTag 438 { 439 if(ADD_TO_CART_MAINTENANCE_MODE==1){ 440 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 441 $.notify({ 442 title: "<strong class='insufficient-quantity-cart'>"+SYSTEM_MAINTENANCE_TEXT+"</strong> ", 443 icon: 'glyphicon glyphicon-info-sign', 444 message: ADD_TO_CART_MAINTENANCE_MODE_MSG 445 }, { 446 timer: 2000, 447 type: 'danger', 448 animate: { 449 enter: 'animated lightSpeedIn', 450 exit: 'animated lightSpeedOut' 451 } 452 }); 453 } else { 454 $.notify({ 455 title: "<strong class='insufficient-quantity-cart'>Alert: System Maintenance</strong> ", 456 icon: 'glyphicon glyphicon-info-sign', 457 message: ADD_TO_CART_MAINTENANCE_MODE_MSG 458 }, { 459 timer: 2000, 460 type: 'danger', 461 animate: { 462 enter: 'animated lightSpeedIn', 463 exit: 'animated lightSpeedOut' 464 } 465 }); 466 } 467 setTimeout(function () { 468 window.location.reload(); 469 },1000); 470 return false; 471 } 472 } 473 474 var e = document.getElementById("numProductQty"); 475 var isValid = (!cInv) ? true : e.validity.valid; 476 477 if (handle && isValid) { 478 let params = {handle: handle,part_type:( (part_type=="")?'product':part_type )}; 479 xhr.call('getPartDetails', params, 'POST') 480 .then(function(data) { 481 if (data.status) { 482 483 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 484 $.notify({ 485 from: "bottom", 486 title: "<strong></strong> ", 487 icon: 'glyphicon glyphicon-shopping-cart', 488 message: CART_ADDED_SUCCESS_TEXT 489 }, { 490 timer: 1000, 491 type: 'success', 492 animate: { 493 enter: 'animated lightSpeedIn', 494 exit: 'animated lightSpeedOut' 495 } 496 }); 497 } else { 498 $.notify({ 499 from: "bottom", 500 title: "<strong></strong> ", 501 icon: 'glyphicon glyphicon-shopping-cart', 502 message: "Added to your cart successfully...!" 503 }, { 504 timer: 1000, 505 type: 'success', 506 animate: { 507 enter: 'animated lightSpeedIn', 508 exit: 'animated lightSpeedOut' 509 } 510 }); 511 } 512 513 data.data.count = count; 514 cart.addPart(data.data); 515 var part_cart_interval = setInterval(function () { 516 if(cart_l>0) 517 { 518 clearInterval(part_cart_interval); 519 window.location.reload(); 520 } 521 },1000); 522 523 } 524 }); 525 526 } else if (!e.validity.valid) { 527 528 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 529 $.notify({ 530 title: "<strong class='insufficient-quantity-cart'></strong> ", 531 icon: 'glyphicon glyphicon-shopping-cart', 532 message: INSUFFICIENT_QUANTITY_TEXT 533 }, { 534 timer: 2000, 535 type: 'dangert', 536 animate: { 537 enter: 'animated lightSpeedIn', 538 exit: 'animated lightSpeedOut' 539 } 540 }); 541 542 cart.showAlert(INSUFFICIENT_QUANTITY_TEXT, 'danger'); 543 } else { 544 $.notify({ 545 title: "<strong class='insufficient-quantity-cart'></strong> ", 546 icon: 'glyphicon glyphicon-shopping-cart', 547 message: "Insufficient Quantity!" 548 }, { 549 timer: 2000, 550 type: 'dangert', 551 animate: { 552 enter: 'animated lightSpeedIn', 553 exit: 'animated lightSpeedOut' 554 } 555 }); 556 557 cart.showAlert('Insufficient Quantity!', 'danger'); 558 } 559 560 //setTimeout(window.location.href = BASE_PATH+"/products/"+handle , 6000); 561 setTimeout( 562 function() { 563 window.location.reload('BASE_PATH+"/products/"+handle'); 564 }, 3000); 565 } else { 566 567 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 568 $.notify({ 569 title: "<strong></strong> ", 570 icon: 'glyphicon glyphicon-shopping-cart', 571 message: UNABLE_TO_ADD_PRODUCT_CART_TEXT 572 }, { 573 timer: 1000, 574 type: 'dangert', 575 animate: { 576 enter: 'animated lightSpeedIn', 577 exit: 'animated lightSpeedOut' 578 } 579 }); 580 581 cart.showAlert(UNABLE_TO_ADD_PRODUCT_CART_TEXT, 'danger'); 582 } else { 583 $.notify({ 584 title: "<strong></strong> ", 585 icon: 'glyphicon glyphicon-shopping-cart', 586 message: "Unable to add product to cart!" 587 }, { 588 timer: 1000, 589 type: 'dangert', 590 animate: { 591 enter: 'animated lightSpeedIn', 592 exit: 'animated lightSpeedOut' 593 } 594 }); 595 596 cart.showAlert('Unable to add product to cart!', 'danger'); 597 } 598 } 599} 600 601 602if (CONTROLL == "calendar") { 603 Array.prototype.contains = function(v) { 604 for (var i = 0; i < this.length; i++) { 605 if (this[i] === v) return true; 606 } 607 return false;
608 }; 609 610 Array.prototype.unique = function() { 611 var arr = []; 612 for (var i = 0; i < this.length; i++) { 613 if (!arr.contains(this[i])) { 614 arr.push(this[i]); 615 } 616 } 617 return arr; 618 } 619} 620 621function addToCalCart(handle, count, type, travel_total, from_cart) { 622 if ($("#allow_products_as_course_to_ssi").length > 0 && $("#allow_products_as_course_to_ssi").val() == 1) //FeatureTag 623 { 624 if ($("#padi_club_product").length > 0 && $("#padi_club_product").val() == 1) { 625 if ((type == 'Course' || type == 'Product') && checkAddStudentForm()) { 626 getCourseRegisteredUsers(); 627 if($("#add_guardian_email_addressfor_students").length>0 && $("#add_guardian_email_addressfor_students").val()==1){ 628 checkAgefact(); 629 } 630 preserveContact(handle, function (success) { 631 if (!success) { 632 return false; 633 } 634 if (REG_USERS.length > 0) { 635 var reg_name = []; 636 var reg_email = []; 637 $.each(REG_USERS, function (i, item) { 638 reg_name.push(item.name.toLowerCase()); 639 reg_email.push(item.email.toLowerCase()); 640 }); 641 } 642 console.log("reg_name", typeof reg_name); 643 // Use a Set to filter out duplicate names 644 if (new Set(reg_name).size !== REG_USERS.length) { 645 if ($("#multi_language_support").length > 0 && $("#multi_language_support").val() == 1) { 646 alert(DUPLICATE_STUDENT_NAME_TEXT); 647 } else { 648 alert("You have entered the same student name more than once. Please remove to proceed."); 649 } 650 return false; 651 } 652 if ((ssi_id !== '' || tdisdi_id !== '' || padi_id !== '') && new Set(reg_email).size !== REG_USERS.length) { 653 if ($("#multi_language_support").length > 0 && $("#multi_language_support").val() == 1) { 654 alert(UNIQUE_STUDENT_EMAIL_TEXT); 655 } else { 656 alert("Students' emails should be unique"); 657 } 658 return false; 659 } 660 if ($("#padi_club_product").length > 0 && $("#padi_club_product").val() == 1) { //FeatureTag 661 if (selectedAddonValues.length > 0) { 662 travel_total = $("#crsOverallTotal").text().replace(/[^0-9.-]+/g, ""); 663 } 664 } 665 if ($("#ssi_course_bundle").length > 0 && $("#ssi_course_bundle").val() == 1) { //FeatureTag 666 //SSI Bundle Cchanges starts 667 setTimeout(function () { 668 getCourseCost(count); 669 setTimeout(function () { 670 proceedAddToCalCart(handle, count, type, travel_total, from_cart); 671 }, 1500); 672 }, 1500); 673 //SSI Bundle Cchanges ends 674 } else { 675 proceedAddToCalCart(handle, count, type, travel_total, from_cart); 676 } 677 }); 678 } 679 } else { 680 if ((type == 'Course' || type == 'Product') && checkAddStudentForm()) { 681 getCourseRegisteredUsers(); 682 if($("#add_guardian_email_addressfor_students").length>0 && $("#add_guardian_email_addressfor_students").val()==1){ 683 checkAgefact(); 684 } 685 preserveContact(handle); 686 if (REG_USERS.length > 0) { 687 var reg_name = []; 688 var reg_email = []; 689 $.each(REG_USERS, function (i, item) { 690 reg_name.push(item.name.toLowerCase()); 691 reg_email.push(item.email.toLowerCase()); 692 }); 693 } 694 console.log("reg_name", typeof reg_name); 695 // Use a Set to filter out duplicate names 696 if (new Set(reg_name).size !== REG_USERS.length) { 697 if ($("#multi_language_support").length > 0 && $("#multi_language_support").val() == 1) { 698 alert(DUPLICATE_STUDENT_NAME_TEXT); 699 } else { 700 alert("You have entered the same student name more than once. Please remove to proceed."); 701 } 702 return false;
703 } 704 if ((ssi_id !== '' || tdisdi_id !== '' || padi_id !== '') && new Set(reg_email).size !== REG_USERS.length) { 705 if ($("#multi_language_support").length > 0 && $("#multi_language_support").val() == 1) { 706 alert(UNIQUE_STUDENT_EMAIL_TEXT); 707 } else { 708 alert("Students' emails should be unique"); 709 } 710 return false; 711 } 712 if ($("#padi_club_product").length > 0 && $("#padi_club_product").val() == 1) { //FeatureTag 713 if (selectedAddonValues.length > 0) { 714 travel_total = $("#crsOverallTotal").text().replace(/[^0-9.-]+/g, ""); 715 } 716 } 717 if ($("#ssi_course_bundle").length > 0 && $("#ssi_course_bundle").val() == 1) { //FeatureTag 718 //SSI Bundle Cchanges starts 719 setTimeout(function () { 720 getCourseCost(count); 721 setTimeout(function () { 722 proceedAddToCalCart(handle, count, type, travel_total, from_cart); 723 }, 1500); 724 }, 1500); 725 //SSI Bundle Cchanges ends 726 } else { 727 proceedAddToCalCart(handle, count, type, travel_total, from_cart); 728 } 729 730 } 731 } 732 733 } else { 734 if (type == 'course' && checkAddStudentForm()) { 735 getCourseRegisteredUsers(); 736 if($("#add_guardian_email_addressfor_students").length>0 && $("#add_guardian_email_addressfor_students").val()==1){ 737 checkAgefact(); 738 } 739 preserveContact(handle); 740 if (REG_USERS.length > 0) { 741 var reg_name = []; 742 var reg_email = []; 743 $.each(REG_USERS, function (i, item) { 744 reg_name.push(item.name.toLowerCase()); 745 reg_email.push(item.email.toLowerCase()); 746 }); 747 } 748 if (reg_name.unique().length != REG_USERS.length) { 749 if ($("#multi_language_support").length > 0 && $("#multi_language_support").val() == 1) { 750 alert(DUPLICATE_STUDENT_NAME_TEXT); 751 } else { 752 alert("You have entered the same student name more than once. Please remove to proceed."); 753 } 754 return false; 755 } 756 757 if ((ssi_id != '' || tdisdi_id != '' || padi_id != '') && reg_email.unique().length != REG_USERS.length) { 758 if ($("#multi_language_support").length > 0 && $("#multi_language_support").val() == 1) { 759 alert(UNIQUE_STUDENT_EMAIL_TEXT); 760 } else { 761 alert("Students email should be unique") 762 } 763 return false; 764 } 765 766 proceedAddToCalCart(handle, count, type, travel_total, from_cart); 767 } 768 } 769 if ((type == 'travel' || type == 'charter') && checkAddOptionForm()) { 770 getTravelRegisteredUsers(); 771 getTravelAddonOptions(); 772 preserveContact(handle); 773 if (REG_USERS.length > 0) { 774 var reg_name = []; 775 var reg_email = []; 776 $.each(REG_USERS, function (i, item) { 777 reg_name.push(item.name.toLowerCase() + "_" + item.option_id); 778 reg_email.push(item.email.toLowerCase()); 779 }); 780 } 781 if (reg_name.unique().length != REG_USERS.length) { 782 if ($("#multi_language_support").length > 0 && $("#multi_language_support").val() == 1) { 783 alert(DUPLICATE_TRAVELER_NAME_TEXT); 784 } else { 785 alert("You have entered the same traveler name more than once. Please remove to proceed."); 786 } 787 return false; 788 } 789 if (reg_email.unique().length != REG_USERS.length) { 790 //alert("You have entered more than one repeated traveller email, Please check and confirm?") 791 //return false;
792 } 793 proceedAddToCalCart(handle, count, type, travel_total, from_cart); 794 } 795} 796var cal_checkout_btn = false; 797var cart_msg = ''; 798var xck_out = 0; 799 800 801 var is_deposit = false; 802 803 804function proceedAddToCalCart(handle, count, type, travel_total, from_cart) { 805 if (handle) { 806 let params = { 807 handle: handle, 808 part_type: type, 809 travel_total: travel_total, 810 count:count 811 }; 812 xhr.call('getPartDetails', params, 'POST') 813 .then(function(data) { 814 if (data.status) { 815 816 $.notify({ 817 title: "<strong></strong> ", 818 icon: 'glyphicon glyphicon-shopping-cart', 819 message: cart_msg //"Added to your cart successfully...!" 820 }, { 821 timer: 1000, 822 type: 'success', 823 animate: { 824 enter: 'animated lightSpeedIn', 825 exit: 'animated lightSpeedOut' 826 } 827 }); 828 if (type == 'travel' || type == 'charter') { 829 data.data.count = 1; 830 } else { 831 data.data.count = count; 832 } 833 data.data.original_count = count; 834 var addon_cnt = 0; 835 // if(data.data.addons) 836 // { 837 // $.each(data.data.addons, function(key, item) { 838 // cart.addPart(item); 839 // addon_cnt++; 840 // }); 841 // } 842 843 data.data.is_deposit = is_deposit; 844 845 846 cart.addPart(data.data); 847 cart.assignCount(); 848 addon_cnt++; 849 var course_addon_interval = setInterval(function () { 850 851 console.log(cart_l+"----"+addon_cnt+"-------"+from_cart+"-----"+cal_checkout_btn) 852 853 if(cart_l==addon_cnt) 854 { 855 clearInterval(course_addon_interval); 856 if(cal_checkout_btn==true){ 857 cal_checkout_btn = false; 858 xck_out++; 859 if($("#contact_user_id").length>0 && $("#contact_user_id").val()!='' && $("#contact_user_id").val()!=undefined){ 860 setTimeout(function(){ window.location.href = BASE_PATH+"/checkout"; },700) ; 861 }else{ 862 $("#signin_signup").show(); 863 show_signin_form(); 864 } 865 866 }else{ 867 if(from_cart == 'yes'){ 868 window.location.href = BASE_PATH+"/cart"; 869 }else{ 870 window.location.reload(); 871 } 872 } 873 } 874 },1200); 875 if(cal_checkout_btn==true) 876 { 877 if($("#contact_user_id").length>0 && $("#contact_user_id").val()!='' && $("#contact_user_id").val()!=undefined){ 878 setTimeout(function(){ window.location.href = BASE_PATH+"/checkout"; },700) 879 }else{ 880 $("#signin_signup").show(); 881 show_signin_form(); 882 } 883 } 884 console.log(cal_checkout_btn+"==========xck_out===="+xck_out); 885 886 } 887 }); 888 hideMainDialog(); 889 } 890} 891 892function deleteFromCart(uuid, el, unique_id) { 893 if (unique_id != '') { 894 895 if(unique_id!=$(el).attr("del-part")){ 896 var cart_res = cart.removePart($(el).attr("del-part")); 897 }else{ 898 var cart_res = cart.removePart(unique_id); 899 } 900 901 } else { 902 var cart_res = cart.removePart(uuid); 903 } 904 if (cart_res) { 905 $(el).closest("tr").remove(); 906 907 $("li." + uuid).remove(); 908 909 var amount = ($("#amountPayable").length != 0) ? $("#amountPayable").html() : '$ 0.00'; 910 911 var tot_item = parseInt($(".tot_items").attr("data-tot")) - 1; 912 $(".tot_items").attr("data-tot", tot_item); 913 $(".amountPayable").html(amount); 914 var tot_item = parseInt($(".tot_items").attr("data-tot")); 915 $(".tot_items").attr("data-tot", tot_item); 916 $(".tot_items").html(tot_item + " item(s) - " + amount); 917 918 if($(".item_not_available").length==0) 919 { 920 if (CONTROLL == "products" && ACTION == "cart" ) 921 { 922 if($(".btn_place_order").length>0) 923 {
924 $(".btn_place_order").attr("disabled",false); 925 } 926 else if($("#place_order").length>0) 927 { 928 $("#place_order").attr("disabled",false); 929 } 930 } 931 } 932 933 934 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 935 $.notify({ 936 title: "<strong></strong> ", 937 icon: 'glyphicon glyphicon-shopping-cart', 938 message: DELETED_FROM_CART_TEXT 939 }, { 940 timer: 1000, 941 type: 'success', 942 animate: { 943 enter: 'animated lightSpeedIn', 944 exit: 'animated lightSpeedOut' 945 } 946 }); 947 } else { 948 $.notify({ 949 title: "<strong></strong> ", 950 icon: 'glyphicon glyphicon-shopping-cart', 951 message: "Deleted from your cart successfully...!" 952 }, { 953 timer: 1000, 954 type: 'success', 955 animate: { 956 enter: 'animated lightSpeedIn', 957 exit: 'animated lightSpeedOut' 958 } 959 }); 960 } 961 962 963 } 964 965} 966function deleteFromCartTop(uuid, el, unique_id) { 967 if (confirm(ARE_YOU_SURE_YOU_WANT_TO_REMOVE_THIS_ITEM_FROM_YOUR_CART_TEXT+'?')) { 968 if (unique_id != '') { 969 970 if(unique_id!=$(el).attr("del-part")){ 971 var cart_res = cart.removePart($(el).attr("del-part")); 972 }else{ 973 var cart_res = cart.removePart(unique_id); 974 } 975 976 } else { 977 var cart_res = cart.removePart(uuid); 978 } 979 if (cart_res) { 980 $(el).parent().parent().remove(); 981 $.ajax({ 982 url: BASE_PATH + "/ajax/remove_shipping", 983 success: function(result) {} 984 }); 985 986 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 987 $.notify({ 988 title: "<strong></strong> ", 989 icon: 'glyphicon glyphicon-shopping-cart', 990 message: DELETED_FROM_CART_TEXT 991 }, { 992 timer: 1000, 993 type: 'success', 994 animate: { 995 enter: 'animated lightSpeedIn', 996 exit: 'animated lightSpeedOut' 997 } 998 }); 999 } else { 1000 $.notify({ 1001 title: "<strong></strong> ", 1002 icon: 'glyphicon glyphicon-shopping-cart', 1003 message: "Deleted from your cart successfully...!" 1004 }, { 1005 timer: 1000, 1006 type: 'success', 1007 animate: { 1008 enter: 'animated lightSpeedIn', 1009 exit: 'animated lightSpeedOut' 1010 } 1011 }); 1012 } 1013 var rm_part_cart_interval = setInterval(function () { 1014 if(cart_l>0) 1015 { 1016 clearInterval(rm_part_cart_interval); 1017 window.location.reload(); 1018 } 1019 },1000); 1020 //setTimeout(location.reload(), 1000); 1021 } 1022 } 1023 return false; 1024} 1025if($("#addon_qty_can_not_be_edited").length>0 && $("#addon_qty_can_not_be_edited").val()==1) //FeatureTag 1026{ 1027 var focusin=0; 1028 var timeoutId; 1029 $(document).on('focus', '.cart_qty ', function(e){ 1030 //console.log("focusin===",focusin); 1031 if(focusin==0){ 1032 1033 }else{ 1034 $("#place_order").parent().fadeOut(); 1035 } 1036 }); 1037 $(document).on('keydown', '.cart_qty', function(e) { 1038 focusin++; 1039 if (focusin == 1) { // Focus is incremented before this check, so it's 1 when first focused 1040 $("#place_order").parent().fadeOut(); 1041 } 1042 var obj = $(this); 1043 // Clear the previous timeout if the user is still typing 1044 clearTimeout(timeoutId); 1045 // Set a new timeout to trigger the change event after 2 seconds 1046 timeoutId = setTimeout(function() { 1047 //console.log("Trigger==="); 1048 obj.trigger("change"); 1049 focusin = 0; // Reset focusin counter after triggering change 1050 }, 500); 1051 //console.log("focusin2===", focusin); 1052 }); 1053 $(document).on('keyup', '.cart_qty ', function(e){ 1054 //console.log("focusin1===",focusin); 1055 if ($(this).val() === "") { 1056 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 1057 alert(FIELD_CANNOT_EMPTY_TEXT); 1058 } else { 1059 alert("The field cannot be left empty."); 1060 } 1061 //console.log("Trigger 1==="); 1062 $(this).val(1).trigger("change"); 1063 }else{ 1064 var input = $(this).val(); 1065 var min = parseInt($(this).attr('min')); 1066 if (input < min) { 1067 $(this).val(min); 1068 //console.log("Trigger 2==="); 1069 $(this).trigger("change"); 1070 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 1071 alert(MIN_QTY_TEXT+ " " + min); 1072 } else { 1073 alert("Please enter a qty should be greater then or equal to "+ min); 1074 } 1075 } 1076 } 1077 if(focusin==0){ 1078 1079 }else{ 1080 focusin = 0; 1081 $("#place_order").parent().fadeOut(); 1082 } 1083 }); 1084} 1085function changeUnitCount(handle, uuid, e, product_type, original_count) { 1086 1087 if($("#addon_qty_can_not_be_edited").length>0 && $("#addon_qty_can_not_be_edited").val()==1) //FeatureTag 1088 { 1089 if(e.value > 0){ 1090 $("#place_order").parent().fadeOut(); 1091 // $(e).attr("readonly", true); 1092 $(e).parent().find(".loader_cart_pos").removeClass("hide"); 1093 } 1094 if(parseInt($(e).attr("data-addon"))==1 && parseInt($(e).attr("min"))>0 ){ 1095 if(parseInt($(e).attr("min"))>parseInt(e.value)){ 1096 var alrmsg = 'This product is should be place qty with: '+$(e).attr("min"); 1097 cart.showAlert(alrmsg, 'danger'); 1098 // $(e).val($(e).attr("min")); 1099 // $(e).attr("readonly", false); 1100 $("#place_order").parent().fadeIn(); 1101 $(e).parent().find(".loader_cart_pos").addClass("hide"); 1102 return false;
1103 } 1104 } 1105 } 1106 1107 if (cart.isUUIDExists(uuid) && e.value > 0) { 1108 let params; 1109 if($("#addon_qty_can_not_be_edited").length>0 && $("#addon_qty_can_not_be_edited").val()==1) //FeatureTag 1110 { 1111 if(parseInt($(e).attr("data-addon"))==1){ 1112 params = { 1113 parent_id : $(e).attr("data-parent_id"), 1114 addon: true, 1115 uuid : uuid, 1116 handle: handle, 1117 count: $(e).val(), 1118 product_type: product_type.toLowerCase() 1119 }; 1120 }else{ 1121 params = { 1122 uuid : uuid, 1123 handle: handle, 1124 count: $(e).val(), 1125 product_type: product_type.toLowerCase() 1126 }; 1127 } 1128 }else{ 1129 params = { 1130 handle: handle, 1131 count: $(e).val(), 1132 product_type: product_type.toLowerCase() 1133 }; 1134 } 1135 if (product_type == "GiftCertificate") { 1136 params.gc_key = $(e).attr('data-key'); 1137 } 1138 xhr.call('checkStock', params, 'POST') 1139 .then(function(data) { 1140 if (data.status) { 1141 if($("#PSO_"+data.data.part['uuid']).length>0) 1142 { 1143 if(data.data.PSO_msg) 1144 { 1145 $("#PSO_"+data.data.part['uuid']).html(data.data.PSO_msg); 1146 }else{ 1147 $("#PSO_"+data.data.part['uuid']).html(''); 1148 } 1149 } 1150 return data.data; 1151 } 1152 }) 1153 .then(function(data) { 1154 if (!data.available) { 1155 if(data.nla==true) 1156 { 1157 var alrmsg = 'This product is no longer available. Maximum order quantity available: '+data.stock; 1158 } 1159 else{ 1160 var alrmsg = 'We are Sorry! We are able to accomodate only '+ data.processed +' quantity of <strong>'+ data.title +'</strong> for each customer'; 1161 } 1162 cart.showAlert(alrmsg, 'danger'); 1163 } 1164 $(e).val(data.processed); 1165 if (product_type == "Travel" || product_type == "Charter" || product_type == "Course") { 1166 } else { 1167 $(e).closest("tr").find(".sub-total").html(data.subTotal); 1168 } 1169 return data; 1170 }) 1171 .then(function(data) { 1172 if (product_type == "Travel" || product_type == "Charter") { 1173 if (data.available) 1174 gotoCalenderRegister(handle, (original_count + 1), product_type); 1175 } else if (product_type == "Course") { 1176 if (data.available) 1177 gotoCalenderRegister(handle, (e.value), product_type); 1178 } else { 1179 cart.updatePart(data.part); 1180 } 1181 if($("#addon_qty_can_not_be_edited").length>0 && $("#addon_qty_can_not_be_edited").val()==1) //FeatureTag 1182 { 1183 var intervalId = setInterval(function() { 1184 console.log("loader_cart_pos===>", $(".loader_cart_pos:visible").length); 1185 1186 if ($(".loader_cart_pos:visible").length == 0) { 1187 $("#place_order").parent().fadeIn(); 1188 clearInterval(intervalId); // Stop the interval once the condition is met 1189 } 1190 }, 1000); 1191 1192 setTimeout(function(){ 1193 $(e).parent().find(".loader_cart_pos").addClass("hide"); 1194 },1000); 1195 } 1196 }); 1197 } 1198} 1199 1200function gotoCalenderRegister(handle, count, product_type) { 1201 let params = { 1202 handle: handle, 1203 count: count, 1204 product_type: product_type 1205 }; 1206 xhr.call('getCollection', params, 'POST') 1207 .then(function(data) { 1208 if (data.status) { 1209 if (product_type == "Course") { 1210 window.location.href = BASE_PATH + "/calendar/register/" + data.data['collection_uuid'] + "/" + data.data['id'] + "/" + data.data['count'] + "/" + data.data['handle']; 1211 } else { 1212 window.location.href = BASE_PATH + "/calendar/reserve/" + data.data['collection_uuid'] + "/" + data.data['id'] + "/" + count + "/" + data.data['handle']; 1213 } 1214 } 1215 }) 1216} 1217 1218function clearCookie() { 1219 cart.clearCookie(); 1220} 1221 1222function shippingOptionChanged(e) { 1223 var opt = $(e).val(); 1224 1225 if (opt === 'new_shipping') { 1226 OPT_BILLING_ADDRESS = 1; 1227 $("#conNewShipping").slideDown(); 1228 } else if (opt === 'same_as_shipping') { 1229 OPT_BILLING_ADDRESS = 0; 1230 $("#conNewShipping").slideUp(); 1231 } 1232} 1233$(document).ready(function() { 1234 if(paypal_flag==1){ 1235 if($("#terms_conditions").length==false) 1236 { 1237 $("#smart-button-container").show(); 1238 } 1239 if($("#DirectPayAuthForm").length==0){ 1240 $("#btnSubmitPay").hide(); 1241 } 1242 } 1243}); 1244$(document).on('click', '#terms_conditions ', function(){ 1245 if($("#terms_conditions").prop("checked")) 1246 { 1247 $(".terms_conditions").removeClass("error").css({"font-weight":"600","padding":"0px 10px"}); 1248 $(".terms_conditions_error").css({"border":"none","padding":"0px 10px","margin-bottom":"10px"}); 1249 if(paypal_flag==1){ 1250 $("#smart-button-container").show(); 1251 } 1252 }else{ 1253 if(paypal_flag==1){ 1254 $("#smart-button-container").hide(); 1255 } 1256 } 1257}); 1258function pform_submit(fid) 1259{ 1260 if($("#terms_conditions").length>0){ 1261 if(!$("#terms_conditions").prop("checked")) 1262 { 1263 $(".terms_conditions").addClass("error").css({"font-weight":"600","padding":"0px 10px"}); 1264 $(".terms_conditions_error").css({"border":"1px solid","padding":"0px 10px","margin-bottom":"10px"}); 1265 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 1266 alert(ACCEPT_TERMS_TEXT); 1267 } else { 1268 alert("Please accept the terms & conditions to proceed further."); 1269 } 1270 $('#btnSubmitPay').attr("disabled", false); 1271 return false;
1272 } 1273 } 1274 $.ajax({ 1275 url: BASE_PATH + "/checkout/check_inventory_qty", 1276 async: true, 1277 success: function success(res) { 1278 var json = $.parseJSON(res); 1279 var qty_str = ""; 1280 $.each(json.data,function(index, value){ 1281 console.log(index + '===========> ' + value); 1282 qty_str += "<br>"+value; 1283 }); 1284 if(json.status==0){ 1285 $.notify({ 1286 title: "", 1287 icon: 'glyphicon glyphicon-cart', 1288 message: qty_str 1289 }, { 1290 offset: { 1291 x: 50, 1292 y: 200 1293 }, 1294 timer: 3000, 1295 type: 'danger', 1296 animate: { 1297 enter: 'animated lightSpeedIn', 1298 exit: 'animated lightSpeedOut' 1299 } 1300 }); 1301 setTimeout(function(){ 1302 window.location.href = BASE_PATH + "/cart"; 1303 },2000); 1304 return false; 1305 }else{ 1306 reset_payment_counter(600); 1307 if(fid == "paylaterAuthForm"){ 1308 process_payment(); 1309 /** 1310 * process_payment() above already posts the order. When Pay Later was switched 1311 * on, this is the card form renamed - and its card validator is still bound, so 1312 * .submit() would run process_payment() again: a second pay_later_auth post with 1313 * the same (now used) captcha token -> "Antibot verification failed". 1314 */ 1315 if($("#add_paylater_for_stores_with_no_integrated_payments").val()==1){ //FeatureTag 1316 return; 1317 } 1318 } 1319 $('#'+fid).submit(); 1320 1321 if(fid == "DirectPayAuthForm"){ 1322 process_payment(); 1323 } 1324 1325 } 1326 } 1327 }); 1328 1329} 1330var pwd_cap_error = false; 1331var prevent_cc = 0; 1332 1333 var tot_attempt = 5; 1334 1335function prevent_cc_testing() 1336{ 1337 1338} 1339 1340 1341 1342function prevent_cc_testing_new() 1343{ 1344 $("#btnSubmitPay").attr("disabled", true); 1345 $.notify({ 1346 title: "", 1347 icon: 'glyphicon glyphicon-cart', 1348 message: "You have tried too many attempts.." 1349 }, { 1350 offset: { 1351 x: 50, 1352 y: 200 1353 }, 1354 timer: 1000, 1355 type: 'danger', 1356 animate: { 1357 enter: 'animated lightSpeedIn', 1358 exit: 'animated lightSpeedOut' 1359 } 1360 }); 1361 setTimeout(function(){ 1362 getHasChanges(true); 1363 window.location.href = BASE_PATH + "/cart"; 1364 1365 },500); 1366 return false; 1367} 1368 1369$(document).on('mouseover', '#btnSubmitPay', function() { 1370 reset_captcha('',CHECKOUT_ACTION); 1371}); 1372 1373 1374$(document).on('click', '#btnSubmitPay', function() { 1375 getHasChanges(false); 1376 if($("#pay_by").attr("data-action")=="cc") 1377 { 1378 var cccn = $("#CreditCardCardNumber").val(); 1379 var cccv = $("#CreditCardCvv").val(); 1380 var cce = $("#CreditCardExpiry").val(); 1381 var ccn = $("#CreditCardName").val(); 1382 var amountPayable_ship = parseFloat($("#amountPayable_ship").attr("data-amount")); 1383 if( (cccn=='' || cccv=='' || cce=='' || ccn=='') && amountPayable_ship>0 ) 1384 { 1385 if(amountPayable_ship>0) 1386 { 1387 $(".gc_error").html(INSUFFICIENT_GIFT_BALANCE_TEXT);//.fadeIn(); 1388 //setTimeout(function(){ $(".gc_error").fadeOut(); },5000); 1389 $("#gc_serial_number").focus(); 1390 return false; 1391 } 1392 } 1393 } 1394 if ($("#DirectPayAuthForm").length) { 1395 $('#btnSubmitPay').attr("disabled", true); 1396 pform_submit("DirectPayAuthForm"); 1397 } 1398 else if ($("#CreditCardAuthForm").length) { 1399 if($("#CreditCardAuthForm").valid()) 1400 { 1401 var btnObj = this; 1402 $(btnObj).attr('disabled', true); 1403 $('#btnSubmitPay').attr("disabled", true); 1404 reset_captcha('',CHECKOUT_ACTION); 1405 pform_submit("CreditCardAuthForm"); 1406 1407 } 1408 }else if($("#payment-form").length) 1409 { 1410 // [fix_storefront_gift_certificate_full_amount_checkout] Stripe stores gate submit on the 1411 // Stripe Elements card state (manualInputStates). When a gift certificate fully covers the 1412 // order, Amount Due is 0 and the card section is hidden, so that gate blocks checkout. Skip 1413 // card entry and use the zero-payment path (process_payment routes to /checkout/direct_pay). 1414 if($("#fix_storefront_gift_certificate_full_amount_checkout").val()==1 && parseFloat($("#amountPayable_ship").attr("data-amount"))<=0 && (typeof act_url==='undefined' || act_url!='pay_later_auth')) 1415 { 1416 act_url = 'direct_pay'; 1417 old_act_url = 'direct_pay'; 1418 $('#btnSubmitPay').attr("disabled", true); 1419 reset_captcha('',CHECKOUT_ACTION); 1420 process_payment(); 1421 } 1422 else if(act_url=='direct_pay') 1423 { 1424 var btnObj = this; 1425 $(btnObj).attr('disabled', true); 1426 $('#btnSubmitPay').attr("disabled", true); 1427 reset_captcha('',CHECKOUT_ACTION); 1428 pform_submit("payment-form"); 1429 }else{ 1430 console.log('cc',manualInputStates); 1431 1432 if(manualInputStates['cardNumber']==false ){ 1433 $('#card-errors1').html(errorInputmsg['cardNumber']); 1434 $('#card-errors1').css('display','block'); 1435 $("#btnSubmitPay").attr("disabled", false); 1436 }else{ 1437 $('#card-errors1').html(''); 1438 $('#card-errors1').css('display','none'); 1439 } 1440 if( manualInputStates['cardExpiry']==false ){ 1441 $('#card-errors3').html(errorInputmsg['cardExpiry']); 1442 $('#card-errors3').css('display','block'); 1443 $("#btnSubmitPay").attr("disabled", false); 1444 }else{ 1445 $('#card-errors3').html(''); 1446 $('#card-errors3').css('display','none'); 1447 } 1448 if( manualInputStates['cardCvc']==false ){ 1449 $('#card-errors2').html(errorInputmsg['cardCvc']); 1450 $('#card-errors2').css('display','block'); 1451 $("#btnSubmitPay").attr("disabled", false); 1452 }else{ 1453 $('#card-errors2').html(''); 1454 $('#card-errors2').css('display','none'); 1455 } 1456 if( manualInputStates['postalCode']==false){ 1457 $('#card-errors4').html(errorInputmsg['postalCode']); 1458 $('#card-errors4').css('display','block'); 1459 $("#btnSubmitPay").attr("disabled", false); 1460 }else{ 1461 $('#card-errors4').html(''); 1462 $('#card-errors4').css('display','none'); 1463 } 1464 if($("#payment-form").valid() && (manualInputStates['cardNumber']==true && manualInputStates['cardExpiry']==true && manualInputStates['cardCvc']==true && manualInputStates['postalCode']==true)) 1465 { 1466 var btnObj = this; 1467 $(btnObj).attr('disabled', true); 1468 $('#btnSubmitPay').attr("disabled", true); 1469 reset_captcha('',CHECKOUT_ACTION); 1470 pform_submit("payment-form"); 1471 1472 } 1473 } 1474 }else if($("#CardConnectCreditCardAuthForm").length) 1475 { 1476 if($("#pat_typ_partial").is(":checked") && parseFloat($("#amountPayable_ship").attr("data-amount"))==0){ 1477 process_payment(); 1478 } 1479 else{ 1480 if($("#CardConnectCreditCardAuthForm").valid()){ 1481 var btnObj = this; 1482 $(btnObj).attr('disabled', true); 1483 $('#btnSubmitPay').attr("disabled", true); 1484 reset_captcha('',CHECKOUT_ACTION); 1485 pform_submit("CardConnectCreditCardAuthForm"); 1486 1487 1488 } 1489 } 1490 1491 }else if($("#AdyenCreditCardAuthForm").length) 1492 { 1493 if($("#AdyenCreditCardAuthForm").valid()){ 1494 var btnObj = this; 1495 $(btnObj).attr('disabled', true); 1496 $('#btnSubmitPay').attr("disabled", true); 1497 reset_captcha('',CHECKOUT_ACTION); 1498 pform_submit("AdyenCreditCardAuthForm"); 1499 1500 } 1501 1502 }else if($("#WorldPayCreditCardAuthForm").length) 1503 { 1504 if(act_url=='direct_pay') 1505 { 1506 var btnObj = this; 1507 $(btnObj).attr('disabled', true); 1508 $('#btnSubmitPay').attr("disabled", true); 1509 reset_captcha('',CHECKOUT_ACTION); 1510 pform_submit("DirectPayAuthForm"); 1511 }else{ 1512 $('#btnSubmitPay').attr("disabled", true); 1513 pform_submit("WorldPayCreditCardAuthForm"); 1514 } 1515 }else if($("#TsysCreditCardAuthForm").length) 1516 { 1517 var btnObj = this; 1518 $(btnObj).attr('disabled', true); 1519 $('#btnSubmitPay').attr("disabled", true); 1520 $.ajax({ 1521 url: BASE_PATH + "/site/verify_captcha", 1522 type: "POST", 1523 data: { 1524 captcha: $("#cc_security #g-recaptcha-response").val(), 1525 action: $("#cc_security #action").val(), 1526 UserCaptcha: $("#cc_security #UserCaptcha").length ? $("#cc_security #UserCaptcha").val() : '', 1527 scode: $("#cc_security #UserCaptcha").length ? $("#cc_security #UserCaptcha").attr('data-val') : '' 1528 1529 }, 1530 success: function success(res) { 1531 reset_captcha('',CHECKOUT_ACTION); 1532 var obj = JSON.parse(res); 1533 if (Object.keys(obj).length > 1 && obj.success == true && obj.action && obj.score == captcha_threshold || Object.keys(obj).length == 1 && obj.success == true) { 1534 $('#btnSubmitPay').attr("disabled", true); 1535 pform_submit("TsysCreditCardAuthForm"); 1536 } else { 1537 $(btnObj).attr('disabled', false); 1538 $('.creload:visible').trigger('click'); 1539 $(".simple_security").fadeIn(); 1540 $(btnObj).attr('disabled', false); 1541 1542 if (obj.message) { 1543 $("#cc_security #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">' + obj.message + '</label>'); 1544 } else { 1545 $("#cc_security #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">Please enter the security code</label>'); 1546 } 1547 1548 } 1549 } 1550});
1551 } 1552 else if(paypal_flag==1 && $("#PaypalCreditCardAuthForm").length>0) 1553 { 1554 if($("#PaypalCreditCardAuthForm").valid()){ 1555 var btnObj = this; 1556 $(btnObj).attr('disabled', true); 1557 $('#btnSubmitPay').attr("disabled", true); 1558 1559 reset_captcha('',CHECKOUT_ACTION); 1560 pform_submit("PaypalCreditCardAuthForm"); 1561 1562 1563 } 1564 1565 }else if($("#paylaterAuthForm").length){ 1566 /* Pay Later terms (Cpanel): the customer must accept them before the order goes on account. 1567 Same treatment as the store Terms & Conditions check in pform_submit(). */ 1568 if($("#add_paylater_for_stores_with_no_integrated_payments").val()==1 && $("#paylater_terms_ack").length && !$("#paylater_terms_ack").prop("checked")) //FeatureTag 1569 { 1570 $(".paylater_terms").addClass("error").css({"border":"1px solid #f00","padding":"5px 10px"}); 1571 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 1572 alert(ACCEPT_PAYLATER_TERMS_TEXT); 1573 } else { 1574 alert("Please accept the Pay Later terms to proceed further."); 1575 } 1576 $('#btnSubmitPay').attr("disabled", false); 1577 return false; 1578 } 1579 //if($("#paylaterAuthForm").valid() || true){ 1580 var btnObj = this; 1581 $(btnObj).attr('disabled', true) 1582 reset_captcha('',CHECKOUT_ACTION); 1583 if($.trim($("#amountPayable_ship").attr("data-amount"))<=0){ 1584 $(".pl_error").html("Pay Later Amount should not be zero or empty!"); 1585 $(btnObj).attr('disabled', false) 1586 }else{ 1587 pform_submit("paylaterAuthForm"); 1588 } 1589 1590 /* 1591 var btnObj = this; 1592 $(btnObj).attr('disabled', true); 1593 $('#btnSubmitPay').attr("disabled", true); 1594 $.ajax({ 1595 url: BASE_PATH + "/site/verify_captcha", 1596 type: "POST", 1597 data: { 1598 captcha: $("#cc_security #g-recaptcha-response").val(), 1599 action: $("#cc_security #action").val(), 1600 UserCaptcha: $("#cc_security #UserCaptcha").length ? $("#cc_security #UserCaptcha").val() : '', 1601 scode: $("#cc_security #UserCaptcha").length ? $("#cc_security #UserCaptcha").attr('data-val') : '' 1602 1603 }, 1604 success: function success(res) { 1605 if($("#storefront_order_processing_method_upgrade").length>0 && $("#storefront_order_processing_method_upgrade").val()==1){}else{ //FeatureTag 1606 reset_captcha(); 1607 } 1608 var obj = JSON.parse(res); 1609 if (Object.keys(obj).length > 1 && obj.success == true && obj.action && obj.score == captcha_threshold || Object.keys(obj).length == 1 && obj.success == true) { 1610 $('#btnSubmitPay').attr("disabled", true); 1611 if($.trim($("#amountPayable_ship").attr("data-amount"))<=0){ 1612 $(".pl_error").html("Pay Later Amount should not be zero or empty!"); 1613 1614 }else{ 1615 pform_submit("paylaterAuthForm"); 1616 } 1617 1618 1619 } else { 1620 $(btnObj).attr('disabled', false); 1621 $('.creload:visible').trigger('click'); 1622 if($("#storefront_order_processing_method_upgrade").length>0 && $("#storefront_order_processing_method_upgrade").val()==1){ 1623 prevent_cc_testing(); 1624 } 1625 $(".simple_security").fadeIn(); 1626 $(btnObj).attr('disabled', false); 1627 1628 if (obj.message) { 1629 $("#cc_security #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">' + obj.message + '</label>'); 1630 } else { 1631 $("#cc_security #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">Please enter the security code</label>'); 1632 } 1633 1634 } 1635 } 1636 }); 1637 */ 1638 //} 1639 } 1640}); 1641 1642$(document).on('click', '.btn_place_order', function() { 1643 $("#signin_signup").show(); 1644 $(".guest_acc").show(); 1645 $.ajax({ 1646 url: BASE_PATH + "/ajax/set_ref", 1647 success: function(result) {} 1648 }); 1649}); 1650$(document).on('click', '.guest_form_btn', function() { 1651 $("#signin_signup").hide(); 1652 window.location.href = BASE_PATH + "/checkout"; 1653}); 1654 1655function show_register_form(){ 1656 $("#span_sign_in").css("display","none"); 1657 $("#span_sign_up").css("display","block"); 1658 if($("#LoginInfoCreateAccountForm:visible").length) 1659 { 1660 $("#LoginInfoCreateAccountForm:visible .simple_security").hide(); 1661 if( !$('#LoginInfoCreateAccountForm:visible #g-recaptcha-response').length ) 1662 $('#LoginInfoCreateAccountForm:visible #action').after("<input type='hidden' id='g-recaptcha-response' name='g-recaptcha-response' value='' >"); 1663 reset_captcha('',REGISTER_ACTION); 1664 } 1665 1666} 1667 1668function show_signin_form() { 1669 $("#span_sign_in").css("display", "block"); 1670 $("#span_sign_up").css("display", "none"); 1671} 1672 1673function OpenForgotPass() { 1674 $("#forgot_password").show(); 1675} 1676 1677function hideshow(which) { 1678 $(which).hide(); 1679 if ( (CONTROLL == "calendar" && ACTION == "register") || (CONTROLL == "calendar" && ACTION == "reserve") ) 1680 { 1681 window.location.reload(); 1682 } 1683 1684} 1685$(document).on('click', '#pickup_in_store', function() { 1686 cart.assignTotal(); 1687}); 1688 1689function shippingMethodChanged(e) { 1690 var opt = $(e).val(); 1691 let subTotal = 0.0; 1692 let ship_cost = 0; 1693 subTotal = Number($("#hidden_subTotal").val()); 1694 1695 var shipObj = '' 1696 if($("#deliveryAmount_ship").length){ 1697 shipObj = $("#deliveryAmount_ship"); 1698 } 1699 if($("#shipping_price").length){ 1700 shipObj = $("#shipping_price"); 1701 } 1702 1703 1704 if($('#pickup_in_store').length && opt!="pickup_in_store") 1705 {
1706 $('#pickup_in_store').prop('checked',false); 1707 } 1708 if($('#free_shipping').length && opt!="free_shipping") 1709 { 1710 $('#free_shipping').prop('checked',false); 1711 } 1712 if($('#flat_rate').length && opt!="flat_rate") 1713 { 1714 $('#flat_rate').prop('checked',false); 1715 } 1716 if($('#price_based').length && opt!="price_based") 1717 { 1718 $('#price_based').prop('checked',false); 1719 } 1720 if($('#local_delivery').length && opt!="local_delivery") 1721 { 1722 $('#local_delivery').prop('checked',false); 1723 } 1724 if($('.ups_shipping').length) 1725 { 1726 $('.ups_shipping').prop('checked',false); 1727 } 1728 1729 if($('.ship_station_shipping').length) 1730 { 1731 $('.ship_station_shipping').prop('checked',false); 1732 } 1733 1734 $.ajax({ 1735 url: BASE_PATH+"/api/getShippingCost", 1736 method: 'post', 1737 data: { 1738 "shipping_method":opt, 1739 'free_shipping_flag': $("#hidden_free_shipping_flag").val() 1740 }, 1741 success: function(result){ 1742 var json = $.parseJSON(result); 1743 $("#amountPayable_ship").html(json.total); 1744 shipObj.html(json.shipping_price); 1745 1746 $("#cart_tax").html(json.taxTotal); 1747 1748 1749 } 1750 }); 1751} 1752 1753function addCommas(nStr) { 1754 nStr += ''; 1755 var x = nStr.split('.'); 1756 var x1 = x[0]; 1757 var x2 = x.length > 1 ? '.' + x[1] : ''; 1758 var rgx = /(\d+)(\d{3})/; 1759 while (rgx.test(x1)) { 1760 x1 = x1.replace(rgx, '$1' + ',' + '$2'); 1761 } 1762 return x1 + x2; 1763} 1764 1765$(document).on('click', '.alert_place_order', function() { 1766 $("#go-top").trigger("click"); 1767 cart.showAlert('One or more reservations in your cart has expired. Please add the reservation details again to proceed', 'danger'); 1768}); 1769 1770if ($("#CustomerInfoState").length) { 1771 1772} 1773$(document).ready(function() { 1774 if ($("#CustomerInfoState").length) { 1775 $("#CustomerInfoState").trigger("change"); 1776 } 1777}); 1778$(document).on('change', '#CustomerInfoState', function() { 1779 1780 1781 var shipping_present = $("#shipping_price").length; 1782 if($("#tax_for_online_shipping").length>0 && $("#tax_for_online_shipping").val()==1) 1783 { 1784 shipping_present = ($("#shipping_price").length || $("#deliveryAmount_ship").length) ? 1 : 0; 1785 } 1786 if($("#remove_duplicitous_shipping_address_step").length>0 && $("#remove_duplicitous_shipping_address_step").val()==1) 1787 { 1788 var charter_travel = {}; 1789 $(".charter_travel").each(function() { 1790 var ct_id = $(this).attr("id"); 1791 var ct_tax = parseFloat($(this).attr("data-tax")); 1792 var ct_amount = parseFloat($(this).attr("data-amount")); 1793 charter_travel[ct_id] = {}; 1794 charter_travel[ct_id].tax = ct_tax; 1795 charter_travel[ct_id].amount = ct_amount; 1796 }); 1797 $.ajax({ 1798 url: BASE_PATH + "/checkout/getCostSummary", 1799 method: 'post', 1800 data: { 1801 'shipping' : shipping_present, 1802 'state': $(this).val(), 1803 'charter_travel': charter_travel, 1804 }, 1805 success: function(result) { 1806 var json = $.parseJSON(result); 1807 if (json.charter_travel) { 1808 $.each(json.charter_travel, function(i, part) { 1809 $("#" + i).html($("#" + i).attr('data-count') + " x " + part.amount); 1810 }); 1811 } 1812 if ($("#cart_tax").length) { 1813 $("#cart_tax").html(json.tax); 1814 } 1815 $("#amountPayable_ship").html(json.total); 1816 $("#cart_subtotal").html(json.sub); 1817 } 1818 }); 1819 }else{ 1820 var charter_travel = {}; 1821 $(".charter_travel").each(function() { 1822 var ct_id = $(this).attr("id"); 1823 var ct_tax = parseFloat($(this).attr("data-tax")); 1824 var ct_amount = parseFloat($(this).attr("data-amount")); 1825 charter_travel[ct_id] = {}; 1826 charter_travel[ct_id].tax = ct_tax; 1827 charter_travel[ct_id].amount = ct_amount; 1828 }); 1829 $.ajax({ 1830 url: BASE_PATH + "/checkout/getCostSummary", 1831 method: 'post', 1832 data: { 1833 'shipping' : shipping_present, 1834 'state': $(this).val(), 1835 'charter_travel': charter_travel, 1836 }, 1837 success: function(result) { 1838 var json = $.parseJSON(result); 1839 if (json.charter_travel) { 1840 $.each(json.charter_travel, function(i, part) { 1841 $("#" + i).html($("#" + i).attr('data-count') + " x " + part.amount); 1842 }); 1843 } 1844 if ($("#cart_tax").length) { 1845 $("#cart_tax").html(json.tax); 1846 } 1847 $("#amountPayable_ship").html(json.total); 1848 $("#cart_subtotal").html(json.sub); 1849 } 1850 }); 1851 } 1852 1853}); 1854 1855function proceed_pay_validate() 1856{ 1857 var CustomerInfoShippingForm_validate = $("#CustomerInfoShippingForm:visible").validate().checkForm(); 1858 if( CustomerInfoShippingForm_validate == true) 1859 { 1860 var captcha_length_check = $("#CustomerInfoShippingForm:visible #UserCaptchaContactCreate").length; 1861 1862 if(captcha_length_check) 1863 { 1864 $('.proceed_pay').attr('disabled',true); 1865 1866 var userCreatContactData = { 1867 captcha:$("#CustomerInfoShippingForm #g-recaptcha-response").val(), 1868 action: "user/contact_create", 1869 UserCaptcha : ($("#CustomerInfoShippingForm #UserCaptchaContactCreate").length)?$("#CustomerInfoShippingForm #UserCaptchaContactCreate").val():'', 1870 scode : ($("#CustomerInfoShippingForm #UserCaptchaContactCreate").length)?$("#CustomerInfoShippingForm #UserCaptchaContactCreate").attr('data-val'):'' 1871 1872 }; 1873 $.ajax({ 1874 url:BASE_PATH+"/site/verify_captcha", 1875 type:"POST", 1876 data: userCreatContactData, 1877 success:function(res){ 1878 reset_captcha('',REGISTER_ACTION); 1879 var obj = JSON.parse(res); 1880 if( (Object.keys(obj).length>1 && obj.success==true && obj.action && obj.score==captcha_threshold) || 1881 (Object.keys(obj).length==1 && obj.success==true) 1882 ) 1883 { 1884 $("#CustomerInfoShippingForm #g-recaptcha-response").val(''); 1885 if($('.proceed_pay').length>0){ 1886 //$('.proceed_pay').html("Proceed to Shipping"); 1887 $('.proceed_pay').prop('disabled', false); 1888 } 1889 $("#CustomerInfoShippingForm").submit(); 1890 } 1891 else 1892 { 1893 $("#CustomerInfoShippingForm:visible .simple_security").fadeIn(); 1894 $('.proceed_pay').attr('disabled',false); 1895 $('.creload:visible').trigger('click'); 1896 if(pwd_cap_error==true){ 1897 if(($("#avalara_tax_api").length>0 && $("#avalara_tax_api").val()==1) || ($("#remove_duplicitous_shipping_address_step").length>0 && $("#remove_duplicitous_shipping_address_step").val()==1)) //FeatureTag 1898 { 1899 $("#CustomerInfoShippingForm:visible").find("#usercaptcha-error").remove(); 1900 } 1901 if(obj.message){ 1902 $("#CustomerInfoShippingForm #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">'+obj.message+'</label>'); 1903 }else{ 1904 $("#CustomerInfoShippingForm #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">Please enter the security code</label>'); 1905 } 1906 }else{ 1907 if(obj.message){ 1908 $("#CustomerInfoShippingForm #UserCaptchaContactCreate").after('<label id="usercaptcha-error" class="error" for="UserCaptchaContactCreate">'+obj.message+'</label>'); 1909 }else{ 1910 $("#CustomerInfoShippingForm #UserCaptchaContactCreate").after('<label id="usercaptcha-error" class="error" for="UserCaptchaContactCreate">Please enter the security code</label>'); 1911 } 1912 pwd_cap_error = true; 1913 } 1914 } 1915 } 1916 }); 1917 }else{ 1918 var cust_form = 'CustomerInfoShippingForm'; 1919 if(!$("#" + cust_form).validate().checkForm()){ 1920 if($('.proceed_pay').length>0){ 1921 //$('.proceed_pay').html("Proceed to Shipping"); 1922 $('.proceed_pay').prop('disabled', false); 1923 } 1924 } 1925 $("#" + cust_form).submit(); 1926 } 1927 }else{ 1928 $('.proceed_pay').attr('disabled',false); 1929 var cust_form = 'CustomerInfoShippingForm'; 1930 if(!$("#" + cust_form).validate().checkForm()){ 1931 if($('.proceed_pay').length>0){ 1932 //$('.proceed_pay').html("Proceed to Shipping"); 1933 $('.proceed_pay').prop('disabled', false); 1934 } 1935 } 1936 $("#" + cust_form).submit(); 1937 } 1938 if(($("#avalara_tax_api").length>0 && $("#avalara_tax_api").val()==1) || ($("#remove_duplicitous_shipping_address_step").length>0 && $("#remove_duplicitous_shipping_address_step").val()==1)) //FeatureTag 1939 { 1940 $("#CustomerInfoShippingForm:visible").find("#usercaptcha-error").remove(); 1941 if($("#CustomerInfoShippingForm:visible #UserCaptcha").val()=='') 1942 { 1943 $("#CustomerInfoShippingForm:visible #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">Please enter the security code</label>'); 1944 } 1945 } 1946} 1947 1948 1949 1950 1951$(document).on('click', '.proceed_pay ', function() { 1952 //$(".proceed_pay").html("<img src='"+BASE_PATH+"/img/loading1.gif'>Loading..."); 1953 $(this).prop('disabled', true); 1954 setTimeout(function() 1955 { 1956 var cust_form = 'CustomerInfoShippingForm'; 1957 if ($("#" + cust_form).attr('data-token') != '') { 1958 $("#" + cust_form).attr('action', '/checkout/payment/'
1958+ $("#" + cust_form).attr('data-token')); 1959 } 1960 if ($(".ck_email").length > 0 && $(".ck_email").val() != '') { 1961 $.ajax({ 1962 url: BASE_PATH + "/site/checkEmail", 1963 type: "post", 1964 async: false, 1965 data: { 1966 email_id: function() { 1967 return $("#CustomerInfoEmail").val(); 1968 } 1969 }, 1970 success: function(msg) { 1971 if ($.trim(msg) == "false") { 1972 $("#signin_signup").show(); 1973 } else { 1974 if($("#avalara_tax_api").length>0 && $("#avalara_tax_api").val()==1) //FeatureTag 1975 { 1976 proceed_pay_validate(); 1977 } 1978 else{ 1979 if(!$("#" + cust_form).validate().checkForm()){ 1980 if($('.proceed_pay').length>0){ 1981 //$('.proceed_pay').html("Proceed to Shipping"); 1982 $('.proceed_pay').prop('disabled', false); 1983 } 1984 } 1985 $("#" + cust_form).submit(); 1986 } 1987 1988 } 1989 } 1990 }); 1991 } else { 1992 if($("#avalara_tax_api").length>0 && $("#avalara_tax_api").val()==1) //FeatureTag 1993 { 1994 proceed_pay_validate(); 1995 } 1996 else{ 1997 if(!$("#" + cust_form).validate().checkForm()){ 1998 if($('.proceed_pay').length>0){ 1999 //$('.proceed_pay').html("Proceed to Shipping"); 2000 $('.proceed_pay').prop('disabled', false); 2001 } 2002 } 2003 $("#" + cust_form).submit(); 2004 } 2005 } 2006 },1000); 2007}); 2008function htmlDecode(input) { 2009 var doc = new DOMParser().parseFromString(input, "text/html"); 2010 return doc.documentElement.textContent; 2011} 2012$(document).on('change', '.ck_fname, .ck_lname, .ck_email ', function() { 2013 var dssf_tmp_id = this.value; 2014 if (dssf_tmp_id != 'new') { 2015 var data_type = $(this).attr("data-type"); 2016 if (data_type == 'fname') { 2017 $(".ck_lname").val(dssf_tmp_id); 2018 $(".ck_email").val(dssf_tmp_id); 2019 } else if (data_type == "lname") { 2020 $(".ck_fname").val(dssf_tmp_id); 2021 $(".ck_email").val(dssf_tmp_id); 2022 } else if (data_type == "email") { 2023 $(".ck_fname").val(dssf_tmp_id); 2024 $(".ck_lname").val(dssf_tmp_id); 2025 } 2026 $("#CustomerInfoFirstName").val(htmlDecode($(".ck_fname").find("option:selected").html())).attr("type", "hidden"); 2027 $("#CustomerInfoLastName").val(htmlDecode($(".ck_lname").find("option:selected").html())).attr("type", "hidden"); 2028 if ($(".ck_email").val() != null) { 2029 $("#CustomerInfoEmail").val($(".ck_email").find("option:selected").html()).attr("type", "hidden"); 2030 $(".ck_email").removeClass("hide"); 2031 2032 var res = $("#CustomerInfoEmail").val().split(" ("); 2033 $("#CustomerInfoEmail").val(res[0]); 2034 2035 $.ajax({ 2036 url: BASE_PATH + "/site/checkEmail", 2037 type: "post", 2038 async: false, 2039 data: { 2040 email_id: function() { 2041 return $("#CustomerInfoEmail").val(); 2042 } 2043 }, 2044 success: function(msg) { 2045 if ($.trim(msg) == "false") { 2046 $("#signin_signup").show(); 2047 } 2048 } 2049 }); 2050 } else { 2051 $("#CustomerInfoEmail").attr("type", "text").val(''); 2052 $(".ck_email").addClass("hide"); 2053 } 2054 2055 2056 $("#CustomerInfoDssfTmpId").val(dssf_tmp_id).attr("type", "hidden"); 2057 if ($("#CreditCardFirstName").length > 0) { 2058 $("#CreditCardFirstName").attr("type", 'hidden').val($(".ck_fname").find("option:selected").html()); 2059 } 2060 if ($("#CreditCardLastName").length > 0) { 2061 $("#CreditCardLastName").attr("type", 'hidden').val($(".ck_fname").find("option:selected").html()); 2062 } 2063 } else { 2064 $("#CustomerInfoDssfTmpId").val(''); 2065 $(".ck_fname").remove(); 2066 $(".ck_lname").remove(); 2067 $(".ck_email").remove(); 2068 $("#CustomerInfoFirstName").attr("type", 'text').val(''); 2069 $("#CustomerInfoLastName").attr("type", 'text').val(''); 2070 $("#CustomerInfoEmail").attr("type", 'text').val(''); 2071 if ($("#CreditCardFirstName").length > 0) { 2072 $("#CreditCardFirstName").attr("type", 'text').val(''); 2073 $("#CreditCardLastName").attr("type", 'text').val(''); 2074 } 2075 } 2076 2077}); 2078 2079 2080$(document).ready(function() { 2081 $(".gc_amt_btn").click(function() { 2082 $(".gc_amt_btn").removeClass('gc-form-selected-btn'); 2083 $(this).addClass('gc-form-selected-btn'); 2084 2085 }); 2086 $("#add_to_cart_gc").click(function() { 2087 2088 if($("#enable_maintenance_mode_in_add_to_cart_on_sf").length>0 && $("#enable_maintenance_mode_in_add_to_cart_on_sf").val()==1) //FeatureTag 2089 { 2090 if(ADD_TO_CART_MAINTENANCE_MODE==1){ 2091 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 2092 $.notify({ 2093 title: "<strong class='insufficient-quantity-cart'>"+SYSTEM_MAINTENANCE_TEXT+"</strong> ", 2094 icon: 'glyphicon glyphicon-info-sign', 2095 message: ADD_TO_CART_MAINTENANCE_MODE_MSG 2096 }, { 2097 timer: 2000, 2098 type: 'danger', 2099 animate: { 2100 enter: 'animated lightSpeedIn', 2101 exit: 'animated lightSpeedOut' 2102 } 2103 }); 2104 } else { 2105 $.notify({ 2106 title: "<strong class='insufficient-quantity-cart'>Alert: System Maintenance</strong> ", 2107 icon: 'glyphicon glyphicon-info-sign', 2108 message: ADD_TO_CART_MAINTENANCE_MODE_MSG 2109 }, { 2110 timer: 2000, 2111 type: 'danger', 2112 animate: { 2113 enter: 'animated lightSpeedIn', 2114 exit: 'animated lightSpeedOut' 2115 } 2116 }); 2117 } 2118 setTimeout(function () { 2119 window.location.reload(); 2120 },1000); 2121 return false; 2122 } 2123 } 2124 2125 $("#add_to_cart_gc").attr("disabled", true); 2126 if($("#gc_to_amount").val() == ''){ 2127 $("#gc_to_amount").val($("#custom_gc_amount").val()); 2128 } 2129 if ($("#gc_to_amount").val() == '' || $("#gc_to_amount").val() == 0) { 2130 if ($("#gc-amt-error").length == 0) 2131 { 2132 if($("#custom_gc_amount").length>0){ 2133 $("#gc_to_amount").after('<label id="gc-amt-error" style="color:#f00;font-weight:bold;">'+PLEASE_CHOOSE_OR_ENTER_GIFT_CARD_AMOUNT_TEXT+'.</label>'); 2134 }else{ 2135 $("#gc_to_amount").after('<label id="gc-amt-error" style="color:#f00;font-weight:bold;">'+PLEASE_CHOOSE_GIFT_CARD_AMOUNT_TEXT+'.</label>'); 2136 } 2137 } 2138 2139 $("#add_to_cart_gc").attr("disabled", false); 2140 return false;
2141 } else { 2142 $("#gc-amt-error").remove(); 2143 } 2144 2145 if ($("#gc_to_amount").val() < 1) { 2146 $("#gc_to_amount").after('<label id="gc-amt-error" style="color:#f00;font-weight:bold;">'+GIFT_CARD_AMOUNT_SHOULD_BE_GREATER_THAN_ONE_TEXT+'.</label>'); 2147 $("#add_to_cart_gc").attr("disabled", false); 2148 return false; 2149 } 2150 2151 if ($("#gc_form").valid()) { 2152 var count = $("#gc_qty").val(); 2153 let params = { 2154 handle: $(this).attr('data-handle'), 2155 part_type: 'GiftCertificate' 2156 }; 2157 var formdata = $("#gc_form").serializeArray(); 2158 $(formdata).each(function(index, obj) { 2159 params[obj.name] = obj.value; 2160 }); 2161 var gc_unique_id = new Date().valueOf(); 2162 params['gc_unique_id'] = gc_unique_id; 2163 2164 xhr.call('getPartDetails', params, 'POST') 2165 .then(function(data) { 2166 if (data.status) { 2167 2168 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 2169 $.notify({ 2170 from: "bottom", 2171 title: "<strong></strong> ", 2172 icon: 'glyphicon glyphicon-shopping-cart', 2173 message: CART_ADDED_SUCCESS_TEXT 2174 }, { 2175 timer: 1000, 2176 type: 'success', 2177 animate: { 2178 enter: 'animated lightSpeedIn', 2179 exit: 'animated lightSpeedOut' 2180 } 2181 }); 2182 } else { 2183 $.notify({ 2184 from: "bottom", 2185 title: "<strong></strong> ", 2186 icon: 'glyphicon glyphicon-shopping-cart', 2187 message: "Added to your cart successfully...!" 2188 }, { 2189 timer: 1000, 2190 type: 'success', 2191 animate: { 2192 enter: 'animated lightSpeedIn', 2193 exit: 'animated lightSpeedOut' 2194 } 2195 }); 2196 } 2197 2198 data.data.count = count; 2199 var gc_am_val = $("#gc_to_amount").val().replace("$", ""); 2200 if(/^[0-9.+]+$/.test(gc_am_val)){ 2201 data.data.price = gc_am_val; 2202 } 2203 data.data.gc_unique_id = gc_unique_id; 2204 cart.addPart(data.data); 2205 var part_cart_interval = setInterval(function () { 2206 if(cart_l>0) 2207 { 2208 clearInterval(part_cart_interval); 2209 window.location.href = BASE_PATH + '/cart'; 2210 } 2211 },1000); 2212 2213 } 2214 }); 2215 return false; 2216 } else { 2217 $("#add_to_cart_gc").attr("disabled", false); 2218 } 2219 2220 }); 2221}); 2222 2223$(document).ready(function(){ 2224 checkout_buttons(); 2225}); 2226function checkout_buttons() 2227{ 2228 if($(".item_not_available").length>0) 2229 { 2230 2231 if (CONTROLL == "checkout" && ACTION == "index" ) 2232 { 2233 $(".proceed_pay").attr("disabled",true); 2234 } 2235 else if(CONTROLL == "checkout" && ACTION == "shipping") 2236 { 2237 $('#shipping_ahref').attr('disabled',true); 2238 } 2239 else if(CONTROLL == "checkout" && ACTION == "payment") 2240 { 2241 $('#btnSubmitPay').attr('disabled',true); 2242 } 2243 else if (CONTROLL == "products" && ACTION == "cart" ) 2244 { 2245 if($(".btn_place_order").length>0) 2246 { 2247 $(".btn_place_order").attr("disabled",true); 2248 } 2249 else if($("#place_order").length>0) 2250 { 2251 $("#place_order").attr("disabled",true); 2252 } 2253 } 2254 if (CONTROLL == "checkout") 2255 { 2256 setTimeout(function(){ 2257 2258 $.notify({ 2259 title: "", 2260 icon: 'glyphicon glyphicon-cart', 2261 message: "Please edit your cart and try again." 2262 }, { 2263 offset: { 2264 x: 50, 2265 y: 200 2266 }, 2267 timer: 1000, 2268 type: 'danger', 2269 animate: { 2270 enter: 'animated lightSpeedIn', 2271 exit: 'animated lightSpeedOut' 2272 } 2273 }); 2274 2275 },1000); 2276 } 2277 } 2278} 2279function addToCartReplace(handle, count, cInv,pkg_replace,pkg_price,pkg_replace_price) { 2280 if($("#enable_maintenance_mode_in_add_to_cart_on_sf").length>0 && $("#enable_maintenance_mode_in_add_to_cart_on_sf").val()==1) //FeatureTag 2281 { 2282 if(ADD_TO_CART_MAINTENANCE_MODE==1){ 2283 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 2284 $.notify({ 2285 title: "<strong class='insufficient-quantity-cart'>"+SYSTEM_MAINTENANCE_TEXT+"</strong> ", 2286 icon: 'glyphicon glyphicon-info-sign', 2287 message: ADD_TO_CART_MAINTENANCE_MODE_MSG 2288 }, { 2289 timer: 2000, 2290 type: 'danger', 2291 animate: { 2292 enter: 'animated lightSpeedIn', 2293 exit: 'animated lightSpeedOut' 2294 } 2295 }); 2296 } else { 2297 $.notify({ 2298 title: "<strong class='insufficient-quantity-cart'>Alert: System Maintenance</strong> ", 2299 icon: 'glyphicon glyphicon-info-sign', 2300 message: ADD_TO_CART_MAINTENANCE_MODE_MSG 2301 }, { 2302 timer: 2000, 2303 type: 'danger', 2304 animate: { 2305 enter: 'animated lightSpeedIn', 2306 exit: 'animated lightSpeedOut' 2307 } 2308 }); 2309 } 2310 setTimeout(function () { 2311 window.location.reload(); 2312 },1000); 2313 return false; 2314 } 2315 } 2316 var e = document.getElementById("numProductQty"); 2317 var isValid = (!cInv) ? true : e.validity.valid; 2318 if(handle && isValid) { 2319 let params = {handle: handle,part_type:'product'}; 2320 xhr.call('getPartDetails', params, 'POST') 2321 .then(function(data) { 2322 if(data.status) { 2323 data.data.count = count; 2324 data.data.pkg_replace = pkg_replace; 2325 if(pkg_price!='') 2326 { 2327 data.data.price = pkg_price; 2328 } 2329 data.data.pkg_replace_price = pkg_replace_price; 2330 cart.addPart(data.data); 2331 var part_cart_interval = setInterval(function () { 2332 if(cart_l>0) 2333 { 2334 clearInterval(part_cart_interval); 2335 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 2336 $.notify({ 2337 from: "bottom", 2338 title: "<strong></strong> ", 2339 icon: 'glyphicon glyphicon-shopping-cart', 2340 message: CART_ADDED_SUCCESS_TEXT 2341 },{timer: 1000,type: 'success',animate: {enter: 'animated lightSpeedIn',exit: 'animated lightSpeedOut'}}); 2342 } else { 2343 $.notify({ 2344 from: "bottom", 2345 title: "<strong></strong> ", 2346 icon: 'glyphicon glyphicon-shopping-cart', 2347 message: "Added to your cart successfully...!" 2348 },{timer: 1000,type: 'success',animate: {enter: 'animated lightSpeedIn',exit: 'animated lightSpeedOut'}}); 2349 } 2350 2351 window.location.reload(); 2352 } 2353 },1000); 2354 } 2355 }); 2356 2357 }else if(!e.validity.valid) { 2358 2359 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 2360 $.notify({ 2361 title: "<strong></strong> ", 2362 icon: 'glyphicon glyphicon-shopping-cart', 2363 message: INSUFFICIENT_QUANTITY_TEXT 2364 },{timer: 1000,type: 'danger',animate: {enter: 'animated lightSpeedIn',exit: 'animated lightSpeedOut'}}); 2365 2366 cart.showAlert(INSUFFICIENT_QUANTITY_TEXT, 'danger'); 2367 } else { 2368 $.notify({ 2369 title: "<strong></strong> ", 2370 icon: 'glyphicon glyphicon-shopping-cart', 2371 message: "Insufficient Quantity!" 2372 },{timer: 1000,type: 'danger',animate: {enter: 'animated lightSpeedIn',exit: 'animated lightSpeedOut'}}); 2373 2374 cart.showAlert('Insufficient Quantity!', 'danger'); 2375 } 2376 location.reload(); 2377 }else { 2378 2379 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 2380 $.notify({ 2381 title: "<strong></strong> ", 2382 icon: 'glyphicon glyphicon-shopping-cart', 2383 message: UNABLE_TO_ADD_PRODUCT_CART_TEXT 2384 },{timer: 1000,type: 'dangert',animate: {enter: 'animated lightSpeedIn',exit: 'animated lightSpeedOut'}}); 2385 2386 cart.showAlert(UNABLE_TO_ADD_PRODUCT_CART_TEXT, 'danger'); 2387 } else { 2388 $.notify({ 2389 title: "<strong></strong> ", 2390 icon: 'glyphicon glyphicon-shopping-cart', 2391 message: "Unable to add product to cart!" 2392 },{timer: 1000,type: 'dangert',animate: {enter: 'animated lightSpeedIn',exit: 'animated lightSpeedOut'}}); 2393 2394 cart.showAlert('Unable to add product to cart!', 'danger'); 2395 } 2396 } 2397} 2398 2399if (CONTROLL == "checkout" && (ACTION == "payment" || ACTION == "confirm") ) 2400{ 2401 (function (global) { 2402 if(typeof (global) === "undefined") 2403 { 2404 throw new Error("window is undefined"); 2405 } 2406 var _hash = "!"; 2407 var noBackPlease = function () { 2408 global.location.href += "#"; 2409 global.setTimeout(function () { 2410 global.location.href += "!"; 2411 }, 50); 2412 }; 2413 global.onhashchange = function () { 2414 if (global.location.hash !== _hash) { 2415 global.location.hash = _hash; 2416 } 2417 }; 2418 global.onload = function () { 2419 noBackPlease(); 2420 document.body.onkeydown = function (e) { 2421 var elm = e.target.nodeName.toLowerCase(); 2422 if (e.which === 8 && (elm !== 'input' && elm !== 'textarea')) { 2423 e.preventDefault(); 2424 } 2425 e.stopPropagation(); 2426 }; 2427 2428 }; 2429 })(window); 2430} 2431 2432$(document).on('click', '.remove_coupon ', function() { 2433 var c_id = $(this).attr('data-coupon'); 2434 var c_id1 = $(this).attr('data-id'); 2435 $("#coupon_" + c_id1).remove(); 2436 $.ajax({ 2437 url: BASE_PATH + "/api/remove_coupon", 2438 type: "post", 2439 async: false, 2440 data: { 2441 'coupon_code': c_id, 2442 'total': $("#amountPayable_ship").attr("data-amount") 2443 }, 2444 success: function(result) { 2445 var obj = jQuery.parseJSON(result); 2446 $("#amountPayable_ship").attr("data-amount", obj.total).html(obj.tot_label); 2447 $("#coupon_value").html(obj.reward_val_label); 2448 $("#coupon_value").attr("data-amount", obj.reward_value); 2449 $("#coupon_code").attr('readonly', false); 2450 $(".coupon_success").addClass("hide"); 2451 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 2452 $.notify({ 2453 from: "bottom", 2454 title: "<strong></strong> ", 2455 icon: 'glyphicon glyphicon-tags', 2456 message: COUPON_REMOVED_SUCCESS_TEXT 2457 }, { 2458 timer: 1000, 2459 type: 'success', 2460 animate: { 2461 enter: 'animated lightSpeedIn', 2462 exit: 'animated lightSpeedOut' 2463 } 2464 }); 2465 } else { 2466 $.notify({ 2467 from: "bottom", 2468 title: "<strong></strong> ", 2469 icon: 'glyphicon glyphicon-tags', 2470 message: ' Coupon removed successfully...!' 2471 }, { 2472 timer: 1000, 2473 type: 'success', 2474 animate: { 2475 enter: 'animated lightSpeedIn', 2476 exit: 'animated lightSpeedOut' 2477 } 2478 }); 2479 } 2480 2481 2482 } 2483 }); 2484}); 2485$(document).on('click', '#apply_coupon ', function() { 2486 var btnObj = $(this); 2487 if (CONTROLL == "checkout" && ACTION == "index") { 2488 var coupon_code = $("#coupon_code").val(); 2489 if (coupon_code != '') { 2490 $.ajax({ 2491 url: BASE_PATH + "/api/checkCouponValidity", 2492 type: "post", 2493 async: false, 2494 data: { 2495 'coupon_code': coupon_code, 2496 'total': $("#amountPayable_ship").attr("data-amount"), 2497 'reward_value': $("#coupon_value").attr("data-amount") 2498 }, 2499 success: function(result) { 2500 var obj = jQuery.parseJSON(result); 2501 if (obj.status == 1) { 2502 $("#amountPayable_ship").attr("data-amount", obj.data.total).html(obj.data.tot_label); 2503 $("#coupon_value").html(obj.data.reward_val_label); 2504 $("#coupon_value").attr("data-amount", (parseFloat(obj.data.reward_value)+parseFloat($("#coupon_value").attr("data-amount"))) ); 2505 2506 $.notify({ 2507 from: "bottom", 2508 title: "<strong></strong> ", 2509 icon: 'glyphicon glyphicon-tags', 2510 message: ' "' + coupon_code + '" has been applied successfully...!' 2511 }, { 2512 timer: 1000, 2513 type: 'success', 2514 animate: { 2515 enter: 'animated lightSpeedIn', 2516 exit: 'animated lightSpeedOut' 2517 } 2518 }); 2519 2520 $.each(obj.data.cart, function(i, tcart) { 2521 console.log(tcart.id+"====="+tcart.part+"======"+tcart.category); 2522 if(tcart.part==true && tcart.category==true) 2523 { 2524 $(".coupon_"+tcart.id).removeClass("hide"); 2525 console.log("1===="+tcart.id) 2526 }
2527 else if(tcart.part==true && tcart.category==undefined) 2528 { 2529 $(".coupon_"+tcart.id).removeClass("hide"); 2530 console.log("2===="+tcart.id) 2531 } 2532 else if( tcart.part==undefined && tcart.category==true) 2533 { 2534 console.log("3===="+tcart.id) 2535 $(".coupon_"+tcart.id).removeClass("hide"); 2536 } 2537 }); 2538 2539 var loyalty_reward_value = obj.data.reward_val_label1; 2540 var loyalty_program_name = obj.data.program_name; 2541 var loyalty_program_des = obj.data.description; 2542 var str_html = ''; 2543 var cp_id = 1; 2544 if($(".remove_coupon").length>0){ 2545 cp_id = parseInt($(".remove_coupon").last().attr('data-id'))+1; 2546 } 2547 str_html += "<div class='row dotted_border' id='coupon_" + cp_id + "'>"; 2548 str_html += "<div class='col-lg-2 RM_PLR15'>"; 2549 str_html += "<strong>" + coupon_code + "</strong>"; 2550 str_html += "</div>"; 2551 str_html += "<div class='col-lg-8 RM_PLR15'>"; 2552 str_html += "<strong>" + loyalty_program_name + "</strong> - "; 2553 str_html += loyalty_program_des; 2554 str_html += "</div>"; 2555 str_html += "<div class='col-lg-2 RM_PLR15'>"; 2556 str_html += loyalty_reward_value + " <i class='fa fa-trash-o remove_coupon' data-coupon='" + coupon_code + "' data-id='" + cp_id + "'></i>"; 2557 str_html += "</div></div>"; 2558 $("#coupon_details").append(str_html); 2559 $("#coupon_code").focus().val(''); 2560 } else { 2561 var msg = '"' + coupon_code + '" ' + IS_INVALID_COUPON_TEXT; 2562 if (obj.message) { 2563 msg = obj.message; 2564 } 2565 $.notify({ 2566 from: "bottom", 2567 title: "<strong></strong> ", 2568 icon: 'glyphicon glyphicon-tags', 2569 message: msg 2570 }, { 2571 timer: 1000, 2572 type: 'danger', 2573 animate: { 2574 enter: 'animated lightSpeedIn', 2575 exit: 'animated lightSpeedOut' 2576 } 2577 }); 2578 2579 $("#coupon_code").focus().val(''); 2580 } 2581 } 2582 }); 2583 } else { 2584 $("#coupon_code").focus().val(''); 2585 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 2586 $.notify({ 2587 from: "bottom", 2588 title: "<strong></strong> ", 2589 icon: 'glyphicon glyphicon-tags', 2590 message: ENTER_COUPON_TEXT 2591 }, { 2592 timer: 1000, 2593 type: 'danger', 2594 animate: { 2595 enter: 'animated lightSpeedIn', 2596 exit: 'animated lightSpeedOut' 2597 } 2598 }); 2599 } else { 2600 $.notify({ 2601 from: "bottom", 2602 title: "<strong></strong> ", 2603 icon: 'glyphicon glyphicon-tags', 2604 message: PLEASE_ENTER_THE_COUPON_TEXT+'..!' 2605 }, { 2606 timer: 1000, 2607 type: 'danger', 2608 animate: { 2609 enter: 'animated lightSpeedIn', 2610 exit: 'animated lightSpeedOut' 2611 } 2612 }); 2613 } 2614 } 2615 } 2616}); 2617$(document).on('click', '.remove_gc ', function() { 2618 $("#gc_serial_number").attr('readonly',false);
2619 $('#pay_by').attr("disabled",false); 2620 2621 $(".gc_error").html(""); 2622 var gc_serial_number = $(this).attr('data-gc'); 2623 $("tr." +gc_serial_number).remove(); 2624 2625 if($(".gc_serial_number_list").find('tr').length==1) 2626 { 2627 $(".gc_serial_number_list").addClass("hide"); 2628 } 2629 $("#gc_apply").attr('disabled',false); 2630 2631 $.ajax({ 2632 url: BASE_PATH + "/api/removeGiftSerialNumber", 2633 type: "post", 2634 async: false, 2635 data: { 2636 'gc_serial_number': gc_serial_number, 2637 'total': $("#amountPayable_ship").attr("data-amount") 2638 }, 2639 success: function(result) { 2640 var obj = jQuery.parseJSON(result); 2641 2642 if(obj.total_gc_price>0) 2643 { 2644 var str_html = ''; 2645 str_html += "<div class='panel panel-default'>"; 2646 str_html += "<div class='panel-heading'>"; 2647 str_html += "<div class='row gc_disc' id='gc_discount' data-amount='"+obj.total_gc_price+"'>"; 2648 str_html += "<div class='col-lg-10 RM_PLR15'>"; 2649 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 2650 str_html += "<strong>"+GIFT_CERTIFICATE_TEXT+"</strong>"; 2651 } else { 2652 str_html += "<strong>Gift Certificate</strong>"; 2653 } 2654 str_html += "</div>"; 2655 str_html += "<div class='col-lg-2 RM_PLR15' style='text-align:right'>"; 2656 str_html += obj.total_gc_price_label; 2657 str_html += "</div></div>"; 2658 str_html += "<div class='row gc_discount_amt_due' id='gc_discount' data-amount='"+obj.total_gc_price+"'>"; 2659 str_html += "<div class='col-lg-10 RM_PLR15'>"; 2660 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 2661 str_html += "<strong>"+AMOUNT_DUE_TEXT+"</strong>"; 2662 } else { 2663 str_html += "<strong>Amount Due</strong>"; 2664 } 2665 str_html += "</div>"; 2666 str_html += "<div class='col-lg-2 RM_PLR15 amt_due' style='text-align:right'>"; 2667 str_html += obj.total_label; 2668 str_html += "</div></div>"; 2669 2670 str_html += "</div>"; 2671 str_html += "</div>"; 2672 2673 console.log('pay_rm_length',$(".pay_rm").length); 2674 console.log('gc_discount',$("#gc_discount").length); 2675 if($(".pay_rm").length > 0){ 2676 $(".gc_disc").parent().parent().remove(); 2677 }else{ 2678 if($("#gc_discount").length>0) 2679 { 2680 $("#gc_discount").parent().parent().remove(); 2681 } 2682 } 2683 2684 console.log(str_html); 2685 $(".costSummary").append(str_html); 2686 $("#amountPayable_ship").attr("data-amount",obj.total); 2687 } 2688 else 2689 { console.log('pay_late_lable length', $(".pay_late_lable").length); 2690 if($(".pay_late_lable").length > 0){ 2691 2692 $(".gc_disc").remove(); 2693 $("#amountPayable_ship").attr("data-amount",obj.total); 2694 $("#pay_late_amt_disp").html(obj.total_label); 2695 $(".amt_due").html(obj.total_label); 2696 }else{ 2697 $(".gc_disc").parent().parent().remove(); 2698 // $("#gc_discount").parent().parent().remove(); 2699 $("#amountPayable_ship").attr("data-amount",obj.total); 2700 $(".amt_due").html(obj.total_label); 2701 2702 } 2703 } 2704 2705 if(obj.total>0) 2706 { 2707 $("#card_pay").show(); 2708 $('#credit').css('display','inline'); 2709 $('#credit').prop('checked', true); 2710 $('#credit').next('.pay_m').css('display','inline'); 2711 $('#credit-handkey-exist').css('display','inline'); 2712 $('.pay_m_type').css('display','inline'); 2713 $('#save_vault').show(); 2714 2715 if($(".gc_serial_number_list").find('tr').length==1) 2716 { 2717 paybtn(); 2718 }else{ 2719 $("#gc_serial_number").focus(); 2720 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 2721 var emsg = "<p>"+INSUFFICIENT_GIFT_BALANCE_TEXT+"</p>"; 2722 } else { 2723 var emsg = "<p>The gift certificate you have entered don't have sufficient balance to complete the order. Enter an additional gift certificate or use credit card to pay the balance</p>"; 2724 } 2725 var eclass = "gc_error"; 2726 paybtn(eclass,emsg); 2727 } 2728 }else{ 2729 paybtn(); 2730 } 2731 2732 2733 2734 2735 $.notify({ 2736 from: "bottom", 2737 title: "<strong></strong> ", 2738 icon: 'glyphicon glyphicon-tags', 2739 message: GIFT_CERTIFICATE_NUMBER_REMOVED_SUCCESSFULLY_TEXT 2740 }, { 2741 timer: 1000, 2742 type: 'success', 2743 animate: { 2744 enter: 'animated lightSpeedIn', 2745 exit: 'animated lightSpeedOut' 2746 } 2747 }); 2748 2749 } 2750 }); 2751}); 2752$(document).on('keypress', '#gc_serial_number', function(event){ 2753 if (event.keyCode === 13) { 2754 if($("#check_gc_balance").length>0){ 2755 $("#check_gc_balance").trigger("click"); 2756 } 2757 else if($("#gc_apply").length>0){ 2758 $("#gc_apply").trigger("click"); 2759 } 2760 } 2761}); 2762$(document).on('keypress', '#UserCaptcha', function(event){ 2763 if (event.keyCode === 13) { 2764 if($("#gc_captcha_verify").length>0){ 2765 $("#gc_captcha_verify").trigger("click"); 2766 } 2767 } 2768}); 2769$(document).on('click', '#gc_captcha_verify', function() { 2770 $('#gc_captcha_verify').attr("disabled",true).html("<img src='"+BASE_PATH +"/img/loading1.gif'>"); 2771 if($("#UserCaptchaGiftCard").is(":visible") && $("#UserCaptchaGiftCard").val()!='') { 2772 var gc_captcha_data = { 2773 'captcha_code':$("#UserCaptchaGiftCard").val(), 2774 'action' : 'user/redeem_gift_card' 2775 }; 2776 }else{ 2777 $(".gc_error").html("Please enter the captcha code");
2778 $('#gc_captcha_verify').attr("disabled",false).html("Submit"); 2779 return false; 2780 } 2781 $.ajax({ 2782 url: BASE_PATH + "/api/verifycaptcha", 2783 type: "post", 2784 async: false, 2785 data: gc_captcha_data, 2786 success: function(result) { 2787 setTimeout(function(){$('#gc_captcha_verify').attr("disabled",false).html("Submit");},1200); 2788 var obj = jQuery.parseJSON(result); 2789 if (obj.status == 0) { 2790 $(".gc_error").html("Invalid Captcha Code"); 2791 gc_apply_click++; 2792 $(".creload:visible").trigger("click"); 2793 }else{ 2794 $(".gc_error").html(""); 2795 $("#gc_serial_number").parent().parent().parent().removeClass("hide"); 2796 $(".gc_captcha").addClass("hide"); 2797 $("#gc_serial_number").focus(); 2798 gc_apply_click = 0; 2799 if($(".gc_serial_number_list").find('tr').length>1) 2800 { 2801 $(".gc_serial_number_list").removeClass("hide"); 2802 } 2803 if(parseFloat($("#amountPayable_ship").attr("data-amount"))>0 && $(".gc_serial_number_list").find('tr').length>1) 2804 { 2805 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 2806 var err_msg = "<p>"+INSUFFICIENT_GIFT_BALANCE_TEXT+"</p>"; 2807 } else { 2808 var err_msg = "<p>The gift certificate you have entered don't have sufficient balance to complete the order. Enter an additional gift certificate or use credit card to pay the balance</p>"; 2809 } 2810 $(".gc_error").html(err_msg); 2811 } 2812 2813 } 2814 } 2815 }); 2816}); 2817var gc_apply_click = 0; 2818$(document).on('click', '#gc_apply', function() { 2819 $('#gc_apply').attr("disabled",true).html("<img src='"+BASE_PATH +"/img/loading1.gif'>"); 2820 if(gc_apply_click>=4) 2821 { 2822 $(".gc_captcha").removeClass("hide"); 2823 $(".creload:visible").trigger("click"); 2824 $("#UserCaptcha:visible").val(""); 2825 $("#gc_serial_number").val(""); 2826 $("#gc_serial_number").parent().parent().parent().addClass("hide"); 2827 if($(".gc_serial_number_list").find('tr').length>1) 2828 { 2829 $(".gc_serial_number_list").addClass("hide"); 2830 } 2831 $(".gc_error").html(""); 2832 $('#gc_apply').attr("disabled",false).html("Apply"); 2833 return false; 2834 } 2835 2836 // if($("#UserCaptcha").is(":visible") && $("#UserCaptcha").val()=='') 2837 // { 2838 // $("#UserCaptcha").focus(); 2839 // $(".gc_error").html("Please enter the captcha code"); 2840 // return false; 2841 // } 2842 2843 $('#btnSubmitPay').attr("disabled", false); 2844 var gc_serial_number = $.trim($("#gc_serial_number").val()); 2845 if(gc_serial_number=='') 2846 { 2847 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 2848 $.notify({ 2849 from: "bottom", 2850 title: "<strong></strong> ", 2851 icon: 'glyphicon glyphicon-gift', 2852 message: ' <b>'+PLEASE_ENTER_GIFT_CERTIFICATE_TEXT+'</b>' 2853 }, { 2854 timer: 1000, 2855 type: 'danger', 2856 offset: { x: 50, y: 200 }, 2857 animate: { 2858 enter: 'animated lightSpeedIn', 2859 exit: 'animated lightSpeedOut' 2860 } 2861 }); 2862 } else { 2863 $.notify({ 2864 from: "bottom", 2865 title: "<strong></strong> ", 2866 icon: 'glyphicon glyphicon-gift', 2867 message: ' <b>Please enter Gift Certificate Number...!</b>' 2868 }, { 2869 timer: 1000, 2870 type: 'danger', 2871 offset: { x: 50, y: 200 }, 2872 animate: { 2873 enter: 'animated lightSpeedIn', 2874 exit: 'animated lightSpeedOut' 2875 } 2876 }); 2877 } 2878 gc_apply_click++; 2879 $('#gc_apply').attr("disabled",false).html("Apply"); 2880 } 2881 else 2882 { 2883 2884 var gc_data = { 'gc_serial_number': gc_serial_number, 'total': parseFloat($("#amountPayable_ship").attr("data-amount")) }; 2885 2886 // if($("#UserCaptcha").is(":visible") && $("#UserCaptcha").val()!='') 2887 // { 2888 // var gc_data = { 'gc_serial_number': gc_serial_number, 'total': $("#amountPayable_ship").attr("data-amount"), 'gc_captcha':$("#UserCaptcha").val() }; 2889 // } 2890 $.ajax({ 2891 url: BASE_PATH + "/api/getGiftserialBalance", 2892 type: "post", 2893 async: false, 2894 data: gc_data, 2895 success: function(result) { 2896 setTimeout(function(){ $('#gc_apply').attr("disabled",fal
2896se).html("Apply"); },1200); 2897 if($(".creload").is(":visible")) 2898 { 2899 $(".creload:visible").trigger("click"); 2900 $("#UserCaptcha").val(""); 2901 } 2902 var obj = jQuery.parseJSON(result); 2903 2904 if (obj.status == 0) 2905 { 2906 $(".gc_error").html(obj.message); 2907 gc_apply_click++; 2908 paybtn(); 2909 } 2910 else if(obj.status==1) 2911 { 2912 if($(".pay_late_amt_due").length > 0){ 2913 $(".pay_late_amt_due").css('display','none'); 2914 } 2915 if($(".gc_discount_amt_due").length >0){ 2916 $(".gc_discount_amt_due").css('display','none'); 2917 } 2918 var str_html = ''; 2919 str_html += "<div class='panel panel-default'>"; 2920 str_html += "<div class='panel-heading'>"; 2921 str_html += "<div class='row gc_disc' id='gc_discount' data-amount='"+obj.total_gc_price+"'>"; 2922 str_html += "<div class='col-lg-10 RM_PLR15'>"; 2923 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 2924 str_html += "<strong>"+GIFT_CERTIFICATE_TEXT+"</strong>"; 2925 } else { 2926 str_html += "<strong>Gift Certificate</strong>"; 2927 } 2928 str_html += "</div>"; 2929 str_html += "<div class='col-lg-2 RM_PLR15' style='text-align:right'>"; 2930 str_html += obj.total_gc_price_label; 2931 str_html += "</div></div>"; 2932 str_html += "<div class='row gc_discount_amt_due' id='gc_discount' data-amount='"+obj.total_gc_price+"'>"; 2933 str_html += "<div class='col-lg-10 RM_PLR15'>"; 2934 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 2935 str_html += "<strong>"+AMOUNT_DUE_TEXT+"</strong>"; 2936 } else { 2937 str_html += "<strong>Amount Due</strong>"; 2938 } 2939 str_html += "</div>"; 2940 str_html += "<div class='col-lg-2 RM_PLR15 amt_due' style='text-align:right'>"; 2941 str_html += obj.total_label; 2942 str_html += "</div></div>"; 2943 str_html += "</div>"; 2944 str_html += "</div>"; 2945 //console.log('pay_late length',$(".pay_late_lable").length); 2946 //console.log('gift card length',$("#gc_discount").length); 2947 //console.log('gc_disc',$(".gc_disc").length); 2948 if($(".pay_late_lable").length >0 && $(".gc_disc").length >0){ 2949 $(".gc_disc").parent().remove(); 2950 //console.log("gift card exist"); 2951 } 2952 else if($(".pay_late_lable").length >0){ 2953 //console.log("pay later exist"); 2954 } 2955 else if($("#gc_discount").length>0) 2956 { 2957 console.log("pay later not exist and gift card exist"); 2958 $("#gc_discount").parent().parent().remove(); 2959 } 2960 if(parseFloat(obj.total)==0 && paypal_flag==1){ 2961 if(old_act_url=="paypal_auth"){ 2962 $("#PaypalCreditCardAuthForm").attr("action", "/checkout/direct_pay"); 2963 } 2964 act_url = 'direct_pay'; 2965 if(paypal_flag==1){ 2966 $("#btnSubmitPay").show(); 2967 } 2968 } 2969 $("#amountPayable_ship").attr("data-amount",obj.total); 2970 $(".costSummary").append(str_html); 2971 var str = "<tr class='tx_gc "+gc_serial_number+"'><td>"+gc_serial_number+" <a href='javascript:void(0);' class='remove_gc' data-gc='"+gc_serial_number+"'>Remove</a></td><td>"+obj.gc_price_applied_label+"</td></tr>"; 2972 $(".gc_serial_number_list").removeClass("hide").append(str); 2973 $("#gc_serial_number").val(''); 2974 $(".gc_error").html(obj.message); //.fadeIn(); 2975 2976 if(obj.total==0) 2977 { 2978 $("#gc_serial_number").attr('readonly',true); 2979 $("#gc_apply").attr('disabled',true); 2980 2981 $("#card_pay").hide(); 2982 $('#credit').css('display','none'); 2983 $('#credit').prop('checked', false); 2984 $('#credit').next('.pay_m').css('display','none'); 2985 $('#credit-handkey-exist').css('display','none'); 2986 $('.pay_m_type').css('display','none'); 2987 $('#save_vault').hide(); 2988 $('#pay_by').attr("disabled",true); 2989 paybtn(); 2990 }else{ 2991 $("#gc_serial_number").focus(); 2992 var emsg = "<p>"+INSUFFICIENT_GIFT_BALANCE_TEXT+"</p>"; 2993 var eclass = "gc_error"; 2994 paybtn(eclass,emsg); 2995 } 2996 gc_apply_click = 0; 2997 2998 } 2999 } 3000 }); 3001 } 3002}); 3003$(document).on('click', '#pay_by ', function() { 3004 $('#btnSubmitPay').attr("disabled", false); 3005 if($("#button_state").val()==0){ 3006 $('#btnSubmitPay').attr("disabled", true); 3007 } 3008 3009 var action = $(this).attr("data-action"); 3010 if(action=="gc") 3011 { 3012 $('#worldpay_redirect_txt').css('display','none'); 3013 if(paypal_flag==1){ 3014 $(this).attr("data-action",'cc').html('<i class="fa fa-credit-card"></i> '+PAY_BY_PAYPAL_TEXT); 3015 }else{ 3016 $(this).attr("data-action",'cc').html('<i class="fa fa-credit-card"></i> '+PAY_BY_CREDIT_CARD_TEXT); 3017 } 3018 $("#gc_pay").removeClass("hide"); 3019 $("#card_pay").addClass("hide"); 3020 $(".pay_m").html('Gift Certificate'); 3021 paybtn(); 3022 3023 $(".gc_error").html(""); 3024 $("#gc_serial_number").parent().parent().parent().removeClass("hide"); 3025 $(".gc_captcha").addClass("hide"); 3026 $("#gc_serial_number").focus(); 3027 gc_apply_click = 0; 3028 if($(".gc_serial_number_list").find('tr').length>1) 3029 { 3030 $(".gc_serial_number_list").removeClass("hide"); 3031 } 3032 if(parseFloat($("#amountPayable_ship").attr("data-amount"))>0 && $(".gc_serial_number_list").find('tr').length>1) 3033 { 3034 var err_msg = "<p>"+INSUFFICIENT_GIFT_BALANCE_TEXT+"</p>"; 3035 $(".gc_error").html(err_msg); 3036 } 3037 3038 } 3039 else 3040 { $('#worldpay_redirect_txt').css('display','block'); 3041 $(this).attr("data-action",'gc').html('<i class="fa fa-gift"></i> '+PAY_BY_GIFT_CERTIFICATE_TEXT); 3042 $("#gc_pay").addClass("hide"); 3043 $("#card_pay").removeClass("hide"); 3044 if(paypal_flag==1){ 3045 $(".pay_m").html('Paypal'); 3046 $("#paypal-button-container").html(""); 3047 initPayPalButton(); 3048 }else{ 3049 $(".pay_m").html('Credit Card'); 3050 } 3051 3052 $('#btnSubmitPay').attr("disabled", false); 3053 if($("#button_state").val()==0){ 3054 $('#btnSubmitPay').attr("disabled", true); 3055 } 3056 3057 } 3058}); 3059 3060function paybtn(eclass='',emsg='') 3061{ 3062 if($("#CreditCardCardNumber").length>0){ 3063 var cccn = $("#CreditCardCardNumber").val(); 3064 }else 3065 { 3066 var cccn = $("#CreditCardCardNumber").val(); 3067 } 3068 var cccv = $("#CreditCardCvv").val(); 3069 var cce = $("#CreditCardExpiry").val(); 3070 var ccn = $("#CreditCardName").val(); 3071 var amountPayable_ship = parseFloat($("#amountPayable_ship").attr("data-amount")); 3072 if( (cccn=='' || cccv=='' || cce=='' || ccn=='' || $("#WorldPayCreditCardAuthForm").length) && amountPayable_ship>0 ) 3073 { 3074 $('#btnSubmitPay').attr("disabled", true); 3075 } 3076 else 3077 { 3078 $('#btnSubmitPay').attr("disabled", false); 3079 } 3080 if(emsg!='') 3081 { 3082 $('#btnSubmitPay').attr("disabled", true); 3083 $("."+eclass).append(emsg); 3084 } 3085 3086 $('#btnSubmitPay').attr("disabled", false); 3087 3088} 3089$(document).on('click', '.return_to_cart', function(){ 3090 window.location = BASE_PATH+"/cart"; 3091 return false;
3092}); 3093 3094 3095 3096 3097if (CONTROLL == "checkout") { 3098 jQuery(document).ready(function($) 3099 { 3100 if("#back" == location.hash){ 3101 window.location = BASE_PATH+"/cart"; 3102 return false; 3103 } 3104 if (window.history && window.history.pushState) 3105 { 3106 $(window).on('popstate', function() { 3107 var hashLocation = location.hash; 3108 if(hashLocation!='') 3109 { 3110 var hashSplit = hashLocation.split("#!/"); 3111 var hashName = hashSplit[1]; 3112 if (hashName !== '') { 3113 var hash = window.location.hash; 3114 if (hash === '') { 3115 //alert('Back button was pressed.'); 3116 //window.location = 'www.example.com'; 3117 return false; 3118 } 3119 } 3120 } 3121 }); 3122 window.history.pushState('forward', null, '#back'); 3123 } 3124 }); 3125} 3126 3127if (CONTROLL == "checkout" && ACTION == "payment" ) 3128{ 3129 var tx = 0; 3130 $(window.parent.window).on('popstate', function () { 3131 tx++; 3132 if(tx%2==1 && tx>3 ) 3133 { 3134 window.location = BASE_PATH+"/cart"; 3135 return false; 3136 } 3137 else if(tx%2==0 && tx>4 ) 3138 { 3139 window.location = BASE_PATH+"/cart"; 3140 return false; 3141 } 3142 3143 }); 3144} 3145 3146 3147 $(document).on('change', '#CustomerInfoCountry, #CreditCardCountry', function () { 3148 if($(this).val()!="US" && $(this).val()!="CA" && $(this).val()!="AU") 3149 { 3150 $(".dive_states").addClass("hide"); 3151 $(".dive_states1").removeClass("hide"); 3152 }else{ 3153 $(".dive_states").removeClass("hide"); 3154 if($(".dive_states1").val()==''){ 3155 $(".dive_states1").val($("#target option:first").val()); 3156 } 3157 $(".dive_states1").addClass("hide"); 3158 } 3159 }); 3160 3161 3162$(document).on('click', '#pay_later_apply', function() { 3163 // $('#pay_later_apply').attr("disabled",true).html("<img src='"+BASE_PATH +"/img/loading1.gif'>"); 3164 3165 // $('#btnSubmitPay').attr("disabled", false); 3166 var pay_later_amt = $.trim($("#pay_later_amt").val()); 3167 if(pay_later_amt=='' || pay_later_amt == 0) 3168 { 3169 $(".pl_error").html(PAY_LATER_AMOUNT_SHOULD_NOT_BE_EMPTY_TEXT); 3170 } 3171 else if(parseFloat($("#pay_later_amt").val()) >= parseFloat($("#amountPayable_ship").attr("data-amount"))){ 3172 $(".pl_error").html(PAY_LATER_AMOUNT_SHOULD_BE_LESS_THAN_THE_AMOUNT_DUE_TEXT); 3173 } 3174 else 3175 { 3176 $.ajax({ 3177 url: BASE_PATH + "/site/check_paylater_limit", 3178 type: "post", 3179 async: false, 3180 data: { 3181 total: parseFloat($("#pay_later_amt").val()), 3182 payable_total: parseFloat($("#amountPayable_ship").attr("data-amount")), 3183 is_partial:1 3184 }, 3185 success: function(result) { 3186 3187 // if($(".creload").is(":visible")) 3188 // { 3189 // $(".creload:visible").trigger("click"); 3190 // $("#UserCaptcha").val(""); 3191 // } 3192 3193 var obj = jQuery.parseJSON(result); 3194 obj.pay_later = 3195 $(".pl_error").html(''); 3196 if($(".gc_discount_amt_due").length >0){ 3197 $(".gc_discount_amt_due").css('display','none'); 3198 } 3199 var str_html = ''; 3200 var payable_total=''; 3201 str_html += "<div class='panel panel-default'>"; 3202 str_html += "<div class='panel-heading'>"; 3203 str_html += "<div class='row pay_rm pay_late_lable' id='gc_discount' data-amount='"+obj.pay_later+"'>"; 3204 str_html += "<div class='col-lg-10 RM_PLR15'>"; 3205 str_html += "<strong>"+PAY_LATER_TEXT+"</strong>"; 3206 str_html += "</div>"; 3207 str_html += "<div class='col-lg-2 RM_PLR15' style='text-align:right'>"; 3208 str_html += "-"+obj.pay_later_lable; 3209 str_html += "</div></div>"; 3210 str_html += "<div class='row pay_late_amt_due pay_rm gc_discount_amt_due' id='gc_discount' data-amount='"+obj.pay_later_total+"'>"; 3211 str_html += "<div class='col-lg-10 RM_PLR15'>"; 3212 if($("#multi_language_support").length>0 && $("#multi_language_support").val() == 1){ 3213 str_html += "<strong>"+AMOUNT_DUE_TEXT+"</strong>"; 3214 } else { 3215 str_html += "<strong>Amount Due</strong>"; 3216 } 3217 str_html += "</div>"; 3218 str_html += "<div class='col-lg-2 RM_PLR15 amt_due' id='pay_late_amt_disp' style='text-align:right'>"; 3219 str_html += obj.pay_later_total_lable; 3220 str_html += "</div></div>"; 3221 str_html += "</div>"; 3222 str_html += "</div>"; 3223 3224 3225 $("#amountPayable_ship").attr("data-amount",obj.pay_later_total); 3226 $(".costSummary").append(str_html); 3227 var str = "<tr class='pay_late_error'><td> <a href='javascript:void(0);' class='remove_pay_later' data-gc='pay_late_rm'>"+REMOVE_TEXT+"</a></td><td>"+obj.pay_later_lable+"</td></tr>"; 3228 $(".pay_late_list").removeClass("hide").append(str); 3229 $("#pay_later_amt").addClass("hide"); 3230 $("#pay_later_apply").addClass("hide"); 3231 $("#pay_later").attr("disabled",true); 3232 $("#pat_typ_full").attr("disabled",true); 3233 $("input:checked + .slider").css("background-color","grey"); 3234 } 3235 }); 3236 } 3237}); 3238$(document).on('click', '.remove_pay_later ', function() { 3239// $('.remove_pay_later,#pat_typ_full,#pay_later').click(function() { 3240 $("#gc_serial_number").attr('readonly',false);
3241 $('#pay_by').attr("disabled",false); 3242 3243 $(".pay_late_error").html(""); 3244 var pay_late_rm = $(this).attr('data-gc'); 3245 $("tr." +pay_late_rm).remove(); 3246 $(".pay_late_list").addClass("hide"); 3247 $(".pay_late_lable").remove(); 3248 $("#pay_later_amt").removeClass("hide"); 3249 $("#pay_later_apply").removeClass("hide"); 3250 $('#credit-handkey').attr("disabled",false); 3251 $('#credit-handkey-exist').attr("disabled",false); 3252 console.log('pay_later',parseFloat($("#pay_later_amt").val())); 3253 console.log('amountPayable_ship',parseFloat($("#amountPayable_ship").attr("data-amount"))); 3254 var amountPayable_ship_rm = parseFloat($("#amountPayable_ship").attr("data-amount"))+parseFloat($("#pay_later_amt").val()); 3255 console.log('amountPayable_ship_rm',amountPayable_ship_rm); 3256 $("#amountPayable_ship").attr("data-amount",amountPayable_ship_rm); 3257 $(".pay_late_amt_due").attr("data-amount",amountPayable_ship_rm); 3258 $.ajax({ 3259 url: BASE_PATH + "/site/set_currency_symb", 3260 type: "post", 3261 async: false, 3262 data: { 3263 total: amountPayable_ship_rm, 3264 }, 3265 success: function(result) { 3266 var obj = jQuery.parseJSON(result);console.log(obj); 3267 if (obj.status == 1) 3268 { 3269 $("#pay_late_amt_disp").html(obj.total); 3270 $(".amt_due").html(obj.total); 3271 } 3272 } 3273 }); 3274 3275 $("#pay_later").attr("disabled",false); 3276 $("#pat_typ_full").attr("disabled",false); 3277 $("input:checked + .slider").css("background-color","#2AB934"); 3278 $("#pay_later_amt").val(''); 3279 if(parseFloat($("#amountPayable_ship").attr("data-amount"))>0){ 3280 $("#card_pay").show(); 3281 $('#credit').css('display','inline'); 3282 $('#credit').prop('checked', true); 3283 $('#credit').next('.pay_m').css('display','inline'); 3284 $('#credit-handkey-exist').css('display','inline'); 3285 $('.pay_m_type').css('display','inline'); 3286 $('#save_vault').show(); 3287 $("#exist_card_pay").hide(); 3288 $('#credit-handkey-exist').show(); 3289 $('#credit-handkey-exist').next("span").show(); 3290 $('#credit-handkey').show(); 3291 $('#credit-handkey').next("span").show(); 3292 } 3293}); 3294 3295// ============================================================ 3296// Package cert sub-item student assignment (package_with_padi_not_prompting_for_student_info) 3297// ============================================================ 3298 function ensureModal() { 3299 if ($('#pkg-cert-student-modal').length) return; 3300 $('body').append( 3301 '<div id="pkg-cert-student-modal" style="display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:9999;">' + 3302 ' <div style="background:#fff;width:380px;margin:80px auto;padding:24px;border-radius:6px;">' + 3303 ' <h4 id="pkg-cert-modal-title" style="margin:0 0 16px;">Assign Student</h4>' + 3304 ' <input type="hidden" id="pkg-cert-modal-uuid" />' + 3305 ' <input type="hidden" id="pkg-cert-modal-partnum" />' + 3306 ' <label style="display:block;margin-bottom:4px;">First Name *</label>' + 3307 ' <input type="text" id="pkg-cert-fname" style="width:100%;margin-bottom:10px;padding:6px;box-sizing:border-box;" />' + 3308 ' <label style="display:block;margin-bottom:4px;">Last Name *</label>' + 3309 ' <input type="text" id="pkg-cert-lname" style="width:100%;margin-bottom:10px;padding:6px;box-sizing:border-box;" />' + 3310 ' <label style="display:block;margin-bottom:4px;">Email</label>' + 3311 ' <input type="email" id="pkg-cert-email" style="width:100%;margin-bottom:10px;padding:6px;box-sizing:border-box;" />' + 3312 ' <label style="display:block;margin-bottom:4px;">Date of Birth (YYYY-MM-DD)</label>' + 3313 ' <input type="text" id="pkg-cert-dob" placeholder="YYYY-MM-DD" style="width:100%;margin-bottom:16px;padding:6px;box-sizing:border-box;" />' + 3314 ' <button type="button" id="pkg-cert-save-btn" style="background:#27ae60;color:#fff;border:none;padding:8px 20px;border-radius:4px;cursor:pointer;font-size:14px;">
3314Save Student</button>' + 3315 ' <button type="button" id="pkg-cert-cancel-btn" style="background:#aaa;color:#fff;border:none;padding:8px 16px;border-radius:4px;cursor:pointer;font-size:14px;margin-left:8px;">Cancel</button>' + 3316 ' <div id="pkg-cert-modal-error" style="color:red;margin-top:8px;display:none;"></div>' + 3317 ' </div>' + 3318 '</div>' 3319 ); 3320 $('#pkg-cert-cancel-btn').on('click', function () { $('#pkg-cert-student-modal').hide(); }); 3321 $('#pkg-cert-save-btn').on('click', function () { 3322 var uuid = $('#pkg-cert-modal-uuid').val(); 3323 var partnum = $('#pkg-cert-modal-partnum').val(); 3324 var fname = $.trim($('#pkg-cert-fname').val()); 3325 var lname = $.trim($('#pkg-cert-lname').val()); 3326 var email = $.trim($('#pkg-cert-email').val()); 3327 var dob = $.trim($('#pkg-cert-dob').val()); 3328 if (!fname || !lname) { 3329 $('#pkg-cert-modal-error').text('First name and last name are required.').show(); 3330 return; 3331 } 3332 $('#pkg-cert-modal-error').hide(); 3333 $('#pkg-cert-save-btn').prop('disabled', true).text('Saving...'); 3334 $.ajax({ 3335 type: 'POST', 3336 url: BASE_PATH + 'ajax/save_pkg_cert_student', 3337 data: { pkg_sub_part_uuid: uuid, fname: fname, lname: lname, email: email, dob: dob, part_number: partnum }, 3338 success: function (res) { 3339 var r = (typeof res === 'string') ? JSON.parse(res) : res; 3340 if (r.status == '1') { 3341 var btn = $('.btn-pkg-cert-assign[data-uuid="' + uuid + '"]'); 3342 btn.css('background', '#27ae60').text('Change Student (' + fname + ' ' + lname + ')').data('assigned', '1').attr('data-assigned', '1'); 3343 $('#pkg-cert-student-modal').hide(); 3344 checkPkgCertCheckoutGate(); 3345 } else { 3346 $('#pkg-cert-modal-error').text(r.msg || 'Error saving student.').show(); 3347 } 3348 $('#pkg-cert-save-btn').prop('disabled', false).text('Save Student'); 3349 }, 3350 error: function () { 3351 $('#pkg-cert-modal-error').text('Server error. Please try again.').show(); 3352 $('#pkg-cert-save-btn').prop('disabled', false).text('Save Student'); 3353 } 3354 }); 3355 }); 3356 } 3357 3358 $(document).on('click', '.btn-pkg-cert-assign', function () { 3359 ensureModal(); 3360 var uuid = $(this).data('uuid'); 3361 var partnum = $(this).data('partnum'); 3362 var title = $(this).data('title') || ''; 3363 var assigned = $(this).data('assigned'); 3364 $('#pkg-cert-modal-uuid').val(uuid); 3365 $('#pkg-cert-modal-partnum').val(partnum); 3366 $('#pkg-cert-modal-title').text((assigned == '1' ? 'Change' : 'Assign') + ' Student for: ' + title); 3367 $('#pkg-cert-fname,#pkg-cert-lname,#pkg-cert-email,#pkg-cert-dob').val(''); 3368 $('#pkg-cert-modal-error').hide(); 3369 $('#pkg-cert-student-modal').show(); 3370 }); 3371 3372 function checkPkgCertCheckoutGate() { 3373 if ($('.pkg-cert-students').length === 0) return; 3374 var allAssigned = true; 3375 $('.btn-pkg-cert-assign').each(function () { 3376 if ($(this).attr('data-assigned') != '1') { allAssigned = false; } 3377 }); 3378 if (!allAssigned) { 3379 if ($('#pkg-cert-checkout-warning').length === 0) { 3380 $('.pkg-cert-students').first().before('<div id="pkg-cert-checkout-warning" style="background:#fff3cd;border:1px solid #ffc107;padding:8px 12px;margin-bottom:8px;border-radius:4px;font-size:13px;"><strong>Action required:</strong> Please assign a student to all certification items in your package before checking out.</div>'); 3381 } 3382 } else { 3383 $('#pkg-cert-checkout-warning').remove(); 3384 } 3385 } 3386 3387 3388 3389 $(document).ready(function () { 3390 if($("#package_with_padi_not_prompting_for_student_info").length>0 && $("#package_with_padi_not_prompting_for_student_info").val() == 1){ 3391 checkPkgCertCheckoutGate(); 3392 } 3393 }); 3394
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.