1'use strict' 2let OPT_BILLING_ADDRESS = 0; 3let cart_l = 0; 4 5 6let Cart = (function() { 7 let cookieName; 8 let read_cart = (cart_cookie)?JSON.parse(cart_cookie):{}; 9 let cookie_act = ''; 10 function Cart(cookieName = 'dssf_cart') { 11 this.cookieName = 'dssf_cart'; 12 this.readCookie = function() { 13 return read_cart; 14 //return Cookies.getJSON(cookieName); 15 } 16 } 17 18 function _switchCartButtons(status) { 19 status = Number(status); 20 var html = "<button class='btn btn-warning btn-buy-cart'><i class='fa fa-fw fa-shopping-cart'></i> GO TO CART</button>"; 21 if (status === 1) { 22 html = "<button class='btn btn-info disabled'><i class='fa fa-fw fa-shopping-cart'></i> ADDING TO CART</button>"; 23 } 24 $(".cart-btn-container").html(html); 25 } 26 27 Cart.prototype.showAlert = function(msg, type) { 28 $(".alert-" + type).html(msg).show(); 29 setTimeout(function() { 30 $(".alert-" + type).hide(); 31 }, 10000); 32 } 33 34 Cart.prototype.addPart = function(part) { 35 let cart = this.readCookie(); 36 let products = {}; 37 if (cart!==null && cart !== '' && typeof cart !== 'undefined') 38 { 39 products = cart; 40 } 41 42 if (part.gc_unique_id) { 43 products[part.gc_unique_id] = part; 44 } else { 45 products[part.uuid] = part; 46 } 47 this.setCookie(products); 48 _switchCartButtons(3); 49 this.showAlert('Product added To Cart', 'info'); 50 51 if( $("#send_ga4_ecommerce_funnel_events_to_the_datalayer_not_just_purchase").val()==1){ 52 if (typeof ga4PushAddToCart === 'function') { 53 ga4PushAddToCart(products); 54 } 55 } 56 } 57 58 Cart.prototype.removePart = function(uuid) { 59 60 if($("#implement_redis_in_home_page").val()==1 ){ 61 if(window.cartValue != null) { 62 63 if ( Object.keys(window.cartValue).length != 0) { 64 var cart = (window.cartValue)?JSON.parse(window.cartValue):{}; 65 console.log('cart1',cart); 66 }else{ 67 var cart = this.readCookie(); 68 console.log('cart2',cart); 69 } 70 }else { 71 var cart = this.readCookie(); 72 } 73 }else { 74 var cart = this.readCookie(); 75 } 76 77 if (uuid in cart) { 78 79 for (let key in cart) { 80 if(cart[key].is_addon && cart[key].parent_uuid == uuid) 81 { 82 delete cart[cart[key].uuid]; 83 } 84 if( cart[key].free && cart[key].parent_uuid == uuid) 85 { 86 delete cart[cart[key].uuid]; 87 } 88 } 89 90 if($("#intrepid_courses_membership_enhancement_store_front").length>0 && $("#intrepid_courses_membership_enhancement_store_front").val()==1){ 91 92 const clickedItem = cart[uuid]; 93 if (clickedItem.part_type === "Course" && clickedItem.valid_membership_id) { 94 const membershipIdToRemove = parseInt(clickedItem.valid_membership_id); 95 96 for (const key in cart) { 97 const item = cart[key]; 98 if (item.part_type === "Membership" && item.id && parseInt(item.id) === membershipIdToRemove) { 99 100 for (let key in localStorage) { 101 if (key.startsWith(`waiver-${clickedItem.id}`)) { 102 localStorage.removeItem(key); 103 } 104 } 105 106 delete cart[item.uuid]; 107 break; // remove only one matching Membership 108 } 109 } 110 } else if (clickedItem.part_type === "Membership" && clickedItem.id) { 111 const membershipId = parseInt(clickedItem.id); 112 113 for (const key in cart) { 114 const item = cart[key]; 115 if ( 116 item.part_type === "Course" && 117 item.valid_membership_id && 118 parseInt(item.valid_membership_id) === membershipId 119 ) { 120 121 if (!confirm('Note: Deleting the membership item will delete the Course as well.')) { 122 return false;
123 } 124 125 for (let key in localStorage) { 126 if (key.startsWith(`waiver-${item.id}`)) { 127 localStorage.removeItem(key); 128 } 129 } 130 delete cart[item.uuid]; 131 } 132 } 133 } 134 } 135 136 delete cart[uuid]; 137 cookie_act = 'delete'; 138 this.setCookie(cart); 139 this.checkCart(); 140 return true; 141 } 142 143 144 return false; 145 } 146 147 148 Cart.prototype.removePartMembership = function(uuid) { 149 150 if($("#implement_redis_in_home_page").val()==1 ){ 151 if(window.cartValue != null) { 152 153 if ( Object.keys(window.cartValue).length != 0) { 154 var cart = (window.cartValue)?JSON.parse(window.cartValue):{}; 155 console.log('cart1',cart); 156 }else{ 157 var cart = this.readCookie(); 158 console.log('cart2',cart); 159 } 160 }else { 161 var cart = this.readCookie(); 162 } 163 }else { 164 var cart = this.readCookie(); 165 } 166 167 if (uuid in cart) { 168 169 for (let key in cart) { 170 if(cart[key].is_addon && cart[key].parent_uuid == uuid) 171 { 172 delete cart[cart[key].uuid]; 173 } 174 if( cart[key].free && cart[key].parent_uuid == uuid) 175 { 176 delete cart[cart[key].uuid]; 177 } 178 } 179 180 delete cart[uuid]; 181 cookie_act = 'delete'; 182 this.setCookie(cart); 183 this.checkCart(); 184 return true; 185 } 186 187 188 return false; 189 } 190 191 Cart.prototype.updatePart = function(part) { 192 let uuid = part.uuid; 193 let cart = this.readCookie(); 194 if (part.part_type == "GiftCertificate") { 195 uuid = part.gc_unique_id; 196 } 197 198 199 if (uuid in cart) { 200 cart[uuid] = part; 201 } 202 this.setCookie(cart); 203 } 204 205 Cart.prototype.isUUIDExists = function(uuid) { 206 let cart = this.readCookie(); 207 if (uuid in cart) { 208 return true; 209 } 210 return false; 211 } 212 213 Cart.prototype.checkCart = function() { 214 if (this.cartCount() === 0) { 215 $(".con-cart").html('<h3 class="text-center text-banner text-muted">Cart is Empty!</h3>'); 216 } 217 } 218 219 Cart.prototype.cartCount = function() { 220 let cart = this.readCookie(); 221 return cart ? Object.keys(cart).length : 0; 222 } 223 224 Cart.prototype.cartTotal = function() { 225 let cart = this.readCookie(); 226 if (typeof cart !== 'undefined') { 227 let subTotal = 0.0; 228 let ship_cost = 0; 229 for (let key in cart) { 230 let prod = cart[key]; 231 subTotal += Number(prod.price) * Number(prod.count); 232 } 233 subTotal = subTotal.toFixed(2); 234 subTotal = formatMoney(subTotal); 235 $("#amountPayable").html(subTotal); 236 } else { 237 $("#amountPayable").html($("#currency_symbol").val()+'0.00'); 238 } 239 } 240 241 Cart.prototype.assignTotal = function() { 242 this.cartTotal(); 243 //$("#amountPayable").html(this.cartTotal()); 244 } 245 246 Cart.prototype.assignCount = function() { 247 $(".cart-count").html(this.cartCount()); 248 } 249 250 Cart.prototype.setCookie = function(value) { 251 var OP4907 = $("#update_quantity_amount_cart_page").val(); 252 var data = JSON.stringify(value); 253 this.clearCookie(); 254 // Cookies.set(this.cookieName, data, { 255 // expires: 7 256 // }, { 257 // domain: DOMAIN_NAME 258 // }); 259 // cart_l++; 260 if(OP4907 === '1') { 261 $.ajax({ 262 url: BASE_PATH + '/site/cart_cookie', 263 type: "post", 264 data: { 265 'name': this.cookieName, 266 'arg': data,
267 'cookie_act' : cookie_act 268 }, 269 beforeSend: function(){ 270 $("#modal-loading").modal('show'); 271 }, 272 success: function (data) { 273 if(data==true){ 274 cart_l++; 275 let read_cart= cart.readCookie(); 276 var last = 0; 277 for (let key in read_cart) { 278 if($('#last_'+read_cart[key]['uuid']).length > 0){ 279 if(read_cart[key].free){ 280 last = $('#last_'+read_cart[key]['uuid']).val(); 281 if(last!=0){ 282 window.location.reload(); 283 } 284 } 285 if(read_cart[key].bogo){ 286 last = $('#last_'+read_cart[key]['uuid']).val(); 287 if(last!=0){ 288 window.location.reload(); 289 } 290 } 291 } 292 293 } 294 if(($('#loadscheck').length>0) && $('#loadscheck').val()==1){ 295 window.location.reload(); 296 } 297 } 298 $("#modal-loading").modal('hide'); 299 } 300 }); 301 } 302 else{ 303 $.ajax({ 304 url: BASE_PATH + '/site/cart_cookie', 305 type: "post", 306 data: { 307 'name': this.cookieName, 308 'arg': data, 309 'cookie_act' : cookie_act 310 }, 311 success: function (data) { 312 if(data==true){ 313 cart_l++; 314 315 let read_cart= cart.readCookie(); 316 var last = 0; 317 for (let key in read_cart) { 318 if($('#last_'+read_cart[key]['uuid']).length > 0){ 319 if(read_cart[key].free){ 320 last = $('#last_'+read_cart[key]['uuid']).val(); 321 if(last!=0){ 322 window.location.reload(); 323 } 324 } 325 if(read_cart[key].bogo){ 326 last = $('#last_'+read_cart[key]['uuid']).val(); 327 328 if(last!=0){ 329 window.location.reload(); 330 } 331 } 332 } 333 334 } 335 if(($('#loadscheck').length>0) && $('#loadscheck').val()==1){ 336 window.location.reload(); 337 } 338 339 } 340 } 341 }); 342 } 343 this.assignTotal(); 344 this.assignCount(); 345 } 346 Cart.prototype.clearCookie = function() { 347 Cookies.set(this.cookieName, '', { 348 expires: -1 349 }, { 350 domain: DOMAIN_NAME 351 }); 352 this.assignTotal(); 353 this.assignCount(); 354 } 355 return Cart; 356})(); 357 358let XHR = (function() { 359 let params, type, async, method, baseUrl; 360 361 function XHR(baseUrl) { 362 this.baseUrl = baseUrl; 363 } 364 365 let _toParam = (ary) => { 366 if (!(ary instanceof Array)) { 367 console.warn('Exception: Not an array'); 368 return false; 369 } 370 var str = ''; 371 for (var len = ary.length, i = 0; i < len; i++) { 372 373 str += ary[i].join('='); 374 str += (i === len - 1) ? '' : '&'; 375 } 376 return str; 377 } 378 379 XHR.prototype.call = function(method, params = {}, type = 'GET', async = true) { 380 this.method = method; 381 this.params = Object.keys(params).map((i) => { 382 return [i, params[i]] 383 }); 384 this.type = type; 385 this.async = async; 386 387 return new Promise((resolve, reject) => { 388 let url = this.baseUrl + method; 389 let xhr = new XMLHttpRequest(); 390 391 392 xhr.open(this.type, url, this.async); 393 xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 394 xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); 395 xhr.send(_toParam(this.params)); 396 xhr.onload = () => { 397 if (xhr.status >= 200 && xhr.status < 400) { 398 resolve(JSON.parse(xhr.response)); 399 } else { 400 reject(new Error(`${xhr.status} - Error Fetching Data form Server`)); 401 } 402 }; 403 xhr.onerror = () => { 404 reject(new Error(`${xhr.status} - Error Fetching Data form Server`)); 405 }; 406 }); 407 } 408 409 return XHR; 410})(); 411 412let cart = new Cart(); 413let xhr = new XHR(BASE_PATH + '/api/'); 414 415function init_cart() { 416 cart.assignTotal(); 417 cart.assignCount(); 418} 419window.onload = function() { 420 init_cart(); 421} 422 423 424function addToCart(handle, count, cInv, part_type='', is_firearm='', part_id="", offer_type='',free_qty='',eligible_qty='',free_qty_count='',discount_type='',discount_value='', stock='', boffer_id='') { 425 426 if(add_orchid_eState_api_to_site==1 && is_firearm == 1 ){ 427 428 $('.mfp-fade').css('display','none'); 429 $('#zipcode_modal').modal({backdrop: 'static', keyboard: false}); 430 $('#part_id_upc').val(part_id); 431 if(zip!=''){ 432 $('#zip_code').val(zip); 433 //$('#zip_code').prop('readonly', true); 434 //$('#save_zip').css('display','none'); 435 zipupc_save(part_id,zip); 436 } 437 else{ 438 zipupc_save(part_id); 439 } 440 } 441 442 var feature_tag =$("#manage_vault_save_credit_card").val(); 443 var check_auto_addcart =$("#set_cart_auto").val(); 444 if(feature_tag==="1" && check_auto_addcart==="1"){ 445 var isValid = true; 446 }else{ 447 var e = document.getElementById("numProductQty"); 448 var isValid = (!cInv) ? true : e.validity.valid; 449 } 450 451 452//console.log("ggg"+e.validity.valid); 453 if (handle && isValid) { 454 455 let params = {handle: handle,part_type:( (part_type=="")?'product':part_type) }; 456 if(check_auto_addcart == "1"){ 457 if( eligible_qty>0){ 458 params = {handle: handle,part_type:( (part_type=="")?'product':part_type), boffer_id:boffer_id,auto_addcart:1 }; 459 } 460 else{ 461 params = {handle: handle,part_type:( (part_type=="")?'product':part_type),auto_addcart:1 }; 462 } 463 } 464 else{ 465 if( eligible_qty>0){ 466 params = {handle: handle,part_type:( (part_type=="")?'product':part_type), boffer_id:boffer_id }; 467 } 468 } 469 xhr.call('getPartDetails', params, 'POST') 470 .then(function(data) { 471 if (data.status) { 472 $.notify({ 473 from: "bottom", 474 title: "<strong></strong> ", 475 icon: 'glyphicon glyphicon-shopping-cart', 476 message: "Added to your cart successfully...!" 477 }, { 478 timer: 1000, 479 type: 'success', 480 animate: { 481 enter: 'animated lightSpeedIn', 482 exit: 'animated lightSpeedOut' 483 } 484 }); 485 data.data.count = count; 486 cart.addPart(data.data); 487 488 489 if(parseInt(count) >= parseInt(eligible_qty)){ 490 if(offer_type!=1 ){ 491 var cd = (count/eligible_qty); 492 var dd = (Math.floor(cd)*free_qty); 493 } 494 if(offer_type==1){ 495 var cd = (count/eligible_qty); 496 var dd = (Math.floor(cd)); 497 } 498 let params = { 499 freecount: dd, 500 free_qty_count:free_qty_count, 501 offer_type:offer_type, 502 boffer_id:boffer_id, 503 handle: handle, 504 count: count, 505 product_type: part_type.toLowerCase() 506 }; 507 508 xhr.call('checkStock', params, 'POST') 509 .then(function(data) { 510 if (data.status) { 511 if(offer_type==1) { 512 513 if( data.data.available || data.data.stock >= (parseInt(count))){ 514 var cd = (count/eligible_qty); 515 var dd = (Math.floor(cd)); 516 if(parseInt(dd)>0){ 517 518 var k=1; 519 var msg = "Discount added to your cart successfully...!"; 520 521 if( discount_type==1){ 522 discount_value = parseInt(discount_value)/100; 523 } 524 for(var i=1; i<=parseInt(dd);i++){ 525 var r = (Math.random() + 1).toString(36).substring(7); 526 $('#modal
526-loading').modal('show'); 527 // data.data.uuid = 528 529 let params = {handle: handle,part_type:'product',bogo_buy:eligible_qty,bogo_get:free_qty,bogo_free:dd,bogo_discount_type:discount_type,bogo_discount_value:discount_value,bogo_free_count: free_qty_count,count:count,free_qty_count: free_qty_count,offer_type:offer_type,freecount:dd}; 530 531 xhr.call('getPartDetails', params, 'POST') 532 .then(function(data) { 533 if (data.status) { 534 535 $('#modal-loading').modal('show'); 536 data.data.uuid = data.data.uuid+'free'+r+k; 537 $('#last_'+data.data.uuid).val(0); 538 if(parseInt(dd)==k){ 539 $('#loadscheck').val(1); 540 } 541 542 cart.addPart(data.data); 543 k++; 544 } 545 }); 546 547 } 548 549 data.data.part['count'] = count; 550 data.data.part['uuid'] = data.data.part.uuid; 551 cart.updatePart(data.data.part); 552 $('#modal-loading').modal('hide'); 553 $.notify({ 554 from: "bottom", 555 title: "<strong></strong> ", 556 icon: 'glyphicon glyphicon-shopping-cart', 557 message: msg 558 }, { 559 timer: 1000, 560 type: 'success', 561 animate: { 562 enter: 'animated lightSpeedIn', 563 exit: 'animated lightSpeedOut' 564 } 565 }); 566 } 567 } 568 else{ 569 var cd = (count/eligible_qty); 570 var dd = (Math.floor(cd)); 571 if(discount_type==1 || discount_type==0){ 572 if(data.data.stock <= count) { 573 count = data.data.stock; 574 } 575 cd = (count/eligible_qty); 576 dd = Math.floor(cd); 577 var msg = "Discount added to your cart successfully...!"; 578 } 579 if( discount_type==1){ 580 discount_value = parseInt(discount_value)/100; 581 } 582 k=1; 583 for(var i=1; i<=parseInt(dd);i++){ 584 var r = (Math.random() + 1).toString(36).substring(7); 585 let params = {handle: handle,part_type:'product',bogo_buy:eligible_qty,bogo_get:free_qty,bogo_free:dd,bogo_discount_type:discount_type,bogo_discount_value:discount_value,bogo_free_count: free_qty_count}; 586 xhr.call('getPartDetails', params, 'POST') 587 .then(function(data) { 588 if (data.status) { 589 590 $('#modal
590-loading').modal('show'); 591 data.data.uuid = data.data.uuid+'free'+r+k; 592 $('#last_'+data.data.uuid).val(0); 593 if(parseInt(dd)==k){ 594 $('#loadscheck').val(1); 595 } 596 597 cart.addPart(data.data); 598 k++; 599 } 600 }); 601 } 602 $('#modal-loading').modal('hide'); 603 data.data.part['count'] = count; 604 data.data.part['uuid'] = data.data.part.uuid; 605 cart.updatePart(data.data.part); 606 $.notify({ 607 from: "bottom", 608 title: "<strong></strong> ", 609 icon: 'glyphicon glyphicon-shopping-cart', 610 message: msg 611 }, { 612 timer: 1000, 613 type: 'success', 614 animate: { 615 enter: 'animated lightSpeedIn', 616 exit: 'animated lightSpeedOut' 617 } 618 }); 619 } 620 621 } else{ 622 var cd = (count/eligible_qty); 623 var dd = (Math.floor(cd)*free_qty); 624 625 if((data.data.available || data.data.stock >=(parseInt(count)+parseInt(dd)))){ 626 var msg = dd + " Free item Added to your cart successfully...!"; 627 if(parseInt(dd)>0){ 628 var k=1; 629 for(var i=1; i<=parseInt(dd);i++){ 630 var r = (Math.random() + 1).toString(36).substring(7); 631 $('#modal-loading').modal('show'); 632 633 console.log('bbb'+data.data); 634 let params = {handle: handle,part_type:'product',bogo_buy:eligible_qty,bogo_get:free_qty,bogo_free:dd,bogo_discount_type:discount_type,bogo_discount_value:discount_value,bogo_free_count: free_qty_count,count:count,free_qty_count: free_qty_count,offer_type:offer_type,freecount:dd}; 635 636 xhr.call('getPartDetails', params, 'POST') 637 .then(function(data) { 638 if (data.status) { 639 640 $('#modal-loading').modal('show'); 641 data.data.uuid = data.data.uuid+'free'+r+k; 642 $('#last_'+data.data.uuid).val(0); 643 if(parseInt(dd)==k){ 644 $('#loadscheck').val(1); 645 } 646 647 cart.addPart(data.data); 648 k++; 649 } 650 }); 651 652 } 653 654 data.data.part['count'] = count; 655 data.data.part['uuid'] = data.data.part.uuid; 656 657 cart.updatePart(data.data.part);
658 $('#modal-loading').modal('hide'); 659 $.notify({ 660 from: "bottom", 661 title: "<strong></strong> ", 662 icon: 'glyphicon glyphicon-shopping-cart', 663 message: msg 664 }, { 665 timer: 1000, 666 type: 'success', 667 animate: { 668 enter: 'animated lightSpeedIn', 669 exit: 'animated lightSpeedOut' 670 } 671 }); 672 673 674 } 675 } 676 else{ 677 if(parseInt(free_qty_count)>0){ 678 var cds = (data.data.stock/(parseInt(free_qty_count)+parseInt(eligible_qty))); 679 var tds = Math.floor(cds)* parseInt(eligible_qty); 680 var cke = (data.data.stock%(parseInt(free_qty_count))); 681 count = (cke==0)?tds:(parseInt(tds)+parseInt(cke)); //5=(3-eligible1+3free1) 682 683 cd = (count/eligible_qty); 684 dd = (Math.floor(cd)*free_qty); 685 686 if(data.data.stock<(parseInt(count)+parseInt(dd))){ 687 count = count-1; 688 cd = (count/eligible_qty); 689 dd = (Math.floor(cd)*free_qty); 690 } 691 692 msg = 'We are Sorry! We are able to accomodate only '+ count +' quantity of each customer'; 693 694 $.notify({ 695 from: "bottom", 696 title: "<strong></strong> ", 697 icon: 'glyphicon glyphicon-shopping-cart', 698 message: msg 699 }, { 700 timer: 1000, 701 type: 'success', 702 animate: { 703 enter: 'animated lightSpeedIn', 704 exit: 'animated lightSpeedOut' 705 } 706 }); 707 var msg = dd + " Free item Added to your cart successfully...!"; 708 709 var k=1; 710 711 for(var i=1; i<=parseInt(dd);i++){ 712 var r = (Math.random() + 1).toString(36).substring(7); 713 $('#modal
713-loading').modal('show'); 714 let params = {handle: handle,part_type:'product',bogo_buy:eligible_qty,bogo_get:free_qty,bogo_free:dd,bogo_discount_type:discount_type,bogo_discount_value:discount_value,bogo_free_count: free_qty_count,count:count,free_qty_count: free_qty_count,offer_type:offer_type,freecount:dd}; 715 716 xhr.call('getPartDetails', params, 'POST') 717 .then(function(data) { 718 if (data.status) { 719 720 $('#modal-loading').modal('show'); 721 data.data.uuid = data.data.uuid+'free'+r+k; 722 $('#last_'+data.data.uuid).val(0); 723 if(parseInt(dd)==k){ 724 $('#loadscheck').val(1); 725 } 726 cart.addPart(data.data); 727 k++; 728 } 729 }); 730 731 } 732 733 $.notify({ 734 from: "bottom", 735 title: "<strong></strong> ", 736 icon: 'glyphicon glyphicon-shopping-cart', 737 message: msg 738 }, { 739 timer: 1000, 740 type: 'success', 741 animate: { 742 enter: 'animated lightSpeedIn', 743 exit: 'animated lightSpeedOut' 744 } 745 }); 746 747 748 749 data.data.part['count'] = count; 750 data.data.part['uuid'] = data.data.part.uuid; 751 cart.updatePart(data.data.part); 752 753 } 754 755 756 } 757 } 758 } 759 }); 760 761 } 762 763 764 var part_cart_interval = setInterval(function () { 765 if(cart_l>0) 766 { 767 clearInterval(part_cart_interval); 768 if(feature_tag==="1" && check_auto_addcart==="1"){ 769 // window.location = "http://sf.orx.loc/cart"; 770 window.location.href = BASE_PATH+"/cart"; 771 }else{ 772 if(add_orchid_eState_api_to_site==1 && is_firearm == 1){ 773 774 }else{ 775 if( eligible_qty>0 && parseInt(count) >= parseInt(eligible_qty)){ 776 if($('#loadscheck').val()!=1){ 777 778 }else{ 779 window.location.reload(); 780 } 781 782 }else{ 783 window.location.reload(); 784 } 785 } 786 } 787 } 788 },1000); 789 790 } 791 }); 792 793 } else if (!e.validity.valid) { 794 795 $.notify({ 796 title: "<strong class='insufficient-quantity-cart'></strong> ", 797 icon: 'glyphicon glyphicon-shopping-cart', 798 message: "Insufficient Quantity!" 799 }, { 800 timer: 2000, 801 type: 'dangert', 802 animate: { 803 enter: 'animated lightSpeedIn', 804 exit: 'animated lightSpeedOut' 805 } 806 }); 807 808 cart.showAlert('Insufficient Quantity!', 'danger'); 809 810 //setTimeout(window.location.href = BASE_PATH+"/products/"+handle , 6000); 811 setTimeout( 812 function() { 813 window.location.reload('BASE_PATH+"/products/"+handle'); 814 }, 3000); 815 } else { 816 817 $.notify({ 818 title: "<strong></strong> ", 819 icon: 'glyphicon glyphicon-shopping-cart', 820 message: "Unable to add product to cart!" 821 }, { 822 timer: 1000, 823 type: 'dangert', 824 animate: { 825 enter: 'animated lightSpeedIn', 826 exit: 'animated lightSpeedOut' 827 } 828 }); 829 830 cart.showAlert('Unable to add product to cart!', 'danger'); 831 } 832} 833 834 835if (CONTROLL == "calendar") { 836 Array.prototype.contains = function(v) { 837 for (var i = 0; i < this.length; i++) { 838 if (this[i] === v) return true; 839 } 840 return false;
841 }; 842 843 Array.prototype.unique = function() { 844 var arr = []; 845 for (var i = 0; i < this.length; i++) { 846 if (!arr.contains(this[i])) { 847 arr.push(this[i]); 848 } 849 } 850 return arr; 851 } 852} 853 854function addToCalCart(handle, count, type, travel_total, from_cart) { 855 if (type == 'course' && checkAddStudentForm()) { 856 getCourseRegisteredUsers(); 857 preserveContact(handle); 858 if (REG_USERS.length > 0) { 859 var reg_name = []; 860 var reg_email = []; 861 862 var contact_id=REG_USERS[0].id; 863 864 $.each(REG_USERS, function(i, item) { 865 reg_name.push(item.name); 866 reg_email.push(item.email); 867 }); 868 869 870 871 if($("#intrepid_courses_membership_enhancement_store_front").length>0 && $("#intrepid_courses_membership_enhancement_store_front").val()==1) { 872 let course_waiver_flag = $('#course_waiver_flag').val(); 873 if(course_waiver_flag == 1){ 874 $.each(REG_USERS, function(i, item) { 875 const data = localStorage.getItem(`waiver-${$("#check_course_id").val()}-${i}`); 876 if (data) { 877 course_waiver.push(JSON.parse(data)); 878 } 879 }); 880 } 881 882 var validation_array = []; 883 var validation_value = []; 884 $.each(REG_USERS, function(i, item) { 885 if(item.fname === ""){ 886 validation_array.push(1); 887 validation_value.push('First Name'); 888 } 889 if(item.lname === ""){ 890 validation_array.push(1); 891 validation_value.push('Last Name'); 892 } 893 894 if(typeof COURSE_DOB_REQ !== 'undefined' && COURSE_DOB_REQ == true && item.dob == ""){ 895 validation_array.push(1); 896 validation_value.push('DOB'); 897 } 898 899 if(typeof COURSE_OTHER_REQ !== 'undefined' && COURSE_OTHER_REQ == true && item.other == ""){ 900 validation_array.push(1); 901 validation_value.push('Other'); 902 } 903 904 if(typeof COURSE_HEIGHT_REQ !== 'undefined' && COURSE_HEIGHT_REQ == true && (item.height_feet == "" || item.height_inch == "")){ 905 validation_array.push(1); 906 validation_value.push('Height'); 907 } 908 909 if(typeof COURSE_WEIGHT_REQ !== 'undefined' && COURSE_WEIGHT_REQ == true && item.weight == ""){ 910 validation_array.push(1); 911 validation_value.push('Weight'); 912 } 913 914 if(typeof course_ph_flag !== 'undefined' && course_ph_flag == true && item.phone_no == ""){ 915 validation_array.push(1); 916 validation_value.push('Phone Number'); 917 } 918 }); 919 920 if (validation_array.length != 0){ 921 let validation_value_data = validation_value.unique().toString(); 922 alert(validation_value_data + " are required."); 923 return false; 924 } 925 926 } 927 928 929 } 930 if (reg_name.unique().length != REG_USERS.length) { 931 alert("You have entered the same student name more than once. Please remove to proceed."); 932 return false; 933 } 934 if (reg_email.unique().length != REG_USERS.length) { 935 //alert("You have entered more than one repeated student email, Please check and confirm?") 936 //return false; 937 } 938 939 if($("#intrepid_courses_membership_enhancement_store_front").length>0 && $("#intrepid_courses_membership_enhancement_store_front").val()==1) { 940 let course_waiver_flag = $('#course_waiver_flag').val(); 941 if(course_waiver_flag == 1){ 942 if (course_waiver.length != REG_USERS.length) { 943 course_waiver = []; 944 alert("The waiver form is missing from your submission"); 945 return false;
946 } 947 } 948 } 949 proceedAddToCalCart(handle, count, type, travel_total, from_cart,contact_id); 950 951 } 952 if ((type == 'travel' || type == 'charter') && checkAddOptionForm()) { 953 getTravelRegisteredUsers(); 954 getTravelAddonOptions(); 955 preserveContact(handle); 956 if (REG_USERS.length > 0) { 957 var reg_name = []; 958 var reg_email = []; 959 $.each(REG_USERS, function(i, item) { 960 reg_name.push(item.name); 961 reg_email.push(item.email); 962 }); 963 } 964 if (reg_name.unique().length != REG_USERS.length) { 965 alert("You have entered the same traveler name more than once. Please remove to proceed."); 966 return false; 967 } 968 if (reg_email.unique().length != REG_USERS.length) { 969 //alert("You have entered more than one repeated traveller email, Please check and confirm?") 970 //return false; 971 } 972 proceedAddToCalCart(handle, count, type, travel_total, from_cart); 973 } 974} 975var cal_checkout_btn = false; 976var cart_msg = ''; 977function proceedAddToCalCart(handle, count, type, travel_total, from_cart,contact_id='') { 978 if (handle) { 979 let params =""; 980 if($("#intrepid_courses_membership_enhancement_store_front").length>0 && $("#intrepid_courses_membership_enhancement_store_front").val()==1){ 981 if (REG_USERS.length > 0) { 982 params = { 983 handle: handle, 984 part_type: type, 985 travel_total: travel_total, 986 count:count, 987 customer_id:contact_id, 988 registerusers: JSON.stringify(REG_USERS), 989 course_waiver: JSON.stringify(course_waiver) 990 }; 991 } else { 992 params = { 993 handle: handle, 994 part_type: type, 995 travel_total: travel_total, 996 count:count, 997 customer_id:contact_id 998 }; 999 } 1000 } else { 1001 params = { 1002 handle: handle, 1003 part_type: type, 1004 travel_total: travel_total, 1005 count:count, 1006 customer_id:contact_id 1007 }; 1008 } 1009 1010 xhr.call('getPartDetails', params, 'POST') 1011 .then(function(data) { 1012 1013 if (data.status) { 1014 1015 $.notify({ 1016 title: "<strong></strong> ", 1017 icon: 'glyphicon glyphicon-shopping-cart', 1018 message: cart_msg //"Added to your cart successfully...!" 1019 }, { 1020 timer: 1000, 1021 type: 'success', 1022 animate: { 1023 enter: 'animated lightSpeedIn', 1024 exit: 'animated lightSpeedOut' 1025 } 1026 }); 1027 if (type == 'travel' || type == 'charter') { 1028 data.data.count = 1; 1029 } else { 1030 data.data.count = count; 1031 } 1032 data.data.original_count = count; 1033 var addon_cnt = 0; 1034 // if(data.data.addons) 1035 // { 1036 // $.each(data.data.addons, function(key, item) { 1037 // cart.addPart(item); 1038 // addon_cnt++; 1039 // }); 1040 // } 1041 1042 if($("#intrepid_courses_membership_enhancement_store_front").length>0 && $("#intrepid_courses_membership_enhancement_store_front").val()==1){ 1043 if(data.data.membership_flag_enable){ 1044 let validation_show_error_deleted = data.data.validation_show_error_deleted; 1045 if(validation_show_error_deleted.length>0){ 1046 let error_valid_msg = 'Membership '+validation_show_error_deleted.toString()+', which you entered, has been removed.'; 1047 alert(error_valid_msg); 1048 } 1049
1050 let validation_show_error_not_valid = data.data.validation_show_error_not_valid; 1051 if(validation_show_error_not_valid.length>0){ 1052 let error_valid_msg = 'You entered an invalid membership code: ' + validation_show_error_not_valid.toString(); 1053 alert(error_valid_msg); 1054 } 1055 1056 if(data.data.valid_membership_handle && data.data.valid_membership_count){ 1057 addToCartMembership(data.data.valid_membership_handle, data.data.valid_membership_count, 'Membership',data.data.id, contact_id); 1058 addon_cnt++; 1059 } 1060 } else { 1061 if(data.data.remove_valid_membership){ 1062 cart.removePartMembership(data.data.remove_valid_membership); 1063 addon_cnt++; 1064 } 1065 } 1066 } 1067 cart.addPart(data.data); 1068 cart.assignCount(); 1069 addon_cnt++; 1070 var course_addon_interval = setInterval(function () { 1071 console.log(cart_l+"----"+addon_cnt) 1072 if(cart_l==addon_cnt) 1073 { 1074 clearInterval(course_addon_interval); 1075 if(cal_checkout_btn==true){ 1076 console.log('check1'); 1077 window.location.href = BASE_PATH+"/checkout"; 1078 }else{ 1079 if(from_cart == 'yes'){ 1080 window.location.href = BASE_PATH+"/cart"; 1081 }else{ 1082 window.location.reload(); 1083 } 1084 } 1085 } 1086 },1200); 1087 } 1088 }); 1089 hideMainDialog(); 1090 } 1091} 1092 1093 1094function addToCartMembership(handle, count, type, courseid, contact_id='') { 1095 if (handle) { 1096 let params =""; 1097 params = { 1098 handle: handle, 1099 part_type: type, 1100 courseid: courseid, 1101 count:count, 1102 customer_id:contact_id 1103 }; 1104 1105 xhr.call('getPartDetails', params, 'POST') 1106 .then(function(data) { 1107 if (data.status) { 1108 $.notify({ 1109 title: "<strong></strong> ", 1110 icon: 'glyphicon glyphicon-shopping-cart', 1111 message: cart_msg //"Added to your cart successfully...!" 1112 }, { 1113 timer: 1000, 1114 type: 'success', 1115 animate: { 1116 enter: 'animated lightSpeedIn', 1117 exit: 'animated lightSpeedOut' 1118 } 1119 }); 1120 data.data.count = count; 1121 cart.addPart(data.data); 1122 cart.assignCount(); 1123 } 1124 }) 1125 } 1126 } 1127 1128 1129function deleteFromCart(uuid, el, unique_id,is_from="") { 1130 if (unique_id != '') { 1131 var cart_res = cart.removePart(unique_id); 1132 } else { 1133 var cart_res = cart.removePart(uuid); 1134 } 1135 if (cart_res) { 1136 $(el).closest("tr").remove(); 1137 1138 $("li." + uuid).remove(); 1139 1140 var amount = ($("#amountPayable").length != 0) ? $("#amountPayable").html() : '$ 0.00'; 1141 1142 var tot_item = parseInt($(".tot_items").attr("data-tot")) - 1; 1143 $(".tot_items").attr("data-tot", tot_item); 1144 $(".amountPayable").html(amount); 1145 var tot_item = parseInt($(".tot_items").attr("data-tot")); 1146 $(".tot_items").attr("data-tot", tot_item); 1147 $(".tot_items").html(tot_item + " item(s) - " + amount); 1148 1149 if($(".item_not_available").length==0) 1150 { 1151 if (CONTROLL == "products" && ACTION == "cart" ) 1152 { 1153 if($(".btn_place_order").length>0) 1154 {
1155 $(".btn_place_order").attr("disabled",false); 1156 } 1157 else if($("#place_order").length>0) 1158 { 1159 $("#place_order").attr("disabled",false); 1160 } 1161 } 1162 } 1163 1164 1165 $.notify({ 1166 title: "<strong></strong> ", 1167 icon: 'glyphicon glyphicon-shopping-cart', 1168 message: "Deleted from your cart successfully...!" 1169 }, { 1170 timer: 1000, 1171 type: 'success', 1172 animate: { 1173 enter: 'animated lightSpeedIn', 1174 exit: 'animated lightSpeedOut' 1175 } 1176 }); 1177 1178 var rm_part_cart_interval = setInterval(function () { 1179 if(cart_l>0) 1180 { 1181 clearInterval(rm_part_cart_interval); 1182 if($('#ca_compliance_enhancements').val() == 1 && is_from == 'checkout'){ 1183 $("#block_item_popup").modal("hide"); 1184 $("#check_ca_compliance_popup").modal("hide"); 1185 } 1186 else if( is_from=="upc_check"){ 1187 $("#prod_"+uuid).remove(); 1188 setTimeout(function() { 1189 $("#ffl_rem_certify_modal").modal("hide"); 1190 window.location.href = BASE_PATH + "/checkout?rm_cart"; 1191 }, 1000); 1192 }else{ 1193 window.location.reload(); 1194 } 1195 } 1196 },1000); 1197 1198 1199 1200 } 1201 1202} 1203function deleteFromCartTop(uuid, el, unique_id) { 1204 if (confirm('Are you sure you want to remove this item from your cart??')) { 1205 if($("#implement_redis_in_home_page").val()==1 ){ 1206 if (unique_id != '' && unique_id != undefined) { 1207 var cart_res = cart.removePart(unique_id); 1208 } else { 1209 var cart_res = cart.removePart(uuid); 1210 } 1211 }else{ 1212 if (unique_id != '') { 1213 var cart_res = cart.removePart(unique_id); 1214 } else { 1215 var cart_res = cart.removePart(uuid); 1216 } 1217 } 1218 if (cart_res) { 1219 $(el).parent().parent().remove(); 1220 setTimeout(() => { 1221 $.ajax({ 1222 url: BASE_PATH + "/ajax/remove_shipping", 1223 success: function(result) {} 1224 }); 1225 }, 1000); 1226 1227 $.notify({ 1228 title: "<strong></strong> ", 1229 icon: 'glyphicon glyphicon-shopping-cart', 1230 message: "Deleted from your cart successfully...!" 1231 }, { 1232 timer: 1000, 1233 type: 'success', 1234 animate: { 1235 enter: 'animated lightSpeedIn', 1236 exit: 'animated lightSpeedOut' 1237 } 1238 }); 1239 var rm_part_cart_interval = setInterval(function () { 1240 if(cart_l>0) 1241 { 1242 clearInterval(rm_part_cart_interval); 1243 window.location.reload(); 1244 } 1245 },1000); 1246 //setTimeout(location.reload(), 1000); 1247 } 1248 } 1249 return false; 1250} 1251function changeUnitCount(handle, uuid, e, product_type, original_count) { 1252 1253 $(e).addClass("no-spinner"); 1254 var temp = 0; 1255 var free_qty = parseInt($('#free_qty_'+uuid).val()); 1256 var boffer_id = parseInt($('#boffer_id_'+uuid).val()); 1257 var free_qty_count = parseInt($('#free_qty_count_'+uuid).val()); 1258 1259 var offer_type = $('#offer_type_'+uuid).val(); 1260 var eligible_qty = parseInt($('#eligible_qty_'+uuid).val()); 1261 var price = parseInt($('#price_'+uuid).val()); 1262 var discount_value = parseInt($('#discount_value_'+uuid).val()); 1263 var discount_type = parseInt($('#discount_type_'+uuid).val()); 1264 var count = $(e).val(); 1265 1266 if (cart.isUUIDExists(uuid) && e.value > 0 && eligible_qty>0) { 1267 let read_cart= cart.readCookie(); 1268 for (let key in read_cart) { 1269 if(read_cart[key].bogo=='free') 1270 { 1271 $(e).addClass("no-spinner"); 1272 } 1273 else{ 1274 //$(e).removeClass("no-spinner"); 1275 } 1276 if((read_cart[key].free==1 && read_cart[key].parent_uuid == uuid) ) 1277 { 1278 cart.removePart(read_cart[key].uuid); 1279 } 1280 } 1281 1282 1283 if(offer_type!=1 && free_qty_count>0){ 1284 var cd = (count/eligible_qty); 1285 var dd = (Math.floor(cd)*free_qty); 1286 } 1287 1288 if(((offer_type==1) && (discount_type==1 || discount_type==0))){ 1289 var cd = (count/eligible_qty); 1290 var dd = (Math.floor(cd)); 1291 } 1292 1293 let params = { 1294 freecount: dd, 1295 free_qty_count:free_qty_count, 1296 offer_type:offer_type, 1297 boffer_id:boffer_id, 1298 handle: handle, 1299 count: $(e).val(), 1300 product_type: product_type.toLowerCase() 1301 }; 1302 1303 1304 xhr.call('checkStock', params, 'POST') 1305 .then(function(data) { 1306 if (data.status) { 1307 if($("#PSO_"+data.data.part['uuid']).length>0) 1308 { 1309 if(data.data.PSO_msg) 1310 { 1311 $("#PSO_"+data.data.part['uuid']).html(data.data.PSO_msg); 1312 }else{ 1313 $("#PSO_"+data.data.part['uuid']).html(''); 1314 } 1315 } 1316 return data.data; 1317 } 1318 }) 1319 .then(function(data) { 1320 1321 if(offer_type!=1){ 1322 var cd = (count/eligible_qty); 1323 var dd = (Math.floor(cd)*free_qty); 1324 if( data.available || data.stock >= (parseInt(count)+parseInt(dd))) { 1325 1326 if(count<eligible_qty){ 1327 1328 $(e).val(count); 1329 $('#last_'+data.part.uuid).val(1); 1330 data.part['count'] = count;
1331 $('#modal-loading').modal('show'); 1332 cart.updatePart(data.part); 1333 1334 1335 }else{ 1336 1337 var msg = dd + " Free item Added to your cart successfully...!"; 1338 k=1; 1339 for(var i=1; i<=parseInt(dd);i++){ 1340 var r = (Math.random() + 1).toString(36).substring(7); 1341 let params = {handle: handle,part_type:'product',bogo_buy:eligible_qty,bogo_get:free_qty,bogo_free:dd,bogo_discount_type:discount_type,bogo_discount_value:discount_value,bogo_free_count: free_qty_count}; 1342 1343 xhr.call('getPartDetails', params, 'POST') 1344 .then(function(data) { 1345 if (data.status) { 1346 $('#modal-loading').modal('show'); 1347 data.data.uuid = uuid+'free'+r+k; 1348 $('#last_'+uuid).val(0); 1349 if(parseInt(dd)==k){ 1350 $('#last_'+uuid).val(1); 1351 } 1352 console.log(dd); 1353 console.log(data.data); 1354 cart.addPart(data.data); 1355 1356 k++; 1357 } 1358 }); 1359 } 1360 1361 $.notify({ 1362 from: "bottom", 1363 title: "<strong></strong> ", 1364 icon: 'glyphicon glyphicon-shopping-cart', 1365 message: msg 1366 }, { 1367 timer: 1000, 1368 type: 'success', 1369 animate: { 1370 enter: 'animated lightSpeedIn', 1371 exit: 'animated lightSpeedOut' 1372 } 1373 }); 1374 $(e).val(count); 1375 data.part['count'] = count; 1376 cart.updatePart(data.part); 1377 } 1378 } 1379 else{ 1380 1381 1382 var cds = (data.stock/(parseInt(free_qty_count)+parseInt(eligible_qty)));//3 1383 var tds = Math.floor(cds)* parseInt(eligible_qty);//6 1384 var cke = (data.stock%(parseInt(free_qty_count))); //1 1385 1386 count = (cke==0)?tds:(parseInt(tds)+parseInt(cke)); 1387 var cd = (count/eligible_qty); 1388 var dd = (Math.floor(cd)*free_qty); 1389 if(data.stock<(parseInt(count)+parseInt(dd))){ 1390 count = parseInt(count)-1; 1391 var cd = (count/eligible_qty); 1392 var dd = (Math.floor(cd)*free_qty); 1393 } 1394 if(data.nla==true) 1395 { 1396 var alrmsg = 'This product is no longer available. Maximum order quantity available: '+data.stock; 1397 } 1398 else{ 1399 var alrmsg = 'We are Sorry! We are able to accomodate only '+ data.processed +' quantity of <strong>'+ data.title +'</strong> for each customer'; 1400 } 1401 cart.showAlert(alrmsg, 'danger'); 1402 var msg = dd + " Free item Added to your cart successfully...!"; 1403 k=1; 1404 for(var i=1; i<=parseInt(dd);i++){ 1405 1406 var r = (Math.random() + 1).toString(36).substring(7); 1407 let params = {handle: handle,part_type:'product',bogo_buy:eligible_qty,bogo_get:free_qty,bogo_free:dd,bogo_discount_type:discount_type,bogo_discount_value:discount_value,bogo_free_count: free_qty_count}; 1408 xhr.call('getPartDetails', params, 'POST') 1409 .then(function(data) { 1410 if (data.status) {
1411 $('#modal-loading').modal('show'); 1412 data.data.uuid = uuid+'free'+r+k; 1413 $('#last_'+uuid).val(0); 1414 if(parseInt(dd)==k){ 1415 $('#last_'+uuid).val(1); 1416 } 1417 1418 cart.addPart(data.data); 1419 k++; 1420 } 1421 }); 1422 } 1423 1424 $('#modal-loading').modal('hide'); 1425 $.notify({ 1426 from: "bottom", 1427 title: "<strong></strong> ", 1428 icon: 'glyphicon glyphicon-shopping-cart', 1429 message: msg 1430 }, { 1431 timer: 1000, 1432 type: 'success', 1433 animate: { 1434 enter: 'animated lightSpeedIn', 1435 exit: 'animated lightSpeedOut' 1436 } 1437 }); 1438 1439 //temp = count; 1440 $(e).val(count); 1441 data.part['count'] = count; 1442 cart.updatePart(data.part); 1443 } 1444 1445 }else{ 1446 var cd = (count/eligible_qty); 1447 var dd = (Math.floor(cd)); 1448 if(offer_type==1 && discount_type==1){ 1449 discount_value = (discount_value)/100; 1450 } 1451 if(data.available || data.stock >= (parseInt(count))) { 1452 if(count<eligible_qty){ 1453 1454 $(e).val(count); 1455 $('#last_'+data.part.uuid).val(1); 1456 data.part['count'] = count; 1457 $('#modal-loading').modal('show'); 1458 cart.updatePart(data.part); 1459 return false; 1460 1461 }else{ 1462 var msg = " Discount added to your cart successfully...!"; 1463 if(parseInt(dd)>0){ 1464 var k=1; 1465 for(var i=1; i<=parseInt(dd);i++){ 1466 var r = (Math.random() + 1).toString(36).substring(7); 1467 $('#modal-loading').modal('show'); 1468 // data.data.uuid = 1469 //console.log('bbb'+data.data); 1470 let params = {handle: handle,part_type:'product',bogo_buy:eligible_qty,bogo_get:free_qty,bogo_free:dd,bogo_discount_type:discount_type,bogo_discount_value:discount_value,bogo_free_count: free_qty_count,count:count,free_qty_count: free_qty_count,offer_type:offer_type,freecount:dd}; 1471 1472 xhr.call('getPartDetails', params, 'POST') 1473 .then(function(data) { 1474 if (data.status) { 1475 var x = data.data.uuid; 1476 $('#modal-loading').modal('show'); 1477 data.data.uuid = data.data.uuid+'free'+r+k; 1478 $('#last_'+x).val(0); 1479 if(parseInt(dd)==k){ 1480 $('#last_'+x).val(1); 1481 } 1482 1483 cart.addPart(data.data); 1484 k++; 1485 } 1486 }); 1487 1488 } 1489
1490 $('#modal-loading').modal('hide'); 1491 $.notify({ 1492 from: "bottom", 1493 title: "<strong></strong> ", 1494 icon: 'glyphicon glyphicon-shopping-cart', 1495 message: msg 1496 }, { 1497 timer: 1000, 1498 type: 'success', 1499 animate: { 1500 enter: 'animated lightSpeedIn', 1501 exit: 'animated lightSpeedOut' 1502 } 1503 }); 1504 $(e).val(count); 1505 data.part['count'] = count; 1506 cart.updatePart(data.part); 1507 } 1508 } 1509 } 1510 else{ 1511 var cd = (count/eligible_qty); 1512 var dd = (Math.floor(cd)); 1513 if(offer_type==1 && discount_type==1){ 1514 discount_value = (discount_value)/100; 1515 } 1516 if(data.nla==true) 1517 { 1518 var alrmsg = 'This product is no longer available. Maximum order quantity available: '+data.stock; 1519 } 1520 else{ 1521 var alrmsg = 'We are Sorry! We are able to accomodate only '+ data.processed +' quantity of <strong>'+ data.title +'</strong> for each customer'; 1522 } 1523 cart.showAlert(alrmsg, 'danger'); 1524 if(discount_type==1 || discount_type==0){ 1525 if(data.stock <= count) { 1526 count = data.stock; 1527 } 1528 cd = (count/eligible_qty); 1529 dd = Math.floor(cd); 1530 var msg = "Discount added to your cart successfully...!"; 1531 } 1532 1533 k=1; 1534 var temp= count; 1535 for(var i=1; i<=parseInt(dd);i++){ 1536 var r = (Math.random() + 1).toString(36).substring(7); 1537 let params = {handle: handle,part_type:'product',bogo_buy:eligible_qty,bogo_get:free_qty,bogo_free:dd,bogo_discount_type:discount_type,bogo_discount_value:discount_value,bogo_free_count: free_qty_count,count: temp}; 1538 xhr.call('getPartDetails', params, 'POST') 1539 .then(function(data) { 1540 if (data.status) { 1541 var x = data.data.uuid; 1542 $('#modal-loading').modal('show'); 1543 data.data.uuid = data.data.uuid+'free'+r+k; 1544 $('#last_'+x).val(0); 1545 if(parseInt(dd)==k){ 1546 $('#last_'+x).val(1); 1547 } 1548 //console.log('sad'); 1549 cart.addPart(data.data); 1550 k++; 1551 } 1552 }); 1553 } 1554 $('#modal-loading').modal('hide'); 1555 $(e).val(temp); 1556 data.part['count'] = temp; 1557 cart.updatePart(data.part); 1558 $.notify({ 1559 from: "bottom", 1560 title: "<strong></strong> ", 1561 icon: 'glyphicon glyphicon-shopping-cart', 1562 message: msg 1563 }, { 1564 timer: 1000, 1565 type: 'success', 1566 animate: { 1567 enter: 'animated lightSpeedIn', 1568 exit: 'animated lightSpeedOut' 1569 } 1570 }); 1571 1572 } 1573 } 1574 }); 1575 1576 1577 } 1578 else{ 1579 if (cart.isUUIDExists(uuid) && e.value > 0) { 1580 let params = { 1581 handle: handle, 1582 count: $(e).val(), 1583 product_type: product_type.toLowerCase() 1584 }; 1585 if (product_type == "GiftCertificate") { 1586 params.gc_key = $(e).attr('data-key'); 1587 } 1588 xhr.call('checkStock', params, 'POST') 1589 .then(function(data) { 1590 if (data.status) { 1591 if($("#PSO_"+data.data.part['uuid']).length>0) 1592 { 1593 if(data.data.PSO_msg) 1594 { 1595 $("#PSO_"+data.data.part['uuid']).html(data.data.PSO_msg); 1596 }else{ 1597 $("#PSO_"+data.data.part['uuid']).html(''); 1598 } 1599 } 1600 return data.data; 1601 } 1602 }) 1603 .then(function(data) { 1604 if (!data.available) { 1605 if(data.nla==true) 1606 { 1607 var alrmsg = 'This product is no longer available. Maximum order quantity available: '+data.stock; 1608 } 1609 else{ 1610 var alrmsg = 'We are Sorry! We are able to accomodate only '+ data.processed +' quantity of <strong>'+ data.title +'</strong> for each customer'; 1611 } 1612 cart.showAlert(alrmsg, 'danger'); 1613 } 1614 $(e).val(data.processed); 1615 if (product_type == "Travel" || product_type == "Charter" || product_type == "Course") { 1616 } else { 1617 $(e).closest("tr").find(".cart_price").html(data.part.price); 1618 $(e).closest("tr").find(".sub-total").html(data.subTotal); 1619 } 1620 return data; 1621 }) 1622 .then(function(data) { 1623 if (product_type == "Travel" || product_type == "Charter") { 1624 if (data.available) 1625 gotoCalenderRegister(handle, (original_count + 1), product_type); 1626 } else if (product_type == "Course") { 1627 if (data.available) 1628 gotoCalenderRegister(handle, (e.value), product_type); 1629 } else { 1630 cart.updatePart(data.part); 1631 } 1632 }); 1633 } 1634 } 1635 1636 1637 1638} 1639 1640function gotoCalenderRegister(handle, count, product_type) { 1641 let params = { 1642 handle: handle, 1643 count: count, 1644 product_type: product_type 1645 }; 1646 xhr.call('getCollection', params, 'POST') 1647 .then(function(data) { 1648 if (data.status) { 1649 if (product_type == "Course") { 1650 window.location.href = BASE_PATH + "/calendar/register/" + data.data['collection_uuid'] + "/" + data.data['id'] + "/" + data.data['count'] + "/" + data.data['handle']; 1651 } else { 1652 window.location.href = BASE_PATH + "/calendar/reserve/" + data.data['collection_uuid'] + "/" + data.data['id'] + "/" + count + "/" + data.data['handle']; 1653 } 1654 } 1655 }) 1656} 1657 1658function clearCookie() { 1659 cart.clearCookie(); 1660} 1661 1662function shippingOptionChanged(e) { 1663 var opt = $(e).val(); 1664 1665 if (opt === 'new_shipping') { 1666 OPT_BILLING_ADDRESS = 1; 1667 $("#conNewShipping").slideDown(); 1668 } else if (opt === 'same_as_shipping') { 1669 OPT_BILLING_ADDRESS = 0; 1670 $("#conNewShipping").slideUp(); 1671 } 1672} 1673 1674$(document).on('click', '#terms_conditions ', function(){ 1675 if($("#terms_conditions").prop("checked")) 1676 { 1677 if($('#master_v2_mobile_ui_fixs').val()==1){ 1678 $(".terms_conditions").removeClass("error"); 1679 }else{ 1680 $(".terms_conditions").removeClass("error").css({"font-weight":"600","padding":"0px 10px"}); 1681 $(".terms_conditions_error").css({"border":"none","padding":"0px 10px","margin-bottom":"10px"}); 1682 } 1683 } 1684}); 1685function pform_submit(fid) 1686{ 1687 if($("#terms_conditions").length>0){ 1688 if(!$("#terms_conditions").prop("checked")) 1689 { 1690 $(".terms_conditions").addClass("error").css({"font-weight":"600","padding":"0px 10px"}); 1691 $(".terms_conditions_error").css({"border":"1px solid","padding":"0px 10px","margin-bottom":"10px"}); 1692 alert("Please accept the terms & conditions to proceed further."); 1693 $('#btnSubmitPay').attr("disabled", false); 1694 return false;
1695 }else 1696 { 1697 1698 1699 if(fid == "DirectPayAuthForm"){ 1700 process_payment(); 1701 } 1702 else if(fid == "FapsAuthForm"){ 1703 process_payment(); 1704 } 1705 else if(fid == "b2bPOPayAuthForm"){ 1706 process_payment(); 1707 } 1708 else if(fid == "vaultCardOnFilePayAuthForm"){ 1709 process_payment(); 1710 } 1711 else if(fid == "paylaterAuthForm" && $('#partial_and_click_to_pay').val()==1){ 1712 process_payment(); 1713 }else if(fid == "DeluxeAuthForm" && $('#deluxe_payment_integration').val()==1){ 1714 process_payment(); 1715 } 1716 else{ 1717 $('#'+fid).submit(); 1718 } 1719 1720 1721 } 1722 } 1723 else{ 1724 1725 1726 if(fid == "DirectPayAuthForm"){ 1727 process_payment(); 1728 } 1729 else if(fid == "FapsAuthForm"){ 1730 process_payment(); 1731 } 1732 else if(fid == "b2bPOPayAuthForm"){ 1733 process_payment(); 1734 } 1735 else if(fid == "vaultCardOnFilePayAuthForm"){ 1736 process_payment(); 1737 } 1738 else if(fid == "paylaterAuthForm" && $('#partial_and_click_to_pay').val()==1){ 1739 process_payment(); 1740 } 1741 else if(fid == "DeluxeAuthForm" && $('#deluxe_payment_integration').val()==1){ 1742 process_payment(); 1743 } 1744 else{ 1745 $('#'+fid).submit(); 1746 } 1747 1748 } 1749} 1750var pwd_cap_error = false; 1751var prevent_cc = 0; 1752function prevent_cc_testing() 1753{ 1754 prevent_cc++; 1755 if($("#add_ability_for_clients_to_whitelist_blacklist_customers").length>0 && $("#add_ability_for_clients_to_whitelist_blacklist_customers").val()==1){ 1756 if(prevent_cc>=PREVENT_CC_LIMIT){ 1757 $.notify({ 1758 title: "", 1759 icon: 'glyphicon glyphicon-cart', 1760 message: "You have tried too many attempts.." 1761 }, { 1762 offset: { 1763 x: 50, 1764 y: 200 1765 }, 1766 timer: 1000, 1767 type: 'danger', 1768 animate: { 1769 enter: 'animated lightSpeedIn', 1770 exit: 'animated lightSpeedOut' 1771 } 1772 }); 1773 setTimeout(function(){ 1774 window.location.href = BASE_PATH + "/checkout"; 1775 },1000); 1776 } 1777 }else{ 1778 if(prevent_cc>=3){ 1779 $.notify({ 1780 title: "", 1781 icon: 'glyphicon glyphicon-cart', 1782 message: "You have tried too many attempts.." 1783 }, { 1784 offset: { 1785 x: 50, 1786 y: 200 1787 }, 1788 timer: 1000, 1789 type: 'danger', 1790 animate: { 1791 enter: 'animated lightSpeedIn', 1792 exit: 'animated lightSpeedOut' 1793 } 1794 }); 1795 setTimeout(function(){ 1796 window.location.href = BASE_PATH + "/checkout"; 1797 },1000); 1798 } 1799 } 1800} 1801$(document).on('click', '#btnSubmitPay', function() { 1802 1803 if($("#pay_by").attr("data-action")=="cc") 1804 { 1805 var cccn = $("#CreditCardCardNumber").val(); 1806 var cccv = $("#CreditCardCvv").val(); 1807 var cce = $("#CreditCardExpiry").val(); 1808 var ccn = $("#CreditCardName").val(); 1809 var amountPayable_ship = parseFloat($("#amountPayable_ship").attr("data-amount")); 1810 if( (cccn=='' || cccv=='' || cce=='' || ccn=='') && amountPayable_ship>0 ) 1811 { 1812 if(amountPayable_ship>0) 1813 { 1814 $(".gc_error").html("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");//.fadeIn(); 1815 //setTimeout(function(){ $(".gc_error").fadeOut(); },5000); 1816 $("#gc_serial_number").focus(); 1817 return false;
1818 } 1819 } 1820 } 1821 if ($("#DirectPayAuthForm").length) { 1822 $('#btnSubmitPay').attr("disabled", true); 1823 pform_submit("DirectPayAuthForm"); 1824 } else if($("#DeluxeAuthForm").length && $("#deluxe_payment_integration").val()==1){ 1825 if($("#terms_conditions").length>0 && !$("#terms_conditions").prop("checked")){ 1826 $(".terms_conditions").addClass("error").css({"font-weight":"600","padding":"0px 10px"}); 1827 $(".terms_conditions_error").css({"border":"1px solid","padding":"0px 10px","margin-bottom":"10px"}); 1828 alert("Please accept the terms & conditions to proceed further."); 1829 $('#btnSubmitPay').attr("disabled", false); 1830 return false; 1831 } 1832 var btnObj = this; 1833 $(btnObj).attr('disabled', true); 1834 $('#btnSubmitPay').attr("disabled", true); 1835 deluxePay(); 1836 }else if ($("#CreditCardAuthForm").length) { 1837 if($("#CreditCardAuthForm").valid()) 1838 { 1839 var btnObj = this; 1840 $(btnObj).attr('disabled', true); 1841 $('#btnSubmitPay').attr("disabled", true); 1842 1843 $.ajax({ 1844 url: BASE_PATH + "/site/verify_captcha", 1845 type: "POST", 1846 data: { 1847 captcha: $("#cc_security #g-recaptcha-response").val(), 1848 action: $("#cc_security #action").val(), 1849 UserCaptcha: $("#cc_security #UserCaptcha").length ? $("#cc_security #UserCaptcha").val() : '', 1850 scode: $("#cc_security #UserCaptcha").length ? $("#cc_security #UserCaptcha").attr('data-val') : '' 1851 1852 }, 1853 success: function success(res) { 1854 1855 var obj = JSON.parse(res); 1856 if (Object.keys(obj).length > 1 && obj.success == true && obj.action && obj.score == captcha_threshold || Object.keys(obj).length == 1 && obj.success == true) { 1857 $('#btnSubmitPay').attr("disabled", true); 1858 pform_submit("CreditCardAuthForm"); 1859 } else { 1860 $(btnObj).attr('disabled', false); 1861 $('.creload:visible').trigger('click'); 1862 1863 prevent_cc_testing(); 1864 1865 $(".simple_security").fadeIn(); 1866 $(btnObj).attr('disabled', false); 1867 1868 if (obj.message) { 1869 $("#cc_security #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">' + obj.message + '</label>'); 1870 } else { 1871 $("#cc_security #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">Please enter the security code</label>'); 1872 } 1873 1874 } 1875 } 1876 }); 1877 } 1878 }else if($("#payment-form").length && $("#payment-form").is("form")) 1879 { 1880 console.log('cc',manualInputStates); 1881 1882 if(manualInputStates['cardNumber']==false ){ 1883 $('#card-errors1').html(errorInputmsg['cardNumber']); 1884 $('#card-errors1').css('display','block'); 1885 $("#btnSubmitPay").attr("disabled", false); 1886 }else{ 1887 $('#card-errors1').html(''); 1888 $('#card-errors1').css('display','none'); 1889 } 1890 if( manualInputStates['cardExpiry']==false ){ 1891 $('#card-errors3').html(errorInputmsg['cardExpiry']); 1892 $('#card-errors3').css('display','block'); 1893 $("#btnSubmitPay").attr("disabled", false); 1894 }else{ 1895 $('#card-errors3').html(''); 1896 $('#card-errors3').css('display','none'); 1897 } 1898 if( manualInputStates['cardCvc']==false ){ 1899 $('#card-errors2').html(errorInputmsg['cardCvc']); 1900 $('#card-errors2').css('display','block'); 1901 $("#btnSubmitPay").attr("disabled", false); 1902 }else{ 1903 $('#card-errors2').html(''); 1904 $('#card-errors2').css('display','none'); 1905 } 1906 if( manualInputStates['postalCode']==false){ 1907 $('#card-errors4').html(errorInputmsg['postalCode']); 1908 $('#card-errors4').css('display','block'); 1909 $("#btnSubmitPay").attr("disabled", false); 1910 }else{ 1911 $('#card-errors4').html(''); 1912 $('#card-errors4').css('display','none'); 1913 } 1914 if($("#payment-form").valid() && (manualInputStates['cardNumber']==true && manualInputStates['cardExpiry']==true && manualInputStates['cardCvc']==true && manualInputStates['postalCode']==true)) 1915 { 1916 var btnObj = this; 1917 $(btnObj).attr('disabled', true); 1918 $('#btnSubmitPay').attr("disabled", true); 1919 $.ajax({ 1920 url: BASE_PATH + "/site/verify_captcha", 1921 type: "POST", 1922 data: { 1923 captcha: $("#cc_security #g-recaptcha-response").val(), 1924 action: $("#cc_security #action").val(), 1925 UserCaptcha: $("#cc_security #UserCaptcha").length ? $("#cc_security #UserCaptcha").val() : '', 1926 scode: $("#cc_security #UserCaptcha").length ? $("#cc_security #UserCaptcha").attr('data-val') : '' 1927 }, 1928 success: function success(res) { 1929 1930 var obj = JSON.parse(res); 1931 if (Object.keys(obj).length > 1 && obj.success == true && obj.action && obj.score == captcha_threshold || Object.keys(obj).length == 1 && obj.success == true) { 1932 $('#btnSubmitPay').attr("disabled", true); 1933 pform_submit("payment-form"); 1934 } else { 1935 $(btnObj).attr('disabled', false); 1936 $('.creload:visible').trigger('click'); 1937 1938 prevent_cc_testing(); 1939 1940 $(".simple_security").fadeIn(); 1941 $(btnObj).attr('disabled', false); 1942 $('#usercaptcha-error').remove(); 1943 if (obj.message) { 1944 $("#cc_security #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">' + obj.message + '</label>'); 1945 } else { 1946 $("#cc_security #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">Please enter the security code</label>'); 1947 } 1948 } 1949 } 1950 }); 1951} 1952 }else if($("#b2bPOPayAuthForm").length ) 1953 { 1954 if($("#b2bPOPayAuthForm").valid()){ 1955 var btnObj = this; 1956 $(btnObj).attr('disabled', true); 1957 $('#btnSubmitPay').attr("disabled", true); 1958 $.ajax({ 1959 url: BASE_PATH + "/site/verify_captcha", 1960 type: "POST", 1961 data: { 1962 captcha: $("#cc_security #g-recaptcha-response").val(), 1963 action: $("#cc_security #action").val(), 1964 UserCaptcha: $("#cc_security #UserCaptcha").length ? $("#cc_security #UserCaptcha").val() : '', 1965 scode: $("#cc_security #UserCaptcha").length ? $("#cc_security #UserCaptcha").attr('data-val') : '' 1966 1967 }, 1968 success: function success(res) { 1969 1970 var obj = JSON.parse(res); 1971 if (Object.keys(obj).length > 1 && obj.success == true && obj.action && obj.score == captcha_threshold || Object.keys(obj).length == 1 && obj.success == true) { 1972 $('#btnSubmitPay').attr("disabled", true); 1973 if($.trim($("#b2b_po_number1").val())==''){ 1974 $("#b2b_po_number1").after('<label id="b2b_po_number1-error" class="error" for="b2b_po_number">Please enter the PO number</label>'); 1975 $(btnObj).attr('disabled', false); 1976 }else{ 1977 1978 1979 pform_submit("b2bPOPayAuthForm"); 1980 1981 1982 // pform_submit("b2bPOPayAuthForm"); 1983 } 1984 1985 1986 } else { 1987 $(btnObj).attr('disabled', false); 1988 $('.creload:visible').trigger('click'); 1989 1990 prevent_cc_testing(); 1991 1992 $(".simple_security").fadeIn(); 1993 $(btnObj).attr('disabled', false); 1994 1995 if (obj.message) { 1996 $("#cc_security #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">' + obj.message + '</label>'); 1997 } else { 1998 $("#cc_security #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">Please enter the security code</label>'); 1999 } 2000 if($.trim($("#b2b_po_number1").val())==''){ 2001 $("#b2b_po_number1").after('<label id="b2b_po_number1-error" class="error" for="b2b_po_number">Please enter the PO number</label>'); 2002 2003 } 2004 2005 } 2006 } 2007 }); 2008 2009 2010 } 2011 } 2012 else if($("#vaultCardOnFilePayAuthForm").length ) 2013 { 2014 if($("#vaultCardOnFilePayAuthForm").valid()){ 2015 var btnObj = this; 2016 $(btnObj).attr('disabled', true); 2017 $('#btnSubmitPay').attr("disabled", true); 2018 if($.trim($("#ownerZip").val())==''){ 2019 $("#ownerZip").after('<label id="ownerZip-error" class="error" for="vault_card_on_file">Please enter the Zip Code</label>'); 2020 $(btnObj).attr('disabled', false); 2021 } 2022 else{ 2023 $.ajax({ 2024 url: BASE_PATH + "/site/verify_captcha", 2025 type: "POST", 2026 data: { 2027 captcha: $("#cc_security #g-recaptcha-response").val(), 2028 action: $("#cc_security #action").val(), 2029 UserCaptcha: $("#cc_security #UserCaptcha").length ? $("#cc_security #UserCaptcha").val() : '', 2030 scode: $("#cc_security #UserCaptcha").length ? $("#cc_security #UserCaptcha").attr('data-val') : '' 2031 2032 }, 2033 success: function success(res) { 2034 2035 var obj = JSON.parse(res); 2036 if (Object.keys(obj).length > 1 && obj.success == true && obj.action && obj.score == captcha_threshold || Object.keys(obj).length == 1 && obj.success == true) { 2037 $('#btnSubmitPay').attr("disabled", true); 2038 pform_submit("vaultCardOnFilePayAuthForm"); 2039 } else { 2040 $(btnObj).attr('disabled', false); 2041 $('.creload:visible').trigger('click'); 2042 2043 prevent_cc_testing(); 2044 2045 $(".simple_security").fadeIn(); 2046 $(btnObj).attr('disabled', false); 2047 2048 if (obj.message) { 2049 $("#cc_security #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">' + obj.message + '</label>'); 2050 } else { 2051 $("#cc_security #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">Please enter the security code</label>'); 2052 } 2053 if($.trim($("#ownerZip").val())==''){ 2054 $("#ownerZip").after('<label id="ownerZip-error" class="error" for="ownerZip">Please enter the Zip Code</label>'); 2055 2056 } 2057 2058 } 2059 } 2060 }); 2061 } 2062 2063 } 2064 } 2065 else if($("#CardConnectCreditCardAuthForm").length) 2066 { 2067 if($("#partial_and_click_to_pay").val()==1 && $("#pat_typ_partial").is(":checked") && parseFloat($("#amountPayable_ship").attr("data-amount"))==0){ 2068 process_payment(); 2069 } 2070 else{ 2071 if($("#CardConnectCreditCardAuthForm").valid()){ 2072 var btnObj = this; 2073 $(btnObj).attr('disabled', true); 2074 $('#btnSubmitPay').attr("disabled", true); 2075 $.ajax({ 2076 url: BASE_PATH + "/site/verify_captcha", 2077 type: "POST", 2078 data: { 2079 captcha: $("#cc_security #g-recaptcha-response").val(), 2080 action: $("#cc_security #action").val(), 2081 UserCaptcha: $("#cc_security #UserCaptcha").length ? $("#cc_security #UserCaptcha").val() : '', 2082 scode: $("#cc_security #UserCaptcha").length ? $("#cc_security #UserCaptcha").attr('data-val') : '' 2083 2084 }, 2085 success: function success(res) { 2086 2087 var obj = JSON.parse(res); 2088 if (Object.keys(obj).length > 1 && obj.success == true && obj.action && obj.score == captcha_threshold || Object.keys(obj).length == 1 && obj.success == true) { 2089 $('#btnSubmitPay').attr("disabled", true); 2090 pform_submit("CardConnectCreditCardAuthForm"); 2091 } else { 2092 $(btnObj).attr('disabled', false); 2093 $('.creload:visible').trigger('click'); 2094 2095 prevent_cc_testing(); 2096 2097 $(".simple_security").fadeIn(); 2098 $(btnObj).attr('disabled', false); 2099 2100 if (obj.message) { 2101 $("#cc_security #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">' + obj.message + '</label>'); 2102 } else { 2103 $("#cc_security #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">Please enter the security code</label>'); 2104 } 2105 2106 } 2107 } 2108 }); 2109 2110 } 2111 } 2112 2113 }else if($("#WorldPayCreditCardAuthForm").length) 2114 { 2115 $('#btnSubmitPay').attr("disabled", true); 2116 pform_submit("WorldPayCreditCardAuthForm"); 2117 }else if($("#TsysCreditCardAuthForm").length) 2118 { 2119 var btnObj = this; 2120 $(btnObj).attr('disabled', true); 2121 $('#btnSubmitPay').attr("disabled", true); 2122 $.ajax({ 2123 url: BASE_PATH + "/site/verify_captcha", 2124 type: "POST", 2125 data: { 2126 captcha: $("#cc_security #g-recaptcha-response").val(), 2127 action: $("#cc_security #action").val(), 2128 UserCaptcha: $("#cc_security #UserCaptcha").length ? $("#cc_security #UserCaptcha").val() : '', 2129 scode: $("#cc_security #UserCaptcha").length ? $("#cc_security #UserCaptcha").attr('data-val') : '' 2130 2131 }, 2132 success: function success(res) { 2133 reset_captcha(); 2134 var obj = JSON.parse(res); 2135 if (Object.keys(obj).length > 1 && obj.success == true && obj.action && obj.score == captcha_threshold || Object.keys(obj).length == 1 && obj.success == true) { 2136 $('#btnSubmitPay').attr("disabled", true); 2137 pform_submit("TsysCreditCardAuthForm"); 2138
2138 } else { 2139 $(btnObj).attr('disabled', false); 2140 $('.creload:visible').trigger('click'); 2141 2142 prevent_cc_testing(); 2143 2144 $(".simple_security").fadeIn(); 2145 $(btnObj).attr('disabled', false); 2146 2147 if (obj.message) { 2148 $("#cc_security #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">' + obj.message + '</label>'); 2149 } else { 2150 $("#cc_security #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">Please enter the security code</label>'); 2151 } 2152 2153 } 2154 } 2155}); 2156 } 2157 else if($("#FapsAuthForm").length ) 2158 { 2159 if($("#FapsAuthForm").valid()){ 2160 var btnObj = this; 2161 $(btnObj).attr('disabled', true); 2162 2163 if($('#fapscryptogram').val()=='' && $("#gc_pay").prop("checked")==false){ 2164 // alert("Please check the card details"); 2165 $.confirm({ 2166 title: '', 2167 type: 'red', 2168 typeAnimated: true, 2169 content: '<p>
2169Invalid Card Data!</p><p>Please check the card details.</p>', 2170 buttons: { 2171 confirm: { 2172 text: 'Close', 2173 btnClass: 'btn-warning', 2174 keys: ['enter', 'y'], 2175 2176 } 2177 } 2178 }); 2179 $(btnObj).attr('disabled', false); 2180 } 2181 if($("#partial_and_click_to_pay").val()==1 && $('#fapscryptogram').val()=='' && $.trim($("#amountPayable_ship").attr("data-amount"))>0){ 2182 $.confirm({ 2183 title: '', 2184 type: 'red', 2185 typeAnimated: true, 2186 content: '<p>Invalid Card Data!</p><p>Please check the card details.</p>', 2187 buttons: { 2188 confirm: { 2189 text: 'Close', 2190 btnClass: 'btn-warning', 2191 keys: ['enter', 'y'], 2192 2193 } 2194 } 2195 }); 2196 $(btnObj).attr('disabled', false); 2197 } 2198 else{ 2199 if($('#fapsownerzipstatus').val()==1){ 2200 if($('#CreditCardOwnerZip').val()==''){ 2201 $("#CreditCardOwnerZip").after('<label id="CreditCardOwnerZip-error" class="error" for="CreditCardOwnerZip">Please enter owner zip code</label>'); 2202 // show_alert_msg('Please enter owner zip code'); 2203 $(btnObj).attr('disabled', false); 2204 } 2205 } 2206 $.ajax({ 2207 url: BASE_PATH + "/site/verify_captcha", 2208 type: "POST", 2209 data: { 2210 captcha: $("#cc_security #g-recaptcha-response").val(), 2211 action: $("#cc_security #action").val(), 2212 UserCaptcha: $("#cc_security #UserCaptcha").length ? $("#cc_security #UserCaptcha").val() : '', 2213 scode: $("#cc_security #UserCaptcha").length ? $("#cc_security #UserCaptcha").attr('data-val') : '' 2214 2215 }, 2216 success: function success(res) { 2217 2218 var obj = JSON.parse(res); 2219 if (Object.keys(obj).length > 1 && obj.success == true && obj.action && obj.score == captcha_threshold || Object.keys(obj).length == 1 && obj.success == true) { 2220 $('#btnSubmitPay').attr("disabled", true); 2221 pform_submit("FapsAuthForm"); 2222 } else { 2223 $(btnObj).attr('disabled', false); 2224 $('.creload:visible').trigger('click'); 2225 2226 prevent_cc_testing(); 2227 2228 $(".simple_security").fadeIn(); 2229 $(btnObj).attr('disabled', false); 2230 2231 if (obj.message) { 2232 $("#cc_security #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">' + obj.message + '</label>'); 2233 } else { 2234 $("#cc_security #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">Please enter the security code</label>'); 2235 } 2236 } 2237 } 2238 }); 2239 } 2240 2241 } 2242 } 2243 else if($("#paylaterAuthForm").length && $("#partial_and_click_to_pay").val()==1){ 2244 if($("#paylaterAuthForm").valid()){ 2245 var btnObj = this; 2246 $(btnObj).attr('disabled', true); 2247 $('#btnSubmitPay').attr("disabled", true); 2248 $.ajax({ 2249 url: BASE_PATH + "/site/verify_captcha", 2250 type: "POST", 2251 data: { 2252 captcha: $("#cc_security #g-recaptcha-response").val(), 2253 action: $("#cc_security #action").val(), 2254 UserCaptcha: $("#cc_security #UserCaptcha").length ? $("#cc_security #UserCaptcha").val() : '', 2255 scode: $("#cc_security #UserCaptcha").length ? $("#cc_security #UserCaptcha").attr('data-val') : '' 2256 2257 }, 2258 success: function success(res) { 2259 2260 var obj = JSON.parse(res); 2261 if (Object.keys(obj).length > 1 && obj.success == true && obj.action && obj.score == captcha_threshold || Object.keys(obj).length == 1 && obj.success == true) { 2262 $('#btnSubmitPay').attr("disabled", true); 2263 if($.trim($("#amountPayable_ship").attr("data-amount"))<=0){ 2264 $(".pl_error").html("Pay Later Amount should not be zero or empty!"); 2265 2266 }else{ 2267 2268 pform_submit("paylaterAuthForm"); 2269 2270 2271 // pform_submit("b2bPOPayAuthForm"); 2272 } 2273 2274 2275 } else { 2276 $(btnObj).attr('disabled', false); 2277 $('.creload:visible').trigger('click'); 2278 2279 prevent_cc_testing(); 2280 2281 $(".simple_security").fadeIn(); 2282 $(btnObj).attr('disabled', false); 2283 2284 if (obj.message) { 2285 $("#cc_security #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">' + obj.message + '</label>'); 2286 } else { 2287 $("#cc_security #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">Please enter the security code</label>'); 2288 } 2289 // if($.trim($("#b2b_po_number1").val())==''){ 2290 // $("#b2b_po_number1").after('<label id="b2b_po_number1-error" class="error" for="b2b_po_number">Please enter the PO number</label>'); 2291 2292 // } 2293 2294 } 2295 } 2296 }); 2297 2298 2299 } 2300 } 2301});
2302 2303$(document).on('click', '.btn_place_order', function() { 2304 $("#signin_signup").show(); 2305 $(".guest_acc").show(); 2306 $.ajax({ 2307 url: BASE_PATH + "/ajax/set_ref", 2308 success: function(result) {} 2309 }); 2310}); 2311$(document).on('click', '.guest_form_btn', function() { 2312 $("#signin_signup").hide(); 2313 window.location.href = BASE_PATH + "/checkout"; 2314}); 2315 2316function show_register_form(){ 2317 $("#span_sign_in").css("display","none"); 2318 $("#span_sign_up").css("display","block"); 2319 if($("#LoginInfoCreateAccountForm").length) 2320 { 2321 $("#LoginInfoCreateAccountForm .simple_security").hide(); 2322 if( !$('#LoginInfoCreateAccountForm #g-recaptcha-response').length ) 2323 $('#LoginInfoCreateAccountForm #action').after("<input type='hidden' id='g-recaptcha-response' name='g-recaptcha-response' value='' >"); 2324 reset_captcha(); 2325 } 2326} 2327 2328function show_signin_form() { 2329 $("#span_sign_in").css("display", "block"); 2330 $("#span_sign_up").css("display", "none"); 2331} 2332 2333function OpenForgotPass() { 2334 $("#forgot_password").show(); 2335} 2336 2337function hideshow(which) { 2338 $(which).hide(); 2339} 2340$(document).on('click', '#pickup_in_store', function() { 2341 cart.assignTotal(); 2342}); 2343 2344function shippingMethodChanged(e,free_ship_flag='') { 2345 //console.log(isNaN(e)); 2346 if( !isNaN(e)){ 2347 2348 if(Number(e)==0){var opt="free_shipping";} 2349 else if(Number(e)==1){var opt="flat_rate"} 2350 else if(Number(e)==2){var opt="price_based"} 2351 else if(Number(e)==5){var opt="local_delivery"} 2352 else if(Number(e)==3){var opt="pickup_in_store"} 2353 $("#hidden_free_shipping_flag").val(free_ship_flag); 2354 }else{ 2355 var opt = $(e).val(); 2356 } 2357 let subTotal = 0.0; 2358 let ship_cost = 0; 2359 subTotal = Number($("#hidden_subTotal").val()); 2360 2361 var shipObj = '' 2362 if($("#deliveryAmount_ship").length){ 2363 shipObj = $("#deliveryAmount_ship"); 2364 } 2365 if($("#shipping_price").length){ 2366 shipObj = $("#shipping_price"); 2367 } 2368 2369 2370 if($('#pickup_in_store').length && opt!="pickup_in_store") 2371 { 2372 $('#pickup_in_store').prop('checked',false); 2373 } 2374 if($('#free_shipping').length && opt!="free_shipping") 2375 { 2376 $('#free_shipping').prop('checked',false); 2377 } 2378 if($('#flat_rate').length && opt!="flat_rate") 2379 { 2380 $('#flat_rate').prop('checked',false); 2381 } 2382 if($('#price_based').length && opt!="price_based") 2383 { 2384 $('#price_based').prop('checked',false); 2385 } 2386 if($('#local_delivery').length && opt!="local_delivery") 2387 { 2388 $('#local_delivery').prop('checked',false); 2389 } 2390 if($('.ups_shipping').length) 2391 { 2392 $('.ups_shipping').prop('checked',false); 2393 } 2394 if($('#shipping_method_bug_fix').val() ==1 ) 2395 { 2396 if($('.ship_station_shipping').length) 2397 { 2398 $('.ship_station_shipping').prop('checked',false); 2399 } 2400 } 2401 else{ 2402 if($('.ship_station_shipping').length && $('#ship_station').val() ==1 ) 2403 { 2404 $('.ship_station_shipping').prop('checked',false); 2405 } 2406 } 2407 if($('#ship_station_firearm').val() ==1 ) 2408 { 2409 var tot = parseFloat($("#amountPayable_ship").attr("data-amount")); 2410 var fire_ship = $('#firearm_shipment_rate').val(); 2411 } 2412 $.ajax({ 2413 url: BASE_PATH+"/api/getShippingCost", 2414 method: 'post', 2415 data: { 2416 "shipping_method":opt, 2417 'free_shipping_flag': $("#hidden_free_shipping_flag").val() 2418 }, 2419 success: function(result){ 2420 var json = $.parseJSON(result); 2421 if($('#ship_station_firearm').val() ==1 ) 2422 { 2423 var shipping = json.shipping_price; 2424 var dynamic_ship = shipping.replace('$', ''); 2425 var fire_ship = parseFloat($('#firearm_shipment_rate').val()) || 0; 2426 var totalnew = parseFloat(tot)+parseFloat(fire_ship)+parseFloat(dynamic_ship); 2427 var ship = parseFloat(fire_ship)+parseFloat(dynamic_ship); 2428 2429 $("#amountPayable_ship").html('$'+totalnew.toFixed(2)); 2430 $('#non_firearm_shipment_rate').val(dynamic_ship); 2431 $("#shipping_price").html('$'+ship.toFixed(2)); 2432 $("#shipping_price").attr("data-amount",ship.toFixed(2)); 2433 if($('#ffl_online_pickup_firearm_review_invoice').val() ==1 ) 2434 { 2435 2436 var ship_new = parseFloat(dynamic_ship); 2437 var fire_ship = $("#firearm_shipment_rate").val(); 2438 if(fire_ship > 0 && fire_ship != undefined){ 2439 ship_new += parseFloat(fire_ship); 2440 } 2441 $("#deliveryAmount_ship").html('$'+ship_new.toFixed(2)); 2442 } 2443 else if($('#northwest_shipping_issue').val() ==1 ) 2444 { 2445 $("#deliveryAmount_ship").html('$'+ship.toFixed(2)); 2446 } 2447 if($('#ffl_online_pickup_firearm_review_invoice').val() ==1 ){ 2448 $("#deliveryAmount_ship").attr("data-amount",ship_new.toFixed(2)); 2449 } 2450 else if($('#b2b_shipping_charge_fix').val() ==1 ){ 2451 $("#deliveryAmount_ship").attr("data-amount",ship.toFixed(2)); 2452 } 2453 }else{ 2454 $("#amountPayable_ship").html(json.total); 2455 shipObj.html(json.shipping_price); 2456 } 2457 if($('#ship_station_network_issue').val() ==1 ) 2458 { 2459 $('#shipping_ahref').fadeIn('slow'); 2460 $('#shipstation_preloader').hide(); 2461 } 2462 if($("#avalara_tax_not_calculating_issue").val() == 1) 2463 { 2464 if(json.cost_summary.taxTotal > 0 && json.cost_summary.taxTotal != undefined){ 2465 $("#cart_tax").html('$'+json.cost_summary.taxTotal.toFixed(2)); 2466 $("#cart_tax").attr("data-amount",json.cost_summary.taxTotal.toFixed(2)); 2467 $("#amountPayable_ship").html(json.total); 2468 var total_price_new = json.total; 2469 var amountPayable_ship = total_price_new.replace(/($|\$|\s)/g, ''); 2470 var amoun_tot = parseFloat(amountPayable_ship) || 0; 2471 $("#amountPayable_ship").attr("data-amount",amoun_tot.toFixed(2)); 2472 if($("#ffl_online_pickup_firearm_review_invoice").val() == 1){ 2473 var fire_ship = $('#firearm_shipment_rate').val(); 2474 var online_transfer_fee = $("#online_transfer_fee_value").html() || ''; 2475 var online_transfer_fee_new = parseFloat(online_transfer_fee.replace(/($|\$|\s)/g, '')) || 0; 2476 2477 if(online_transfer_fee_new > 0){ 2478 var total_online_new = parseFloat(amoun_tot)+parseFloat(online_transfer_fee_new); 2479 if(fire_ship > 0 && fire_ship != undefined) { 2480 total_online_new += parseFloat(fire_ship); 2481 } 2482 $("#amountPayable_ship").html('$'+parseFloat(total_online_new).toFixed(2)); 2483 $("#amountPayable_ship").attr("data-amount", parseFloat(total_online_new).toFixed(2)); 2484 } 2485 } 2486 } 2487 } 2488 } 2489 }); 2490} 2491 2492function shippingMethodChangedFirearm(e,free_ship_flag='') { 2493 if($('#ship_station_firearm').val() ==1 ) 2494 { 2495 var tot = parseFloat($("#amountPayable_ship").attr("data-amount")); 2496 if(!isNaN(e)){ 2497 if(Number(e)==0){var opt="free_shipping_firearm";} 2498 else if(Number(e)==1){var opt="flat_rate_firearm"} 2499 else if(Number(e)==2){var opt="price_based_firearm"} 2500 else if(Number(e)==5){var opt="local_delivery_firearm"} 2501 else if(Number(e)==3){var opt="pickup_in_store_firearm"} 2502 $("#hidden_free_shipping_flag").val(free_ship_flag); 2503 }else{ 2504 var opt = $(e).val(); 2505 } 2506 let subTotal = 0.0; 2507 let ship_cost = 0; 2508 subTotal = Number($("#hidden_subTotal").val()); 2509 2510 var shipObj = '' 2511 if($("#deliveryAmount_ship").length){ 2512 shipObj = $("#deliveryAmount_ship"); 2513 } 2514 if($("#shipping_price").length){ 2515 shipObj = $("#shipping_price"); 2516 } 2517 if($('#pickup_in_store_firearm').length && opt!="pickup_in_store_firearm") 2518 {
2519 $('#pickup_in_store_firearm').prop('checked',false); 2520 } 2521 if($('#free_shipping_firearm').length && opt!="free_shipping_firearm") 2522 { 2523 $('#free_shipping_firearm').prop('checked',false); 2524 } 2525 if($('#flat_rate_firearm').length && opt!="flat_rate_firearm") 2526 { 2527 $('#flat_rate_firearm').prop('checked',false); 2528 } 2529 if($('#price_based_firearm').length && opt!="price_based_firearm") 2530 { 2531 $('#price_based_firearm').prop('checked',false); 2532 } 2533 if($('#local_delivery_firearm').length && opt!="local_delivery_firearm") 2534 { 2535 $('#local_delivery_firearm').prop('checked',false); 2536 } 2537 if($('.ship_station_shipping_firearm').length) 2538 { 2539 $('.ship_station_shipping_firearm').prop('checked',false); 2540 } 2541 if($('#ups_integration').val() ==1 ) 2542 { 2543 if($('.ups_shipping_firearm').length) 2544 { 2545 $('.ups_shipping_firearm').prop('checked',fal
2545se); 2546 } 2547 } 2548 2549 if(opt=='free_shipping_firearm'){ 2550 $('#free_shipping_firearm').prop('checked',true); 2551 } 2552 if(opt=='flat_rate_firearm'){ 2553 $('#flat_rate_firearm').prop('checked',true); 2554 } 2555 if(opt=='price_based_firearm'){ 2556 $('#price_based_firearm').prop('checked',true); 2557 } 2558 if(opt=='local_delivery_firearm'){ 2559 $('#local_delivery_firearm').prop('checked',true); 2560 } 2561 if(opt=='local_delivery_firearm'){ 2562 $('#local_delivery_firearm').prop('checked',true); 2563 } 2564 if(opt=='pickup_in_store_firearm'){ 2565 $('#pickup_in_store_firearm').prop('checked',true); 2566 } 2567 2568 } 2569 2570 $.ajax({ 2571 url: BASE_PATH+"/api/getShippingCostFirearm", 2572 method: 'post', 2573 data: { 2574 "shipping_method_firearm":opt, 2575 'free_shipping_flag': $("#hidden_free_shipping_flag").val(), 2576 "is_firearm":1 2577 }, 2578 success: function(result){ 2579 var json = $.parseJSON(result); 2580 2581 var shipping = json.shipping_price_firearm; 2582 var dynamic_ship = shipping.replace('$', ''); 2583 var non_fire_ship = $('#non_firearm_shipment_rate').val(); 2584 2585 var totalnew = parseFloat(tot)+parseFloat(non_fire_ship)+parseFloat(dynamic_ship); 2586 var ship = parseFloat(non_fire_ship)+parseFloat(dynamic_ship); 2587 2588 $("#amountPayable_ship").html('$'+totalnew.toFixed(2)); 2589 $('#firearm_shipment_rate').val(dynamic_ship); 2590 $("#shipping_price").html('$'+ship.toFixed(2)); 2591 $("#shipping_price").attr("data-amount",ship.toFixed(2)); 2592 if($('#b2b_shipping_charge_fix').val() ==1 ){ 2593 $("#deliveryAmount_ship").html('$'+ship.toFixed(2)); 2594 $("#deliveryAmount_ship").attr("data-amount",ship.toFixed(2)); 2595 } 2596 if($('#ship_station_network_issue').val() ==1 ) 2597 { 2598 $('#shipping_ahref').fadeIn('slow'); 2599 $('#shipstation_preloader').hide(); 2600 } 2601 if($("#avalara_tax_not_calculating_issue").val() == 1) 2602 { 2603 if(json.cost_summary_firearm.taxTotal > 0 && json.cost_summary_firearm.taxTotal != undefined){ 2604 $("#cart_tax").html('$'+json.cost_summary_firearm.taxTotal.toFixed(2)); 2605 $("#cart_tax").attr("data-amount",json.cost_summary_firearm.taxTotal.toFixed(2)); 2606 2607 $("#amountPayable_ship").html(json.total_firearm); 2608 var total_price_new = json.total_firearm; 2609 var amountPayable_ship = total_price_new.replace(/($|\$|\s)/g, ''); 2610 var amoun_tot = parseFloat(amountPayable_ship) || 0; 2611 $("#amountPayable_ship").attr("data-amount",amoun_tot.toFixed(2)); 2612 2613 if($("#ffl_online_pickup_firearm_review_invoice").val() == 1){ 2614 var online_transfer_fee = $("#online_transfer_fee_value").html() || ''; 2615 var non_fire_ship = $('#non_firearm_shipment_rate').val(); 2616 var online_transfer_fee_new = parseFloat(online_transfer_fee.replace(/($|\$|\s)/g, '')) || 0; 2617 if(online_transfer_fee_new > 0){ 2618 var total_online_new = parseFloat(amoun_tot)+parseFloat(online_transfer_fee_new); 2619 if(non_fire_ship > 0 && non_fire_ship != undefined){ 2620 total_online_new += parseFloat(non_fire_ship); 2621 } 2622 $("#amountPayable_ship").html('$'+parseFloat(total_online_new).toFixed(2)); 2623 $("#amountPayable_ship").attr("data-amount", parseFloat(total_online_new).toFixed(2)); 2624 } 2625 } 2626 } 2627 } 2628 } 2629 }); 2630} 2631 2632function addCommas(nStr) { 2633 nStr += ''; 2634 var x = nStr.split('.'); 2635 var x1 = x[0]; 2636 var x2 = x.length > 1 ? '.' + x[1] : ''; 2637 var rgx = /(\d+)(\d{3})/; 2638 while (rgx.test(x1)) { 2639 x1 = x1.replace(rgx, '$1' + ',' + '$2'); 2640 } 2641 return x1 + x2; 2642} 2643 2644$(document).on('click', '.alert_place_order', function() { 2645 $("#go-top").trigger("click"); 2646 cart.showAlert('One or more reservations in your cart has expired. Please add the reservation details again to proceed', 'danger'); 2647}); 2648 2649if ($("#CustomerInfoState").length) { 2650 2651} 2652$(document).ready(function() { 2653 if ($("#CustomerInfoState").length) { 2654 $("#CustomerInfoState").trigger("change"); 2655 } 2656}); 2657$(document).on('change', '#CustomerInfoState', function() { 2658 var state = $(this).val(); 2659 var cart_tax = parseFloat($("#cart_tax").attr('data-amount')); 2660 var amountPayable_ship = parseFloat($("#amountPayable_ship").attr("data-amount")); 2661 var cart_subtotal = parseFloat($("#cart_subtotal").attr("data-amount")); 2662 2663 var amountPayable_ship1 = ''; 2664 var tt_exempt = 0; 2665 if (state != '' && state != store_home_state && exempt_tax_out_state == 1) { 2666 amountPayable_ship1 = amountPayable_ship - cart_tax; 2667 cart_tax = 0; 2668 tt_exempt = 1; 2669 } else { 2670 amountPayable_ship1 = amountPayable_ship; 2671 } 2672 2673 var charter_travel = {}; 2674 $(".charter_travel").each(function() { 2675 var ct_id = $(this).attr("id"); 2676 var ct_tax = parseFloat($(this).attr("data-tax")); 2677 var ct_amount = parseFloat($(this).attr("data-amount")); 2678 charter_travel[ct_id] = {}; 2679 charter_travel[ct_id].tax = ct_tax; 2680 charter_travel[ct_id].amount = ct_amount; 2681 }); 2682 2683 $.ajax({ 2684 url: BASE_PATH + "/ajax/set_currency", 2685 method: 'post', 2686 data: { 2687 "tax": cart_tax, 2688 "total": amountPayable_ship1, 2689 "sub": cart_subtotal, 2690 'charter_travel': charter_travel, 2691 "exempt_tax_out_state": tt_exempt 2692 }, 2693 success: function(result) { 2694 var json = $.parseJSON(result); 2695 if (json.charter_travel) { 2696 $.each(json.charter_travel, function(i, part) { 2697 $("#" + i).html($("#" + i).attr('data-count') + " x " + part.amount); 2698 }); 2699 } 2700 if ($("#cart_tax").length) { 2701 $("#cart_tax").html(json.tax); 2702 } 2703 $("#amountPayable_ship").html(json.total); 2704 $("#cart_subtotal").html(json.sub); 2705 } 2706 }); 2707 2708}); 2709 2710function proceed_pay_validate() 2711{ 2712 var CustomerInfoShippingForm_validate = $("#CustomerInfoShippingForm:visible").validate().checkForm(); 2713 if( CustomerInfoShippingForm_validate == true) 2714 { 2715 if($("#CustomerInfoShippingForm:visible #UserCaptcha").length) 2716 { 2717 $('.proceed_pay').attr('disabled',true); 2718 $.ajax({ 2719 url:BASE_PATH+"/site/verify_captcha", 2720 type:"POST", 2721 data: { 2722 captcha:$("#CustomerInfoShippingForm #g-recaptcha-response").val(), 2723 action: $("#CustomerInfoShippingForm #action").val(), 2724 UserCaptcha : ($("#CustomerInfoShippingForm #UserCaptcha").length)?$("#CustomerInfoShippingForm #UserCaptcha").val():'', 2725 scode : ($("#CustomerInfoShippingForm #UserCaptcha").length)?$("#CustomerInfoShippingForm #UserCaptcha").attr('data-val'):'' 2726 2727 }, 2728 success:function(res){ 2729 reset_captcha(); 2730 var obj = JSON.parse(res); 2731 if( (Object.keys(obj).length>1 && obj.success==true && obj.action && obj.score==captcha_threshold) || 2732 (Object.keys(obj).length==1 && obj.success==true) 2733 ) 2734 { 2735 $("#CustomerInfoShippingForm #g-recaptcha-response").val(''); 2736 if($('.proceed_pay').length>0){ 2737 //$('.proceed_pay').html("Proceed to Shipping"); 2738 $('.proceed_pay').prop('disabled', false); 2739 } 2740 $("#CustomerInfoShippingForm").submit(); 2741 } 2742 else 2743 { 2744 $("#CustomerInfoShippingForm:visible .simple_security").fadeIn(); 2745 $('.proceed_pay').attr('disabled',false); 2746 $('.creload:visible').trigger('click'); 2747 if(pwd_cap_error==true){ 2748 if(($("#remove_duplicitous_shipping_address_step").length>0 && $("#remove_duplicitous_shipping_address_step").val()==1)) //FeatureTag 2749 { 2750 $("#CustomerInfoShippingForm:visible").find("#usercaptcha-error").remove(); 2751 } 2752 2753 if(obj.message){ 2754 $("#CustomerInfoShippingForm #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">'+obj.message+'</label>'); 2755 }else{ 2756 $("#CustomerInfoShippingForm #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">Please enter the security code</label>'); 2757 } 2758 }else{ 2759 2760 if(obj.message){ 2761 $("#CustomerInfoShippingForm #UserCaptchaContactCreate").after('<label id="usercaptcha-error" class="error" for="UserCaptchaContactCreate">'+obj.message+'</label>'); 2762 }else{ 2763 $("#CustomerInfoShippingForm #UserCaptchaContactCreate").after('<label id="usercaptcha-error" class="error" for="UserCaptchaContactCreate">Please enter the security code</label>'); 2764 } 2765 2766 pwd_cap_error = true; 2767 } 2768 } 2769 } 2770 }); 2771 }else{ 2772 var cust_form = 'CustomerInfoShippingForm'; 2773 if(!$("#" + cust_form).validate().checkForm()){ 2774 if($('.proceed_pay').length>0){ 2775 //$('.proceed_pay').html("Proceed to Shipping"); 2776 $('.proceed_pay').prop('disabled', false); 2777 } 2778 } 2779 $("#" + cust_form).submit(); 2780 } 2781 }else{ 2782 $('.proceed_pay').attr('disabled',false); 2783 var cust_form = 'CustomerInfoShippingForm'; 2784 if(!$("#" + cust_form).validate().checkForm()){ 2785 if($('.proceed_pay').length>0){ 2786 //$('.proceed_pay').html("Proceed to Shipping"); 2787 $('.proceed_pay').prop('disabled', false); 2788 } 2789 } 2790 $("#" + cust_form).submit(); 2791 } 2792 if(($("#remove_duplicitous_shipping_address_step").length>0 && $("#remove_duplicitous_shipping_address_step").val()==1)) //FeatureTag 2793 { 2794 $("#CustomerInfoShippingForm:visible").find("#usercaptcha-error").remove(); 2795 if($("#CustomerInfoShippingForm:visible #UserCaptcha").val()=='') 2796 { 2797 $("#CustomerInfoShippingForm:visible #UserCaptcha").after('<label id="usercaptcha-error" class="error" for="usercaptcha">Please enter the security code</label>'); 2798 } 2799 } 2800} 2801 2802 2803 2804 2805$(document).on('click', '.proceed_pay ', function() { 2806 //$(".proceed_pay").html("<img src='"+BASE_PATH+"/img/loading1.gif'>Loading..."); 2807 $(this).prop('disabled', true); 2808 setTimeout(function() 2809 { 2810 var ca_compliance_enhancements = $("#ca_compliance_enhancements").val(); 2811 var ffl_online_pickup_firearm_review_invoice_tag = $("#ffl_online_pickup_firearm_review_invoice").val(); 2812 var ffl_dropshipping_enabled_tag = $("#ffl_dropshipping_enabled").val(); 2813 // let read_cart4= cart.readCookie(); 2814 if(localStorage.est_dssf_cart && localStorage.getItem('est_dssf_cart').length > 0){ 2815 let read_cart4 = JSON.parse(localStorage.getItem('est_dssf_cart')); 2816 let yet_to_cert_cnts=0; 2817 2818 for (let key in read_cart4) { 2819 if((read_cart4[key]['comp_status']==2 || read_cart4[key]['comp_status']==3)&&read_cart4[key]['comp_certify']==0){ 2820 yet_to_cert_cnts = yet_to_cert_cnts+1; 2821 } 2822 2823 } 2824 if(yet_to_cert_cnts>0 || $("#remove_cert_id").val()==1){ 2825 console.log("existtt") 2826 return false;
2827 } 2828 } 2829 2830 var cust_form = 'CustomerInfoShippingForm'; 2831 if ($("#" + cust_form).attr('data-token') != '') { 2832 $("#" + cust_form).attr('action', '/checkout/payment/' + $("#" + cust_form).attr('data-token')); 2833 } 2834 2835 if ($(".ck_email").length > 0 && $(".ck_email").val() != '') { 2836 $.ajax({ 2837 url: BASE_PATH + "/site/checkEmail", 2838 type: "post", 2839 async: false, 2840 data: { 2841 email_id: function() { 2842 return $("#CustomerInfoEmail").val(); 2843 } 2844 }, 2845 success: function(msg) { 2846 if ($.trim(msg) == "false") { 2847 $("#signin_signup").show(); 2848 } else { 2849 if(ca_compliance_enhancements == 1){ 2850 check_ca_sales(); 2851 } else { 2852 if($('#estate_ammo_and_orchid_ecommerce_integration').val() == 1 && $('#estate_flag_new').val() == 1){ 2853 check_estate_compliance(); 2854 } else { 2855 if(ffl_online_pickup_firearm_review_invoice_tag == 1){ 2856 check_ffl_online_transfer_fee(); 2857 } else { 2858 proceed_pay_validate(); 2859 } 2860 } 2861 } 2862 } 2863 } 2864 }); 2865 } else { 2866 if(ca_compliance_enhancements == 1){ 2867 check_ca_sales(); 2868 } else { 2869 if($('#estate_ammo_and_orchid_ecommerce_integration').val() == 1 && $('#estate_flag_new').val() == 1){ 2870 check_estate_compliance(); 2871 } else { 2872 if(ffl_online_pickup_firearm_review_invoice_tag == 1){ 2873 check_ffl_online_transfer_fee(); 2874 } else { 2875 proceed_pay_validate(); 2876 } 2877 } 2878 } 2879 2880 } 2881 },1000); 2882}); 2883function htmlDecode(input) { 2884 var doc = new DOMParser().parseFromString(input, "text/html"); 2885 return doc.documentElement.textContent; 2886} 2887$(document).on('change', '.ck_fname, .ck_lname, .ck_email ', function() { 2888 var dssf_tmp_id = this.value; 2889 if (dssf_tmp_id != 'new') { 2890 var data_type = $(this).attr("data-type"); 2891 if (data_type == 'fname') { 2892 $(".ck_lname").val(dssf_tmp_id); 2893 $(".ck_email").val(dssf_tmp_id); 2894 } else if (data_type == "lname") { 2895 $(".ck_fname").val(dssf_tmp_id); 2896 $(".ck_email").val(dssf_tmp_id); 2897 } else if (data_type == "email") { 2898 $(".ck_fname").val(dssf_tmp_id); 2899 $(".ck_lname").val(dssf_tmp_id); 2900 } 2901 $("#CustomerInfoFirstName").val(htmlDecode($(".ck_fname").find("option:selected").html())).attr("type", "hidden"); 2902 $("#CustomerInfoLastName").val(htmlDecode($(".ck_lname").find("option:selected").html())).attr("type", "hidden"); 2903 if ($(".ck_email").val() != null) { 2904 $("#CustomerInfoEmail").val($(".ck_email").find("option:selected").html()).attr("type", "hidden"); 2905 $(".ck_email").removeClass("hide"); 2906 2907 var res = $("#CustomerInfoEmail").val().split(" ("); 2908 $("#CustomerInfoEmail").val(res[0]); 2909 2910 $.ajax({ 2911 url: BASE_PATH + "/site/checkEmail", 2912 type: "post", 2913 async: false, 2914 data: { 2915 email_id: function() { 2916 return $("#CustomerInfoEmail").val(); 2917 } 2918 }, 2919 success: function(msg) { 2920 if ($.trim(msg) == "false") { 2921 $("#signin_signup").show(); 2922 } 2923 } 2924 }); 2925 } else { 2926 $("#CustomerInfoEmail").attr("type", "text").val(''); 2927 $(".ck_email").addClass("hide"); 2928 } 2929 2930 2931 $("#CustomerInfoDssfTmpId").val(dssf_tmp_id).attr("type", "hidden"); 2932 if ($("#CreditCardFirstName").length > 0) { 2933 $("#CreditCardFirstName").attr("type", 'hidden').val($(".ck_fname").find("option:selected").html()); 2934 } 2935 if ($("#CreditCardLastName").length > 0) { 2936 $("#CreditCardLastName").attr("type", 'hidden').val($(".ck_fname").find("option:selected").html()); 2937 } 2938 } else { 2939 $("#CustomerInfoDssfTmpId").val(''); 2940 $(".ck_fname").remove(); 2941 $(".ck_lname").remove(); 2942 $(".ck_email").remove(); 2943 $("#CustomerInfoFirstName").attr("type", 'text').val(''); 2944 $("#CustomerInfoLastName").attr("type", 'text').val(''); 2945 $("#CustomerInfoEmail").attr("type", 'text').val(''); 2946 if ($("#CreditCardFirstName").length > 0) { 2947 $("#CreditCardFirstName").attr("type", 'text').val(''); 2948 $("#CreditCardLastName").attr("type", 'text').val(''); 2949 } 2950 } 2951 2952}); 2953 2954 2955$(document).ready(function() { 2956 $(".gc_amt_btn").click(function() { 2957 $(".gc_amt_btn").removeClass('gc-form-selected-btn'); 2958 $(this).addClass('gc-form-selected-btn'); 2959 2960 });
2961 var gift_certificate_add_issue_fixing_tag=$("#gift_certificate_add_issue_fixing").val(); 2962 if(gift_certificate_add_issue_fixing_tag==1){ 2963 $(document).on('click', '#add_to_cart_gc', function() { 2964 2965 $("#add_to_cart_gc").attr("disabled", true); 2966 if ($("#gc_to_amount").val() == '' || $("#gc_to_amount").val() == 0) { 2967 if ($("#gc-amt-error").length == 0) 2968 { 2969 if($("#custom_gc_amount").length>0){ 2970 $("#gc_to_amount").after('<label id="gc-amt-error" style="color:#f00;font-weight:bold;">Please choose or enter gift card amount.</label>'); 2971 }else{ 2972 $("#gc_to_amount").after('<label id="gc-amt-error" style="color:#f00;font-weight:bold;">Please choose gift card amount.</label>'); 2973 } 2974 } 2975 2976 $("#add_to_cart_gc").attr("disabled", false); 2977 return false; 2978 } else { 2979 $("#gc-amt-error").remove(); 2980 } 2981 2982 if ($("#gc_to_amount").val() < 1) { 2983 $("#gc_to_amount").after('<label id="gc-amt-error" style="color:#f00;font-weight:bold;">Gift card amount should be greater than 1.</label>'); 2984 $("#add_to_cart_gc").attr("disabled", false); 2985 return false; 2986 } 2987 2988 if ($("#gc_form").valid()) { 2989 var count = $("#gc_qty").val(); 2990 let params = { 2991 handle: $(this).attr('data-handle'), 2992 part_type: 'GiftCertificate' 2993 }; 2994 var formdata = $("#gc_form").serializeArray(); 2995 $(formdata).each(function(index, obj) { 2996 params[obj.name] = obj.value; 2997 }); 2998 var gc_unique_id = new Date().valueOf(); 2999 params['gc_unique_id'] = gc_unique_id; 3000 3001 xhr.call('getPartDetails', params, 'POST') 3002 .then(function(data) { 3003 if (data.status) { 3004 3005 $.notify({ 3006 from: "bottom", 3007 title: "<strong></strong> ", 3008 icon: 'glyphicon glyphicon-shopping-cart', 3009 message: "Added to your cart successfully...!" 3010 }, { 3011 timer: 1000, 3012 type: 'success', 3013 animate: { 3014 enter: 'animated lightSpeedIn', 3015 exit: 'animated lightSpeedOut' 3016 } 3017 }); 3018 3019 data.data.count = count; 3020 data.data.price = $("#gc_to_amount").val(); 3021 data.data.gc_unique_id = gc_unique_id; 3022 cart.addPart(data.data); 3023 var part_cart_interval = setInterval(function () { 3024 if(cart_l>0) 3025 { 3026 clearInterval(part_cart_interval); 3027 window.location.href = BASE_PATH + '/cart'; 3028 } 3029 },1000); 3030 3031 } 3032 }); 3033 return false; 3034 } else { 3035 $("#add_to_cart_gc").attr("disabled", false); 3036 } 3037 3038 }); 3039 }else{ 3040 $("#add_to_cart_gc").click(function() { 3041 $("#add_to_cart_gc").attr("disabled", true); 3042 if ($("#gc_to_amount").val() == '' || $("#gc_to_amount").val() == 0) { 3043 if ($("#gc-amt-error").length == 0) 3044 { 3045 if($("#custom_gc_amount").length>0){ 3046 $("#gc_to_amount").after('<label id="gc-amt-error" style="color:#f00;font-weight:bold;">Please choose or enter gift card amount.</label>'); 3047 }else{ 3048 $("#gc_to_amount").after('<label id="gc-amt-error" style="color:#f00;font-weight:bold;">Please choose gift card amount.</label>'); 3049 } 3050 } 3051 3052 $("#add_to_cart_gc").attr("disabled", false); 3053 return false;
3054 } else { 3055 $("#gc-amt-error").remove(); 3056 } 3057 3058 if ($("#gc_to_amount").val() < 1) { 3059 $("#gc_to_amount").after('<label id="gc-amt-error" style="color:#f00;font-weight:bold;">Gift card amount should be greater than 1.</label>'); 3060 $("#add_to_cart_gc").attr("disabled", false); 3061 return false; 3062 } 3063 3064 if ($("#gc_form").valid()) { 3065 var count = $("#gc_qty").val(); 3066 let params = { 3067 handle: $(this).attr('data-handle'), 3068 part_type: 'GiftCertificate' 3069 }; 3070 var formdata = $("#gc_form").serializeArray(); 3071 $(formdata).each(function(index, obj) { 3072 params[obj.name] = obj.value; 3073 }); 3074 var gc_unique_id = new Date().valueOf(); 3075 params['gc_unique_id'] = gc_unique_id; 3076 3077 xhr.call('getPartDetails', params, 'POST') 3078 .then(function(data) { 3079 if (data.status) { 3080 3081 $.notify({ 3082 from: "bottom", 3083 title: "<strong></strong> ", 3084 icon: 'glyphicon glyphicon-shopping-cart', 3085 message: "Added to your cart successfully...!" 3086 }, { 3087 timer: 1000, 3088 type: 'success', 3089 animate: { 3090 enter: 'animated lightSpeedIn', 3091 exit: 'animated lightSpeedOut' 3092 } 3093 }); 3094 3095 data.data.count = count; 3096 data.data.price = $("#gc_to_amount").val(); 3097 data.data.gc_unique_id = gc_unique_id; 3098 cart.addPart(data.data); 3099 var part_cart_interval = setInterval(function () { 3100 if(cart_l>0) 3101 { 3102 clearInterval(part_cart_interval); 3103 window.location.href = BASE_PATH + '/cart'; 3104 } 3105 },1000); 3106 3107 } 3108 }); 3109 return false; 3110 } else { 3111 $("#add_to_cart_gc").attr("disabled", false); 3112 } 3113 3114 }); 3115 } 3116 }); 3117 3118$(document).ready(function(){ 3119 checkout_buttons(); 3120}); 3121function checkout_buttons() 3122{ 3123 if($(".item_not_available").length>0) 3124 { 3125 3126 if (CONTROLL == "checkout" && ACTION == "index" ) 3127 { 3128 $(".proceed_pay").attr("disabled",true); 3129 } 3130 else if(CONTROLL == "checkout" && ACTION == "shipping") 3131 { 3132 $('#shipping_ahref').attr('disabled',true); 3133 } 3134 else if(CONTROLL == "checkout" && ACTION == "payment") 3135 { 3136 $('#btnSubmitPay').attr('disabled',true); 3137 } 3138 else if (CONTROLL == "products" && ACTION == "cart" ) 3139 { 3140 if($(".btn_place_order").length>0) 3141 { 3142 $(".btn_place_order").attr("disabled",true); 3143 } 3144 else if($("#place_order").length>0) 3145 { 3146 $("#place_order").attr("disabled",true); 3147 } 3148 } 3149 if (CONTROLL == "checkout") 3150 { 3151 setTimeout(function(){ 3152 3153 $.notify({ 3154 title: "", 3155 icon: 'glyphicon glyphicon-cart', 3156 message: "Please edit your cart and try again." 3157 }, { 3158 offset: { 3159 x: 50, 3160 y: 200 3161 }, 3162 timer: 1000, 3163 type: 'danger', 3164 animate: { 3165 enter: 'animated lightSpeedIn', 3166 exit: 'animated lightSpeedOut' 3167 } 3168 }); 3169 3170 },1000); 3171 } 3172 } 3173} 3174function addToCartReplace(handle, count, cInv,pkg_replace,pkg_price,pkg_replace_price) { 3175 var e = document.getElementById("numProductQty"); 3176 var isValid = false;
3177 if($('#sf_new_package_variants').val() == 1){ 3178 isValid = (!cInv || !e) ? true : e.validity.valid; 3179 }else{ 3180 isValid = (!cInv) ? true : e.validity.valid; 3181 } 3182 if(handle && isValid) { 3183 let params = {handle: handle,part_type:'product'}; 3184 xhr.call('getPartDetails', params, 'POST') 3185 .then(function(data) { 3186 if(data.status) { 3187 data.data.count = count; 3188 data.data.pkg_replace = pkg_replace; 3189 if(pkg_price!='') 3190 { 3191 data.data.price = pkg_price; 3192 } 3193 data.data.pkg_replace_price = pkg_replace_price; 3194 cart.addPart(data.data); 3195 var part_cart_interval = setInterval(function () { 3196 if(cart_l>0) 3197 { 3198 clearInterval(part_cart_interval); 3199 $.notify({ 3200 from: "bottom", 3201 title: "<strong></strong> ", 3202 icon: 'glyphicon glyphicon-shopping-cart', 3203 message: "Added to your cart successfully...!" 3204 },{timer: 1000,type: 'success',animate: {enter: 'animated lightSpeedIn',exit: 'animated lightSpeedOut'}}); 3205 3206 window.location.reload(); 3207 } 3208 },1000); 3209 } 3210 }); 3211 3212 }else if(!e.validity.valid) { 3213 3214 $.notify({ 3215 title: "<strong></strong> ", 3216 icon: 'glyphicon glyphicon-shopping-cart', 3217 message: "Insufficient Quantity!" 3218 },{timer: 1000,type: 'danger',animate: {enter: 'animated lightSpeedIn',exit: 'animated lightSpeedOut'}}); 3219 3220 cart.showAlert('Insufficient Quantity!', 'danger'); 3221 location.reload(); 3222 }else { 3223 3224 $.notify({ 3225 title: "<strong></strong> ", 3226 icon: 'glyphicon glyphicon-shopping-cart', 3227 message: "Unable to add product to cart!" 3228 },{timer: 1000,type: 'dangert',animate: {enter: 'animated lightSpeedIn',exit: 'animated lightSpeedOut'}}); 3229 3230 cart.showAlert('Unable to add product to cart!', 'danger'); 3231 } 3232} 3233 3234if (CONTROLL == "checkout" && (ACTION == "payment" || ACTION == "confirm") ) 3235{ 3236 (function (global) { 3237 if(typeof (global) === "undefined") 3238 { 3239 throw new Error("window is undefined"); 3240 } 3241 var _hash = "!"; 3242 var noBackPlease = function () { 3243 global.location.href += "#"; 3244 global.setTimeout(function () { 3245 global.location.href += "!"; 3246 }, 50); 3247 }; 3248 global.onhashchange = function () { 3249 if (global.location.hash !== _hash) { 3250 global.location.hash = _hash; 3251 } 3252 }; 3253 global.onload = function () { 3254 noBackPlease(); 3255 document.body.onkeydown = function (e) { 3256 var elm = e.target.nodeName.toLowerCase(); 3257 if (e.which === 8 && (elm !== 'input' && elm !== 'textarea')) { 3258 e.preventDefault(); 3259 } 3260 e.stopPropagation(); 3261 }; 3262 3263 }; 3264 })(window); 3265} 3266 3267 3268$(document).on('click', '.remove_coupon_sale_tax ', function() { 3269 var c_id = $(this).attr('data-coupon'); 3270 var c_id1 = $(this).attr('data-id'); 3271 $("#coupon_" + c_id1).remove(); 3272 $.ajax({ 3273 url: BASE_PATH + "/api/remove_coupon_sale_tax", 3274 type: "post", 3275 async: false, 3276 data: { 3277 'coupon_code': c_id, 3278 'total': $("#amountPayable_ship").attr("data-amount") 3279 }, 3280 success: function(result) { 3281 var obj = jQuery.parseJSON(result); 3282 $("#amountPayable_ship").attr("data-amount", obj.total).html(obj.tot_label); 3283 $("#coupon_value").html(obj.reward_val_label); 3284 $("#coupon_value").attr("data-amount", obj.reward_value); 3285 $("#coupon_code").attr('readonly', false); 3286 3287 $.notify({ 3288 from: "bottom", 3289 title: "<strong></strong> ", 3290 icon: 'glyphicon glyphicon-tags', 3291 message: ' Coupon removed successfully...!' 3292 }, { 3293 timer: 1000, 3294 type: 'success', 3295 animate: { 3296 enter: 'animated lightSpeedIn', 3297 exit: 'animated lightSpeedOut' 3298 } 3299 }); 3300 3301 if($('#setting_option_to_define_coupon_usage_limit_per_order').val() == 1){ 3302 check_coupon_usage_limit_per_order(); 3303 } 3304 3305 } 3306 }); 3307}); 3308 3309 3310$(document).on('click', '.remove_coupon ', function() { 3311 var c_id = $(this).attr('data-coupon'); 3312 var c_id1 = $(this).attr('data-id'); 3313 $("#coupon_" + c_id1).remove(); 3314 if($("#faps_manual_payment_capture").val() == 1){ 3315 resetSurchargeValue(); 3316 } 3317 $.ajax({ 3318 url: BASE_PATH + "/api/remove_coupon", 3319 type: "post", 3320 async: false, 3321 data: { 3322 'coupon_code': c_id, 3323 'total': $("#amountPayable_ship").attr("data-amount") 3324 }, 3325 success: function(result) { 3326 var obj = jQuery.parseJSON(result); 3327 $("#amountPayable_ship").attr("data-amount", obj.total).html(obj.tot_label); 3328 $("#coupon_value").html(obj.reward_val_label); 3329 $("#coupon_value").attr("data-amount", obj.reward_value); 3330 $("#coupon_code").attr('readonly', false); 3331 3332 $.notify({ 3333 from: "bottom", 3334 title: "<strong></strong> ", 3335 icon: 'glyphicon glyphicon-tags', 3336 message: ' Coupon removed successfully...!' 3337 }, { 3338 timer: 1000, 3339 type: 'success', 3340 animate: { 3341 enter: 'animated lightSpeedIn', 3342 exit: 'animated lightSpeedOut' 3343 } 3344 }); 3345 3346 if($('#setting_option_to_define_coupon_usage_limit_per_order').val() == 1){ 3347 check_coupon_usage_limit_per_order(); 3348 } 3349 if($("#faps_manual_payment_capture").val() == 1){ 3350 CalculateSurchargeAmount(obj.total); 3351 } 3352 } 3353 }); 3354 if(($("#faps_manual_payment_capture").val() == 1 || $("#no_fraud_integration").val() == 1) && ($("#FAPS_FLAG").val() == 1 || ($("#deluxe_payment_integration").val() == 1 && $("#DELUXE_FLAG").val() == 1))){ 3355 CheckFapsPaymentCapture(); 3356 } 3357}); 3358 3359$(document).on('click', '#apply_coupon ', function() { 3360 var btnObj = $(this); 3361 if (CONTROLL == "checkout" && ACTION == "index") { 3362 var coupon_code = $("#coupon_code").val(); 3363 if (coupon_code != '') { 3364 $.ajax({ 3365 url: BASE_PATH + "/api/checkCouponValidity", 3366 type: "post", 3367 async: false, 3368 data: { 3369 'coupon_code': coupon_code, 3370 'total': $("#amountPayable_ship").attr("data-amount"), 3371 'reward_value': $("#coupon_value").attr("data-amount") 3372 }, 3373 success: function(result) { 3374 var obj = jQuery.parseJSON(result); 3375 if (obj.status == 1) { 3376 $("#amountPayable_ship").attr("data-amount", obj.data.total).html(obj.data.tot_label); 3377 $("#coupon_value").html(obj.data.reward_val_label); 3378 $("#coupon_value").attr("data-amount", (parseFloat(obj.data.reward_value)+parseFloat($("#coupon_value").attr("data-amount"))) ); 3379 3380 $.notify({ 3381 from: "bottom", 3382 title: "<strong></strong> ", 3383 icon: 'glyphicon glyphicon-tags', 3384 message: ' "' + coupon_code + '" has been applied successfully...!' 3385 }, { 3386 timer: 1000, 3387 type: 'success', 3388 animate: { 3389 enter: 'animated lightSpeedIn', 3390 exit: 'animated lightSpeedOut' 3391 } 3392 }); 3393 3394 3395 var loyalty_reward_value = obj.data.reward_val_label1; 3396 var loyalty_program_name = obj.data.program_name; 3397 var loyalty_program_des = obj.data.description; 3398 var str_html = ''; 3399 var cp_id = 1; 3400 if($(".remove_coupon").length>0){ 3401 cp_id = parseInt($(".remove_coupon").last().attr('data-id'))+1; 3402 } 3403 if($('#setting_option_to_define_coupon_usage_limit_per_order').val() == 1){ 3404 str_html += "<div class='coupon_applied row dotted_border' id='coupon_" + cp_id + "'>"; 3405 }else{ 3406 str_html += "<div class='row dotted_border' id='coupon_" + cp_id + "'>"; 3407 } 3408 str_html += "<div class='col-lg-2 RM_PLR15'>"; 3409 str_html += "<strong>" + coupon_code + "</strong>"; 3410 str_html += "</div>"; 3411 str_html += "<div class='col-lg-8 RM_PLR15'>"; 3412 str_html += "<strong>" + loyalty_program_name + "</strong> - "; 3413 str_html += loyalty_program_des; 3414 str_html += "</div>"; 3415 str_html += "<div class='col-lg-2 RM_PLR15'>"; 3416 str_html += loyalty_reward_value + "
3416<i class='fa fa-trash-o remove_coupon' data-coupon='" + coupon_code + "' data-id='" + cp_id + "'></i>"; 3417 str_html += "</div></div>"; 3418 $("#coupon_details").append(str_html); 3419 $("#coupon_code").focus().val(''); 3420 if($('#setting_option_to_define_coupon_usage_limit_per_order').val() == 1){ 3421 check_coupon_usage_limit_per_order(); 3422 } 3423 } else { 3424 var msg = ' "' + coupon_code + '" is invalid coupon.'; 3425 if (obj.message) { 3426 msg = obj.message; 3427 } 3428 $.notify({ 3429 from: "bottom", 3430 title: "<strong></strong> ", 3431 icon: 'glyphicon glyphicon-tags', 3432 message: msg 3433 }, { 3434 timer: 1000, 3435 type: 'danger', 3436 animate: { 3437 enter: 'animated lightSpeedIn', 3438 exit: 'animated lightSpeedOut' 3439 } 3440 }); 3441 3442 $("#coupon_code").focus().val(''); 3443 } 3444 } 3445 }); 3446 } else { 3447 $("#coupon_code").focus().val(''); 3448 $.notify({ 3449 from: "bottom", 3450 title: "<strong></strong> ", 3451 icon: 'glyphicon glyphicon-tags', 3452 message: 'Please enter the coupon..!' 3453 }, { 3454 timer: 1000, 3455 type: 'danger', 3456 animate: { 3457 enter: 'animated lightSpeedIn', 3458 exit: 'animated lightSpeedOut' 3459 } 3460 }); 3461 } 3462 } 3463}); 3464 3465$(document).on('click', '#apply_coupon_sale_tax ', function() { 3466 var btnObj = $(this); 3467 if (CONTROLL == "checkout" && ACTION == "index") { 3468 var coupon_code = $("#coupon_code").val(); 3469 if (coupon_code != '') { 3470 $.ajax({ 3471 url: BASE_PATH + "/api/checkCouponValiditysaletax", 3472 type: "post", 3473 async: false, 3474 data: { 3475 'coupon_code': coupon_code, 3476 'total': $("#amountPayable_ship").attr("data-amount"), 3477 'reward_value': $("#coupon_value").attr("data-amount") 3478 }, 3479 success: function(result) { 3480 var obj = jQuery.parseJSON(result); 3481 if (obj.status == 1) { 3482 $("#amountPayable_ship").attr("data-amount", obj.data.total).html(obj.data.tot_label); 3483 $("#coupon_value").html(obj.data.reward_val_label); 3484 $("#coupon_value").attr("data-amount", (parseFloat(obj.data.reward_value)+parseFloat($("#coupon_value").attr("data-amount"))) ); 3485 3486 $.notify({ 3487 from: "bottom", 3488 title: "<strong></strong> ", 3489 icon: 'glyphicon glyphicon-tags', 3490 message: ' "' + coupon_code + '" has been applied successfully...!' 3491 }, { 3492 timer: 1000, 3493 type: 'success', 3494 animate: { 3495 enter: 'animated lightSpeedIn', 3496 exit: 'animated lightSpeedOut' 3497 } 3498 }); 3499 3500 3501 var loyalty_reward_value = obj.data.reward_val_label1; 3502 var loyalty_program_name = obj.data.program_name; 3503 var loyalty_program_des = obj.data.description; 3504 var str_html = ''; 3505 var cp_id = 1; 3506 if($(".remove_coupon_sale_tax").length>0){ 3507 cp_id = parseInt($(".remove_coupon_sale_tax").last().attr('data-id'))+1; 3508 } 3509 if($('#setting_option_to_define_coupon_usage_limit_per_order').val() == 1){ 3510 str_html += "<div class='coupon_applied row dotted_border' id='coupon_" + cp_id + "'>"; 3511 }else{ 3512 str_html += "<div class='row dotted_border' id='coupon_" + cp_id + "'>"; 3513 } 3514 str_html += "<div class='col-lg-2 RM_PLR15'>"; 3515 str_html += "<strong>" + coupon_code + "</strong>"; 3516 str_html += "</div>"; 3517 str_html += "<div class='col-lg-8 RM_PLR15'>"; 3518 str_html += "<strong>" + loyalty_program_name + "</strong> - "; 3519 str_html += loyalty_program_des; 3520 str_html += "</div>"; 3521 str_html += "<div class='col-lg-2 RM_PLR15'>"; 3522 str_html += loyalty_reward_value + "
3522<i class='fa fa-trash-o remove_coupon_sale_tax' data-coupon='" + coupon_code + "' data-id='" + cp_id + "'></i>"; 3523 str_html += "</div></div>"; 3524 $("#coupon_details").append(str_html); 3525 $("#coupon_code").focus().val(''); 3526 if($('#setting_option_to_define_coupon_usage_limit_per_order').val() == 1){ 3527 check_coupon_usage_limit_per_order(); 3528 } 3529 } else { 3530 var msg = ' "' + coupon_code + '" is invalid coupon.'; 3531 if (obj.message) { 3532 msg = obj.message; 3533 } 3534 $.notify({ 3535 from: "bottom", 3536 title: "<strong></strong> ", 3537 icon: 'glyphicon glyphicon-tags', 3538 message: msg 3539 }, { 3540 timer: 1000, 3541 type: 'danger', 3542 animate: { 3543 enter: 'animated lightSpeedIn', 3544 exit: 'animated lightSpeedOut' 3545 } 3546 }); 3547 3548 $("#coupon_code").focus().val(''); 3549 } 3550 } 3551 }); 3552 } else { 3553 $("#coupon_code").focus().val(''); 3554 $.notify({ 3555 from: "bottom", 3556 title: "<strong></strong> ", 3557 icon: 'glyphicon glyphicon-tags', 3558 message: 'Please enter the coupon..!' 3559 }, { 3560 timer: 1000, 3561 type: 'danger', 3562 animate: { 3563 enter: 'animated lightSpeedIn', 3564 exit: 'animated lightSpeedOut' 3565 } 3566 }); 3567 } 3568 } 3569}); 3570 3571$(document).on('click', '.remove_gc ', function() { 3572 $("#gc_serial_number").attr('readonly',false); 3573 $('#pay_by').attr("disabled",false); 3574 3575 $(".gc_error").html(""); 3576 var gc_serial_number = $(this).attr('data-gc'); 3577 $("tr." +gc_serial_number).remove(); 3578 3579 if($(".gc_serial_number_list").find('tr').length==1) 3580 { 3581 $(".gc_serial_number_list").addClass("hide"); 3582 } 3583 $("#gc_apply").attr('disabled',false); 3584 3585 $('#credit-handkey').attr("disabled",false); 3586 $('#credit-handkey-exist').attr("disabled",false); 3587 $('#puchase_order').attr("disabled",false); 3588 3589 if($("#surcharge_for_credit_card").val() == 1 && $("#enable_surcharge_ecom").val() == 1 && $("#surcharge_apply_flg").val() == 1 && $("#pplater_surcharge").val() == 0){ 3590 if($("#faps_manual_payment_capture").val() == 1){ 3591 resetSurchargeValue(); 3592 var remove_total = $("#amountPayable_ship").attr("data-amount"); 3593 } else { 3594 var total_amount = $("#amountPayable_ship").attr("data-amount"); 3595 var surcharge_amount = $("#surcharge_amount").val(); 3596 var remove_total = parseFloat(parseFloat(total_amount)-parseFloat(surcharge_amount)).toFixed(2); 3597 } 3598 } else{ 3599 var remove_total = $("#amountPayable_ship").attr("data-amount"); 3600 } 3601 3602 $.ajax({ 3603 url: BASE_PATH + "/api/removeGiftSerialNumber", 3604 type: "post", 3605 async: false, 3606 data: { 3607 'gc_serial_number': gc_serial_number, 3608 'total': remove_total 3609 }, 3610 success: function(result) { 3611 var obj = jQuery.parseJSON(result); 3612 if($("#partial_and_click_to_pay").val()==1){ 3613 if(obj.total_gc_price>0) 3614 { 3615 var str_html = ''; 3616 str_html += "<div class='panel panel-default'>"; 3617 str_html += "<div class='panel-heading'>"; 3618 str_html += "<div class='row gc_disc' id='gc_discount' data-amount='"+obj.total_gc_price+"'>"; 3619 str_html += "<div class='col-lg-10 RM_PLR15'>"; 3620 str_html += "<strong>Gift Certificate</strong>"; 3621 str_html += "</div>"; 3622 str_html += "<div class='col-lg-2 RM_PLR15' style='text-align:right'>"; 3623 str_html += obj.total_gc_price_label; 3624 str_html += "</div></div>"; 3625 str_html += "<div class='row gc_discount_amt_due' id='gc_discount' data-amount='"+obj.total_gc_price+"'>"; 3626 str_html += "<div class='col-lg-10 RM_PLR15'>"; 3627 str_html += "<strong>Amount Due</strong>"; 3628 str_html += "</div>"; 3629 str_html += "<div class='col-lg-2 RM_PLR15 amt_due' style='text-align:right'>"; 3630 str_html += obj.total_label; 3631 str_html += "</div></div>"; 3632 3633 str_html += "</div>"; 3634 str_html += "</div>"; 3635 3636 console.log('pay_rm_length',$(".pay_rm").length); 3637 console.log('gc_discount',$("#gc_discount").length); 3638 if($(".pay_rm").length > 0){ 3639 $(".gc_disc").parent().parent().remove(); 3640 }else{ 3641 if($("#gc_discount").length>0) 3642 { 3643 $("#gc_discount").parent().parent().remove(); 3644 } 3645 } 3646 3647 console.log(str_html); 3648 $(".costSummary").append(str_html); 3649 $("#amountPayable_ship").attr("data-amount",obj.total); 3650 if($("#surcharge_for_credit_card").val() == 1 && $("#enable_surcharge_ecom").val() == 1 && $("#surcharge_apply_flg").val() == 1) { 3651 if($("#faps_manual_payment_capture").val() == 1){ 3652 CalculateSurchargeAmount(obj.total); 3653 } else { 3654 var gc_discount = parseFloat($("#gc_discount").attr('data-amount')).toFixed(2); 3655 var surcharge_value = $("#surcharge_value").val(); 3656 var totalnew = obj.total; 3657 var surcharge_amount = parseFloat((totalnew*surcharge_value)/100).toFixed(2); 3658 var symbol = $("#currency_symbol").val(); 3659 $("#SurchargeAmount").html(symbol+surcharge_amount); 3660 $("#SurchargeAmount").attr('data-amount',surcharge_amount); 3661 var total_amt = parseFloat(parseFloat(totalnew) + parseFloat(surcharge_amount)).toFixed(2); 3662 var pplater_surcharge = $("#pplater_surcharge").val(); 3663 if(pplater_surcharge == 1) { 3664 $("#amountPayable_ship").attr("data-amount", totalnew); 3665 }else{ 3666 $("#amountPayable_ship").attr("data-amount", total_amt); 3667 } 3668 var subTotal = parseFloat($("#hidden_subTotal_Ship").val()).toFixed(2); 3669 $("#amountPayable_ship").html(symbol+subTotal); 3670 $("#surcharge_amount").val(surcharge_amount); 3671 $(".gc_discount_amt_due div.amt_due").html(symbol+total_amt); 3672 } 3673 } 3674 3675 3676 } 3677 else 3678 { console.log('pay_late_lable length', $(".pay_late_lable").length); 3679 if($("#partial_and_click_to_pay").val()==1 && $(".pay_late_lable").length > 0){ 3680 3681 $(".gc_disc").remove(); 3682 $("#amountPayable_ship").attr("data-amount",obj.total); 3683 $("#pay_late_amt_disp").html(obj.total_label); 3684 $(".amt_due").html(obj.total_label); 3685 }else{ 3686 $(".gc_disc").parent().parent().remove(); 3687 // $("#gc_discount").parent().parent().remove(); 3688 if($("#partial_and_click_to_pay").val()==1){ 3689 $("#amountPayable_ship").attr("data-amount",obj.total); 3690 $(".amt_due").html(obj.total_label); 3691 } 3692 else{ 3693 $("#amountPayable_ship").attr("data-amount",obj.total).html(obj.total_label); 3694 } 3695 } 3696 3697 if($("#surcharge_for_credit_card").val() == 1 && $("#enable_surcharge_ecom").val() == 1 && $("#surcharge_apply_flg").val() == 1) { 3698 if($("#faps_manual_payment_capture").val() == 1){ 3699 CalculateSurchargeAmount(obj.total); 3700 } else { 3701 var gc_discount = parseFloat($("#gc_discount").attr('data-amount')).toFixed(2); 3702 var surcharge_value = $("#surcharge_value").val(); 3703 var current_surcharge = $("#surcharge_amount").val(); 3704 var totalnew = parseFloat(obj.total).toFixed(2);// - parseFloat(current_surcharge)).toFixed(2); 3705 var surcharge_amount = parseFloat((totalnew*surcharge_value)/100).toFixed(2); 3706 var symbol = $("#currency_symbol").val(); 3707 $("#SurchargeAmount").html(symbol+surcharge_amount); 3708 $("#SurchargeAmount").attr('data-amount',surcharge_amount); 3709 var total_amt = parseFloat(parseFloat(totalnew) + parseFloat(surcharge_amount)).toFixed(2); 3710 var pplater_surcharge = $("#pplater_surcharge").val(); 3711 if(pplater_surcharge == 1) { 3712 $("#amountPayable_ship").attr("data-amount", totalnew); 3713 }else{ 3714 $("#amountPayable_ship").attr("data-amount", total_amt); 3715 } 3716 3717 // var subTotal = parseFloat($("#hidden_subTotal").val()).toFixed(2); 3718 $("#amountPayable_ship").html(symbol+total_amt); 3719 $("#surcharge_amount").val(surcharge_amount); 3720 $(".gc_discount_amt_due .amt_due").html(symbol+total_amt); 3721 } 3722 } 3723 3724 } 3725 } 3726 else{ 3727 if(obj.total_gc_price>0) 3728 { 3729 var str_html = ''; 3730 str_html += "<div class='panel panel-default'>"; 3731 str_html += "<div class='panel-heading'>"; 3732 str_html += "<div class='row' id='gc_discount' data-amount='"+obj.total_gc_price+"'>"; 3733 str_html += "<div class='col-lg-10 RM_PLR15'>"; 3734 str_html += "<strong>Gift Certificate</strong>"; 3735 str_html += "</div>"; 3736 str_html += "<div class='col-lg-2 RM_PLR15' style='text-align:right'>"; 3737 str_html += obj.total_gc_price_label; 3738 str_html += "</div></div>"; 3739 str_html += "<div class='row' id='gc_discount' data-amount='"+obj.total_gc_price+"'>"; 3740 str_html += "<div class='col-lg-10 RM_PLR15'>"; 3741 str_html += "<strong>Amount Due</strong>"; 3742 str_html += "</div>"; 3743 str_html += "<div class='col-lg-2 RM_PLR15' style='text-align:right'>"; 3744 str_html += obj.total_label; 3745 str_html += "</div></div>"; 3746 str_html += "</div>"; 3747 str_html += "</div>"; 3748 if($("#gc_discount").length>0) 3749 { 3750 $("#gc_discount").parent().parent().remove(); 3751 } 3752 $(".costSummary").append(str_html); 3753 } 3754 else 3755 { 3756 $("#gc_discount").parent().parent().remove(); 3757 } 3758 $("#amountPayable_ship").attr("data-amount",obj.total).html(obj.total_label); 3759 } 3760 if(obj.total>0) 3761 { 3762 if($("#partial_and_click_to_pay").val()==1){ 3763 $("#card_pay").show(); 3764 $('#credit').css('display','inline'); 3765 $('#credit').prop('checked', true); 3766 $('#credit').next('.pay_m').css('display','inline'); 3767 $('#credit-handkey-exist').css('display','inline'); 3768 $('.pay_m_type').css('display','inline'); 3769 $('#save_vault').show(); 3770 } 3771 if($(".gc_serial_number_list").find('tr').length==1) 3772 { 3773 paybtn(); 3774 }else{ 3775 $("#gc_serial_number").focus(); 3776 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>"; 3777 var eclass = "gc_error"; 3778 paybtn(eclass,emsg); 3779 } 3780 3781 }else{ 3782 paybtn(); 3783 } 3784 3785 $.notify({ 3786 from: "bottom", 3787 title: "<strong></strong> ", 3788 icon: 'glyphicon glyphicon-tags', 3789 message: ' Gift Certificate Number removed successfully...!' 3790 }, { 3791 timer: 1000, 3792 type: 'success', 3793 animate: { 3794 enter: 'animated lightSpeedIn', 3795 exit: 'animated lightSpeedOut' 3796 } 3797 }); 3798 } 3799 }); 3800 if(($("#faps_manual_payment_capture").val() == 1 || $("#no_fraud_integration").val() == 1) && ($("#FAPS_FLAG").val() == 1 || ($("#deluxe_payment_integration").val() == 1 && $("#DELUXE_FLAG").val() == 1))){ 3801 CheckFapsPaymentCapture(); 3802 } 3803}); 3804$(document).on('keypress', '#gc_serial_number', function(event){ 3805 if (event.keyCode === 13) { 3806 if($("#check_gc_balance").length>0){ 3807 $("#check_gc_balance").trigger("click"); 3808 } 3809 else if($("#gc_apply").length>0){ 3810 $("#gc_apply").trigger("click"); 3811 } 3812 } 3813}); 3814$(document).on('keypress', '#UserCaptcha', function(event){ 3815 if (event.keyCode === 13) { 3816 if($("#gc_captcha_verify").length>0){ 3817 $("#gc_captcha_verify").trigger("click"); 3818 } 3819 } 3820}); 3821$(document).on('click', '#gc_captcha_verify', function() { 3822 $('#gc_captcha_verify').attr("disabled",true).html("<img src='"+BASE_PATH +"/img/loading1.gif'>"); 3823 if($("#UserCaptcha").is(":visible") && $("#UserCaptcha").val()!='') { 3824 var gc_captcha_data = { 'captcha_code':$("#UserCaptcha").val() }; 3825 }else{ 3826 $(".gc_error").html("Please enter the captcha code");
3827 $('#gc_captcha_verify').attr("disabled",false).html("Submit"); 3828 return false; 3829 } 3830 $.ajax({ 3831 url: BASE_PATH + "/api/verifycaptcha", 3832 type: "post", 3833 async: false, 3834 data: gc_captcha_data, 3835 success: function(result) { 3836 setTimeout(function(){$('#gc_captcha_verify').attr("disabled",false).html("Submit");},1200); 3837 var obj = jQuery.parseJSON(result); 3838 if (obj.status == 0) { 3839 $(".gc_error").html("Invalid Captcha Code"); 3840 gc_apply_click++; 3841 $(".creload:visible").trigger("click"); 3842 }else{ 3843 $(".gc_error").html(""); 3844 $("#gc_serial_number").parent().parent().parent().removeClass("hide"); 3845 $(".gc_captcha").addClass("hide"); 3846 $("#gc_serial_number").focus(); 3847 gc_apply_click = 0; 3848 if($(".gc_serial_number_list").find('tr').length>1) 3849 { 3850 $(".gc_serial_number_list").removeClass("hide"); 3851 } 3852 if(parseFloat($("#amountPayable_ship").attr("data-amount"))>0 && $(".gc_serial_number_list").find('tr').length>1) 3853 { 3854 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>"; 3855 $(".gc_error").html(err_msg); 3856 } 3857 3858 } 3859 } 3860 }); 3861}); 3862var gc_apply_click = 0; 3863$(document).on('click', '#gc_apply', function() { 3864 $('#gc_apply').attr("disabled",true).html("<img src='"+BASE_PATH +"/img/loading1.gif'>"); 3865 if(gc_apply_click>=4) 3866 { 3867 $(".gc_captcha").removeClass("hide"); 3868 $(".creload:visible").trigger("click"); 3869 $("#UserCaptcha:visible").val(""); 3870 $("#gc_serial_number").val(""); 3871 $("#gc_serial_number").parent().parent().parent().addClass("hide"); 3872 if($(".gc_serial_number_list").find('tr').length>1) 3873 { 3874 $(".gc_serial_number_list").addClass("hide"); 3875 } 3876 $(".gc_error").html(""); 3877 $('#gc_apply').attr("disabled",false).html("Apply"); 3878 return false; 3879 } 3880 3881 // if($("#UserCaptcha").is(":visible") && $("#UserCaptcha").val()=='') 3882 // { 3883 // $("#UserCaptcha").focus(); 3884 // $(".gc_error").html("Please enter the captcha code"); 3885 // return false; 3886 // } 3887 3888 $('#btnSubmitPay').attr("disabled", false); 3889 var gc_serial_number = $.trim($("#gc_serial_number").val()); 3890 if(gc_serial_number=='') 3891 { 3892 $.notify({ 3893 from: "bottom", 3894 title: "<strong></strong> ", 3895 icon: 'glyphicon glyphicon-gift', 3896 message: ' <b>Please enter Gift Certificate Number...!</b>' 3897 }, { 3898 timer: 1000, 3899 type: 'danger', 3900 offset: { x: 50, y: 200 }, 3901 animate: { 3902 enter: 'animated lightSpeedIn', 3903 exit: 'animated lightSpeedOut' 3904 } 3905 }); 3906 gc_apply_click++; 3907 $('#gc_apply').attr("disabled",false).html("Apply"); 3908 } 3909 else 3910 { 3911 if($("#surcharge_for_credit_card").val() == 1 && $("#enable_surcharge_ecom").val() == 1 && $("#surcharge_apply_flg").val() == 1) { 3912 if($("#faps_manual_payment_capture").val() == 1){ 3913 resetSurchargeValue(); 3914 var total = parseFloat($("#amountPayable_ship").attr("data-amount")).toFixed(2); 3915 } else { 3916 var pplater_surcharge = $("#pplater_surcharge").val(); 3917 var total_amount = $("#amountPayable_ship").attr("data-amount"); 3918 if(pplater_surcharge == 1){ 3919 var total = parseFloat(parseFloat(total_amount)).toFixed(2); 3920 } 3921 else{ 3922 var surcharge_amount = $("#surcharge_amount").val(); 3923 var total = parseFloat(parseFloat(total_amount)-parseFloat(surcharge_amount)).toFixed(2); 3924 } 3925 } 3926 var gc_data = { 'gc_serial_number': gc_serial_number, 'total': total }; 3927 } 3928 else{ 3929 var gc_data = { 'gc_serial_number': gc_serial_number, 'total': $("#amountPayable_ship").attr("data-amount") }; 3930 } 3931 // if($("#UserCaptcha").is(":visible") && $("#UserCaptcha").val()!='') 3932 // { 3933 // var gc_data = { 'gc_serial_number': gc_serial_number, 'total': $("#amountPayable_ship").attr("data-amount"), 'gc_captcha':$("#UserCaptcha").val() }; 3934 // } 3935 $.ajax({ 3936 url: BASE_PATH + "/api/getGiftserialBalance", 3937 type: "post", 3938 async: false, 3939 data: gc_data, 3940 success: function(result) { 3941 setTimeout(function(){ $('#gc_apply').attr("disabled",fal
3941se).html("Apply"); },1200); 3942 if($(".creload").is(":visible")) 3943 { 3944 $(".creload:visible").trigger("click"); 3945 $("#UserCaptcha").val(""); 3946 } 3947 var obj = jQuery.parseJSON(result); 3948 if (obj.status == 0) 3949 { 3950 $(".gc_error").html(obj.message); 3951 gc_apply_click++; 3952 paybtn(); 3953 } 3954 else if(obj.status==1) 3955 { 3956 if($("#partial_and_click_to_pay").val()==1){ 3957 if($(".pay_late_amt_due").length > 0){ 3958 $(".pay_late_amt_due").css('display','none'); 3959 } 3960 if($(".gc_discount_amt_due").length >0){ 3961 $(".gc_discount_amt_due").css('display','none'); 3962 } 3963 var str_html = ''; 3964 str_html += "<div class='panel panel-default'>"; 3965 str_html += "<div class='panel-heading'>"; 3966 str_html += "<div class='row gc_disc' id='gc_discount' data-amount='"+obj.total_gc_price+"'>"; 3967 str_html += "<div class='col-lg-10 RM_PLR15'>"; 3968 str_html += "<strong>Gift Certificate</strong>"; 3969 str_html += "</div>"; 3970 str_html += "<div class='col-lg-2 RM_PLR15' style='text-align:right'>"; 3971 str_html += obj.total_gc_price_label; 3972 str_html += "</div></div>"; 3973 str_html += "<div class='row gc_discount_amt_due' id='gc_discount' data-amount='"+obj.total_gc_price+"'>"; 3974 str_html += "<div class='col-lg-10 RM_PLR15'>"; 3975 str_html += "<strong>Amount Due</strong>"; 3976 str_html += "</div>"; 3977 str_html += "<div class='col-lg-2 RM_PLR15 amt_due' style='text-align:right'>"; 3978 str_html += obj.total_label; 3979 str_html += "</div></div>"; 3980 str_html += "</div>"; 3981 str_html += "</div>"; 3982 //console.log('pay_late length',$(".pay_late_lable").length); 3983 //console.log('gift card length',$("#gc_discount").length); 3984 //console.log('gc_disc',$(".gc_disc").length); 3985 if($(".pay_late_lable").length >0 && $(".gc_disc").length >0){ 3986 $(".gc_disc").parent().remove(); 3987 //console.log("gift card exist"); 3988 } 3989 else if($(".pay_late_lable").length >0){ 3990 //console.log("pay later exist"); 3991 } 3992 else if($("#gc_discount").length>0) 3993 { 3994 console.log("pay later not exist and gift card exist"); 3995 $("#gc_discount").parent().parent().remove(); 3996 } 3997 $("#amountPayable_ship").attr("data-amount",obj.total); 3998 $(".costSummary").append(str_html); 3999 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>"; 4000 $(".gc_serial_number_list").removeClass("hide").append(str); 4001 $("#gc_serial_number").val(''); 4002 $(".gc_error").html(obj.message); //.fadeIn(); 4003 } 4004 else{ 4005 var str_html = ''; 4006 str_html += "<div class='panel panel-default'>"; 4007 str_html += "<div class='panel-heading'>"; 4008 str_html += "<div class='row' id='gc_discount' data-amount='"+obj.total_gc_price+"'>"; 4009 str_html += "<div class='col-lg-10 RM_PLR15'>"; 4010 str_html += "<strong>Gift Certificate</strong>"; 4011 str_html += "</div>"; 4012 str_html += "<div class='col-lg-2 RM_PLR15' style='text-align:right'>"; 4013 str_html += obj.total_gc_price_label; 4014 str_html += "</div></div>"; 4015 str_html += "<div class='row' id='gc_discount' data-amount='"+obj.total_gc_price+"'>"; 4016 str_html += "<div class='col-lg-10 RM_PLR15'>"; 4017 str_html += "<strong>Amount Due</strong>"; 4018 str_html += "</div>"; 4019 str_html += "<div class='col-lg-2 RM_PLR15' style='text-align:right'>"; 4020 str_html += obj.total_label; 4021 str_html += "</div></div>"; 4022 str_html += "</div>"; 4023 str_html += "</div>"; 4024 if($("#gc_discount").length>0) 4025 { 4026 $("#gc_discount").parent().parent().remove(); 4027 } 4028 $("#amountPayable_ship").attr("data-amount",obj.total); 4029 $(".costSummary").append(str_html); 4030 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>"; 4031 $(".gc_serial_number_list").removeClass("hide").append(str); 4032 $("#gc_serial_number").val(''); 4033 $(".gc_error").html(obj.message); //.fadeIn(); 4034 } 4035 if(obj.total==0) 4036 { 4037 $("#gc_serial_number").attr('readonly',true); 4038 $("#gc_apply").attr('disabled',true); 4039 4040 if($("#partial_and_click_to_pay").val()==1){ 4041 $("#card_pay").hide(); 4042 $('#credit').css('display','none'); 4043 $('#credit').prop('checked', false); 4044 $('#credit').next('.pay_m').css('display','none'); 4045 $('#credit-handkey-exist').css('display','none'); 4046 $('.pay_m_type').css('display','none'); 4047 $('#save_vault').hide(); 4048 if($("#surcharge_for_credit_card").val() == 1 && $("#enable_surcharge_ecom").val() == 1 && $("#surcharge_apply_flg").val() == 1) { 4049 if($("#faps_manual_payment_capture").val() == 1){ 4050 CalculateSurchargeAmount(0); 4051 } else { 4052 $("#surcharge_amount").val('0.00'); 4053 var symbol = $("#currency_symbol").val(); 4054 $("#SurchargeAmount").html(symbol+'0.00'); 4055 $("#SurchargeAmount").attr('data-amount','0.00'); 4056 var subTotal = parseFloat($("#hidden_subTotal_Ship").val()).toFixed(2); 4057 $("#amountPayable_ship").html(symbol+subTotal); 4058 } 4059 } 4060 }else{ 4061 $('#credit-handkey').attr("disabled",true); 4062 $('#credit-handkey-exist').attr("disabled",true); 4063 $('#puchase_order').attr("disabled",true); 4064 } 4065 4066 paybtn(); 4067 }else{ 4068 $("#gc_serial_number").focus(); 4069 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>"; 4070 var eclass = "gc_error"; 4071 if($("#surcharge_for_credit_card").val() == 1 && $("#enable_surcharge_ecom").val() == 1 && $("#surcharge_apply_flg").val() == 1) { 4072 if($("#faps_manual_payment_capture").val() == 1){ 4073 CalculateSurchargeAmount(obj.total); 4074 } else { 4075 var surcharge_value = $("#surcharge_value").val(); 4076 var totalnew = obj.total; 4077 var surcharge_amount = parseFloat((totalnew*surcharge_value)/100).toFixed(2); 4078 var symbol = $("#currency_symbol").val(); 4079 $("#SurchargeAmount").html(symbol+surcharge_amount); 4080 $("#SurchargeAmount").attr('data-amount',surcharge_amount); 4081 var total_amt = parseFloat(parseFloat(totalnew) + parseFloat(surcharge_amount)).toFixed(2); 4082 var pplater_surcharge = $("#pplater_surcharge").val(); 4083 var gc_discount = parseFloat($("#gc_discount").attr('data-amount')).toFixed(2); 4084 if(pplater_surcharge == 1) { 4085 $("#amountPayable_ship").attr("data-amount",totalnew); 4086 } 4087 else{ 4088 $("#amountPayable_ship").attr("data-amount",total_amt); 4089 } 4090 var subTotal = parseFloat($("#hidden_subTotal_Ship").val()).toFixed(2); 4091 $("#amountPayable_ship").html(symbol+subTotal); 4092 $("#surcharge_amount").val(surcharge_amount); 4093 $(".gc_discount_amt_due .amt_due").html(symbol+total_amt); 4094 } 4095 } 4096 paybtn(eclass,emsg); 4097 } 4098 gc_apply_click = 0; 4099 4100 if(($("#faps_manual_payment_capture").val() == 1 || $("#no_fraud_integration").val() == 1) && ($("#FAPS_FLAG").val() == 1 || ($("#deluxe_payment_integration").val() == 1 && $("#DELUXE_FLAG").val() == 1))){ 4101 CheckFapsPaymentCapture(); 4102 } 4103 } 4104 } 4105 }); 4106 } 4107}); 4108$(document).on('click', '#pay_by ', function() { 4109 $('#btnSubmitPay').attr("disabled", false); 4110 var action = $(this).attr("data-action"); 4111 if(action=="gc") 4112 { 4113 $('#worldpay_redirect_txt').css('display','none'); 4114 4115 $("#gc_pay").removeClass("hide"); 4116 $("#card_pay").addClass("hide"); 4117 $("#b2b_po_pay").hide(); 4118 $("#exist_card_pay").hide(); 4119 $('#save_vault').hide(); 4120 $(this).attr("data-action",'cc').html('<i class="fa fa-credit-card"></i> Pay by Credit Card'); 4121 4122 paybtn(); 4123 4124 $(".gc_error").html(""); 4125 $("#gc_serial_number").parent().parent().parent().removeClass("hide"); 4126 $(".gc_captcha").addClass("hide"); 4127 $("#gc_serial_number").focus(); 4128 gc_apply_click = 0; 4129 if($(".gc_serial_number_list").find('tr').length>1) 4130 { 4131 $(".gc_serial_number_list").removeClass("hide"); 4132 } 4133 if(parseFloat($("#amountPayable_ship").attr("data-amount"))>0 && $(".gc_serial_number_list").find('tr').length>1) 4134 { 4135 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>"; 4136 $(".gc_error").html(err_msg); 4137 } 4138 4139 } 4140 else 4141 { $('#worldpay_redirect_txt').css('display','block'); 4142 $(this).attr("data-action",'gc').html('<i class="fa fa-gift"></i> Pay by Gift Certificate'); 4143 4144 $("#gc_pay").removeClass("hide"); 4145 $("#card_pay").addClass("hide"); 4146 $("#b2b_po_pay").hide(); 4147 $("#exist_card_pay").hide(); 4148 $('#save_vault').hide(); 4149 4150 $('#btnSubmitPay').attr("disabled", false); 4151 } 4152}); 4153 4154function paybtn(eclass='',emsg='') 4155{ 4156 if($("#CreditCardCardNumber").length>0){ 4157 var cccn = $("#CreditCardCardNumber").val(); 4158 }else 4159 { 4160 var cccn = $("#CreditCardCardNumber").val(); 4161 } 4162 var cccv = $("#CreditCardCvv").val(); 4163 var cce = $("#CreditCardExpiry").val(); 4164 var ccn = $("#CreditCardName").val(); 4165 var amountPayable_ship = parseFloat($("#amountPayable_ship").attr("data-amount")); 4166 if( (cccn=='' || cccv=='' || cce=='' || ccn=='' || $("#WorldPayCreditCardAuthForm").length) && amountPayable_ship>0 ) 4167 { 4168 $('#btnSubmitPay').attr("disabled", true); 4169 } 4170 else 4171 { 4172 $('#btnSubmitPay').attr("disabled", false); 4173 } 4174 if(emsg!='') 4175 { 4176 $('#btnSubmitPay').attr("disabled", true); 4177 $("."+eclass).append(emsg); 4178 } 4179 if($("#partial_and_click_to_pay").val()==1){ 4180 $('#btnSubmitPay').attr("disabled", false); 4181 } 4182} 4183$(document).on('click', '.return_to_cart', function(){ 4184 window.location = BASE_PATH+"/cart"; 4185 return false;
4186}); 4187 4188 4189if (CONTROLL == "checkout") { 4190 jQuery(document).ready(function($) 4191 { 4192 if("#back" == location.hash){ 4193 window.location = BASE_PATH+"/cart"; 4194 return false; 4195 } 4196 if (window.history && window.history.pushState) 4197 { 4198 $(window).on('popstate', function() { 4199 var hashLocation = location.hash; 4200 if(hashLocation!='') 4201 { 4202 var hashSplit = hashLocation.split("#!/"); 4203 var hashName = hashSplit[1]; 4204 if (hashName !== '') { 4205 var hash = window.location.hash; 4206 if (hash === '') { 4207 //alert('Back button was pressed.'); 4208 //window.location = 'www.example.com'; 4209 return false; 4210 } 4211 } 4212 } 4213 }); 4214 window.history.pushState('forward', null, '#back'); 4215 } 4216 }); 4217} 4218 4219if (CONTROLL == "checkout" && ACTION == "payment" ) 4220{ 4221 var tx = 0; 4222 $(window.parent.window).on('popstate', function () { 4223 tx++; 4224 if(tx%2==1 && tx>3 ) 4225 { 4226 window.location = BASE_PATH+"/cart"; 4227 return false; 4228 } 4229 else if(tx%2==0 && tx>4 ) 4230 { 4231 window.location = BASE_PATH+"/cart"; 4232 return false; 4233 } 4234 4235 }); 4236} 4237 4238 4239 4240$(document).on('click', '#save_zip', function () { 4241 if(add_orchid_eState_api_to_site==1){ 4242 var zip_code = $("#zip_code").val().trim(); 4243 var part_id = $('#part_id_upc').val(); 4244 var regex = /^([0-9]{5})$/; 4245 //console.log(zip_code.match(regex)); 4246 if(zip_code=='' || zip_code.match(regex)==null ){ 4247 $('#response').css('color','red').text("Please Enter Valid Zip Code"); 4248 }else{ 4249 $('#response').text(" "); 4250 zipupc_save(part_id,zip_code); 4251 } 4252 return false; 4253 } 4254}); 4255 4256$('#zipcode_modal').keypress( 4257 function(event){ 4258 if (event.which == '13') { 4259 if(add_orchid_eState_api_to_site==1){ 4260 event.preventDefault(); 4261 $("#save_zip").trigger("click"); 4262 } 4263 } 4264 }); 4265 4266 4267 4268 4269 4270function zipupc_save(part_id='',zip_code=''){ 4271 if(add_orchid_eState_api_to_site==1){ 4272 4273 4274 $.ajax({ 4275 url: $("#base_path").val()+"/api/estate_api_zipcode", 4276 type: "POST", 4277 datatype:'json', 4278 data : { 4279 zip_code :zip_code, 4280 part_id : part_id 4281 }, 4282 success:function(response){ 4283 response = JSON.parse(response); 4284 4285 if(response.status==1){ 4286 //$('#res_status').val(response.data.response); 4287 if(response.data.response==5){ 4288 $('#response').css('color','black').text("Firearm UPC has not been classified. You may purchase the firearm subject to your own understanding of the local laws and regulations."); 4289 } 4290 else if(response.data.response==2){ 4291 $('#response').css('color','black').text("Firearm UPC is restricted in your zip code."); 4292 } 4293 else if(response.data.response==1){ 4294 $('#response').css('color','black').text("Firearm UPC is compliant in your zip code."); 4295 } 4296 else if(response.data.response==3){ 4297 $('#response').css('color','black').text("Firearm UPC is roster state."); 4298 } 4299 4300 } 4301 4302 } 4303 4304 }); 4305 return false; 4306 } 4307 4308} 4309 4310$(document).on('click', '#pay_by_gc ', function() { 4311 $('#btnSubmitPay').attr("disabled", false); 4312 var action = $(this).attr("data-action"); 4313 if(action=="gc") 4314 { 4315 if($("#partial_and_click_to_pay").val()==1){ 4316 4317 } 4318 else{ 4319 $('#worldpay_redirect_txt').css('display','none'); 4320 4321 4322 $("#card_pay").addClass("hide"); 4323 $("#b2b_po_pay").hide(); 4324 $("#exist_card_pay").hide(); 4325 $('#save_vault').hide(); 4326 $('#credit').prop('checked', false); 4327 4328 } 4329 } 4330}); 4331$(document).on('click', '#pay_later_apply', function() { 4332 // $('#pay_later_apply').attr("disabled",true).html("<img src='"+BASE_PATH +"/img/loading1.gif'>"); 4333 4334 // $('#btnSubmitPay').attr("disabled", false); 4335 var pay_later_amt = $.trim($("#pay_later_amt").val()); 4336 var b2b_po_number = ($("#b2b_po_number_p").length > 0)?$("#b2b_po_number_p").val():''; 4337 if(pay_later_amt=='' || pay_later_amt == 0) 4338 { 4339 $(".pl_error").html("Pay Later Amount should not be empty!"); 4340 } 4341 else if(parseFloat($("#pay_later_amt").val()) >= parseFloat($("#amountPayable_ship").attr("data-amount"))){ 4342 $(".pl_error").html("Pay Later Amount should be less than the amount due!"); 4343 } 4344 else 4345 { 4346 4347 if($("#faps_manual_payment_capture").val() == 1){ 4348 resetSurchargeValue(); 4349 } 4350 $.ajax({ 4351 url: BASE_PATH + "/site/check_credit_limit", 4352 type: "post", 4353 async: false, 4354 data: { 4355 total: parseFloat($("#pay_later_amt").val()), 4356 payable_total: parseFloat($("#amountPayable_ship").attr("data-amount")), 4357 is_partial:1, 4358 b2b_po_number: b2b_po_number, 4359 }, 4360 success: function(result) { 4361 4362 // if($(".creload").is(":visible")) 4363 // { 4364 // $(".creload:visible").trigger("click"); 4365 // $("#UserCaptcha").val(""); 4366 // } 4367 4368 var obj = jQuery.parseJSON(result); 4369 if (obj.status == 1) 4370 { 4371 $(".pl_error").html("You have exceeded your credit limit. Please contact your Account Owner for either a credit upgrade or for bringing down the outstanding balances by making a payment."); 4372 } 4373 else if(obj.status==0) 4374 { 4375 $(".pl_error").html(''); 4376 if($(".gc_discount_amt_due").length >0){ 4377 $(".gc_discount_amt_due").css('display','none'); 4378 } 4379 var str_html = ''; 4380 var payable_total=''; 4381 str_html += "<div class='panel panel-default'>"; 4382 str_html += "<div class='panel-heading'>"; 4383 str_html += "<div class='row pay_rm pay_late_lable' id='gc_discount' data-amount='"+obj.pay_later+"'>"; 4384 str_html += "<div class='col-lg-10 RM_PLR15'>"; 4385 str_html += "<strong>Pay Later</strong>"; 4386 str_html += "</div>"; 4387 str_html += "<div class='col-lg-2 RM_PLR15' style='text-align:right'>"; 4388 str_html += "-"+obj.pay_later_lable; 4389 str_html += "</div></div>"; 4390 str_html += "<div class='row pay_late_amt_due pay_rm gc_discount_amt_due' id='gc_discount' data-amount='"+obj.pay_later_total+"'>"; 4391 str_html += "<div class='col-lg-10 RM_PLR15'>"; 4392 str_html += "<strong>Amount Due</strong>"; 4393 str_html += "</div>"; 4394 str_html += "<div class='col-lg-2 RM_PLR15 amt_due' id='pay_late_amt_disp' style='text-align:right'>"; 4395 str_html += obj.pay_later_total_lable; 4396 str_html += "</div></div>"; 4397 str_html += "</div>"; 4398 str_html += "</div>"; 4399 4400 4401 $("#amountPayable_ship").attr("data-amount",obj.pay_later_total); 4402 $(".costSummary").append(str_html); 4403 var str = "<tr class='pay_late_error'><td> <a href='javascript:void(0);' class='remove_pay_later' data-gc='pay_late_rm'>Remove</a></td><td>"+obj.pay_later_lable+"</td><td>"+b2b_po_number+"</td></tr>"; 4404 $(".pay_late_list").removeClass("hide").append(str); 4405 // $("#pay_later_amt").val(''); 4406 $("#pay_later_amt").addClass("hide"); 4407 $("#pay_later_apply").addClass("hide"); 4408 $("#b2b_po_number_p").addClass("hide"); 4409 $("#pay_later").attr("disabled",true); 4410 $("#pat_typ_full").attr("disabled",true); 4411 $("input:checked + .slider").css("background-color","grey"); 4412 4413 var OP789 = $("#surcharge_for_credit_card").val(); 4414 if(OP789 == '1' && $("#enable_surcharge_ecom").val() == 1 && $("#surcharge_apply_flg").val() == 1){ 4415 if($("#faps_manual_payment_capture").val() == 1) { 4416 CalculateSurchargeAmount(obj.pay_later_total); 4417 } else { 4418 var total = obj.pay_later_total; 4419 var surcharge_value = $("#surcharge_value").val(); 4420 var surcharge_amount = parseFloat((total*surcharge_value)/100).toFixed(2); 4421 var symbol = $("#currency_symbol").val(); 4422 $("#SurchargeAmount").html(symbol+surcharge_amount); 4423 $("#SurchargeAmount").attr('data-amount',surcharge_amount); 4424 var total_amt = parseFloat(parseFloat(total) + parseFloat(surcharge_amount)).toFixed(2); 4425 $(".gc_discount_amt_due").attr('data-amount',total_amt); 4426 $("#pay_late_amt_disp").html(symbol+total_amt); 4427 $("#surcharge_amount").val(surcharge_amount); 4428 } 4429 } 4430 4431 if(($("#faps_manual_payment_capture").val() == 1 || $("#no_fraud_integration").val() == 1) && ($("#FAPS_FLAG").val() == 1 || ($("#deluxe_payment_integration").val() == 1 && $("#DELUXE_FLAG").val() == 1))){ 4432 CheckFapsPaymentCapture(); 4433 } 4434 //.fadeIn(); 4435 // if(obj.total==0) 4436 // { 4437 // $("#gc_serial_number").attr('readonly',true); 4438 // $("#gc_apply").attr('disabled',true); 4439 // if($("#rebuild_shipping_destinations_sf").val()==1){ 4440 // $('#credit-handkey').attr("disabled",true); 4441 // $('#credit-handkey-exist').attr("disabled",true); 4442 // $('#puchase_order').attr("disabled",true); 4443 // } 4444 // else{ 4445 // $('#pay_by').attr("disabled",true); 4446 // } 4447 // // paybtn(); 4448 // } 4449 4450 } 4451 } 4452 }); 4453 4454 } 4455}); 4456$(document).on('click', '.remove_pay_later ', function() { 4457// $('.remove_pay_later,#pat_typ_full,#pay_later').click(function() { 4458 $("#gc_serial_number").attr('readonly',false);
4459 $('#pay_by').attr("disabled",false); 4460 4461 $(".pay_late_error").html(""); 4462 var pay_late_rm = $(this).attr('data-gc'); 4463 $("tr." +pay_late_rm).remove(); 4464 $(".pay_late_list").addClass("hide"); 4465 $(".pay_late_lable").remove(); 4466 $("#pay_later_amt").removeClass("hide"); 4467 $("#pay_later_apply").removeClass("hide"); 4468 $("#b2b_po_number_p").removeClass("hide"); 4469 $('#credit-handkey').attr("disabled",false); 4470 $('#credit-handkey-exist').attr("disabled",false); 4471 $('#puchase_order').attr("disabled",false); 4472 console.log('pay_later',parseFloat($("#pay_later_amt").val())); 4473 console.log('amountPayable_ship',parseFloat($("#amountPayable_ship").attr("data-amount"))); 4474 if($("#faps_manual_payment_capture").val() == 1){ 4475 resetSurchargeValue(); 4476 } 4477 var amountPayable_ship_rm = parseFloat($("#amountPayable_ship").attr("data-amount"))+parseFloat($("#pay_later_amt").val()); 4478 console.log('amountPayable_ship_rm',amountPayable_ship_rm); 4479 $("#amountPayable_ship").attr("data-amount",amountPayable_ship_rm); 4480 $(".pay_late_amt_due").attr("data-amount",amountPayable_ship_rm); 4481 $.ajax({ 4482 url: BASE_PATH + "/site/set_currency_symb", 4483 type: "post", 4484 async: false, 4485 data: { 4486 total: amountPayable_ship_rm, 4487 }, 4488 success: function(result) { 4489 var obj = jQuery.parseJSON(result);console.log(obj); 4490 if (obj.status == 1) 4491 { 4492 $("#pay_late_amt_disp").html(obj.total); 4493 $(".amt_due").html(obj.total); 4494 } 4495 } 4496 }); 4497 4498 var OP789 = $("#surcharge_for_credit_card").val(); 4499 if(OP789 == '1' && $("#enable_surcharge_ecom").val() == 1 && $("#surcharge_apply_flg").val() == 1){ 4500 if($("#faps_manual_payment_capture").val() == 1){ 4501 CalculateSurchargeAmount(amountPayable_ship_rm); 4502 } else { 4503 var total = amountPayable_ship_rm; 4504 var surcharge_value = $("#surcharge_value").val(); 4505 var surcharge_amount = parseFloat((total*surcharge_value)/100).toFixed(2); 4506 var symbol = $("#currency_symbol").val(); 4507 $("#SurchargeAmount").html(symbol+surcharge_amount); 4508 $("#SurchargeAmount").attr('data-amount',surcharge_amount); 4509 $("#surcharge_amount").val(surcharge_amount); 4510 var total_amt = parseFloat(parseFloat(total) + parseFloat(surcharge_amount)).toFixed(2); 4511 $(".gc_discount_amt_due").attr('data-amount',total_amt); 4512 $("#pay_late_amt_disp").html(symbol+total_amt); 4513 } 4514 } 4515 4516 $("#pay_later").attr("disabled",false); 4517 $("#pat_typ_full").attr("disabled",false); 4518 $("input:checked + .slider").css("background-color","#2AB934"); 4519 $("#pay_later_amt").val(''); 4520 if(parseFloat($("#amountPayable_ship").attr("data-amount"))>0){ 4521 $("#card_pay").show(); 4522 $('#credit').css('display','inline'); 4523 $('#credit').prop('checked', true); 4524 $('#credit').next('.pay_m').css('display','inline'); 4525 $('#credit-handkey-exist').css('display','inline'); 4526 $('.pay_m_type').css('display','inline'); 4527 $('#save_vault').show(); 4528 $("#exist_card_pay").hide(); 4529 $('#credit-handkey-exist').show(); 4530 $('#credit-handkey-exist').next("span").show(); 4531 $('#credit-handkey').show(); 4532 $('#credit-handkey').next("span").show(); 4533 } 4534 4535 if(($("#faps_manual_payment_capture").val() == 1 || $("#no_fraud_integration").val() == 1) && ($("#FAPS_FLAG").val() == 1 || ($("#deluxe_payment_integration").val() == 1 && $("#DELUXE_FLAG").val() == 1))){ 4536 CheckFapsPaymentCapture(); 4537 } 4538}); 4539 4540function check_coupon_usage_limit_per_order(){ 4541 let applied_coupon_count = $('#coupon_details > .dotted_border').length; 4542 $.ajax({ 4543 url: BASE_PATH + "/checkout/check_coupon_usage_limit_per_order", 4544 method: 'GET', 4545 dataType: 'json', 4546 async: false, 4547 success: function(response) { 4548 console.log('response.status:'+typeof(response)); 4549 if (response.status) { 4550 let limit_per_order = response.limit; 4551 console.log('limit_per_order : '+limit_per_order); 4552 console.log('applied_coupon_count : '+applied_coupon_count); 4553 if(applied_coupon_count >= limit_per_order){ 4554 $('#coupon_input').hide(); 4555 console.log('IF hide'); 4556 }else{ 4557 $('#coupon_input').show(); 4558 console.log('else show'); 4559 } 4560 } 4561 } 4562 }); 4563} 4564 4565// Reset the surcharge amount from amount payable 4566function resetSurchargeValue(){ 4567 var amount_payable = parseFloat($("#amountPayable_ship").attr("data-amount")).toFixed(2); 4568 var surchargeAmountVal = (parseFloat($("#surcharge_amount").val()) > 0) ? parseFloat($("#surcharge_amount").val()) : 0; 4569 amount_payable = parseFloat(amount_payable) - parseFloat(surchargeAmountVal); 4570 $("#amountPayable_ship").attr("data-amount", amount_payable); 4571} 4572 4573 4574function prevent_cc_testing_new() 4575{ 4576 $("#btnSubmitPay").attr("disabled", true); 4577 $.notify({ 4578 title: "", 4579 icon: 'glyphicon glyphicon-cart', 4580 message: "You have tried too many attempts....." 4581 }, {
4582 offset: { 4583 x: 50, 4584 y: 200 4585 }, 4586 timer: 1000, 4587 type: 'danger', 4588 animate: { 4589 enter: 'animated lightSpeedIn', 4590 exit: 'animated lightSpeedOut' 4591 } 4592 }); 4593 setTimeout(function(){ 4594 //getHasChanges(true); 4595 window.location.href = BASE_PATH + "/cart"; 4596 },500); 4597 return false; 4598} 4599 4600/** Always show exclude-manufacturer messages (firearm + non-firearm), regardless of pickup in-store. */ 4601function showOrchidExcludeManufacturerMessages() { 4602 if (typeof $ === "undefined") { return; } 4603 if (!$("#ffl_online_pickup_firearm_ft").length) { return; } 4604 if ($("#prevent_drop_shipping").val() != "1") { return; } 4605 if (typeof cart === "undefined" || typeof cart.readCookie !== "function") { return; } 4606 $(".manufacure_rem_item_firearm").css('display','none'); 4607 $(".manufacure_rem_item_non_firearm").css('display','none'); 4608 var read_cart1 = cart.readCookie(); 4609 var has_nf = false; 4610 var has_f = false; 4611 for (var key in read_cart1) { 4612 if (read_cart1[key]['new_stock'] <= 0 && read_cart1[key]['excluded_manufacturer'] == 1) { 4613 if (read_cart1[key]['is_firearm'] == 0) { 4614 has_nf = true; 4615 $(".rmm_"+read_cart1[key]['uuid']).text("Remove"); 4616 } 4617 if (read_cart1[key]['is_firearm'] == 1) { 4618 has_f = true; 4619 $(".rmm_"+read_cart1[key]['uuid']).text("Remove"); 4620 } 4621 } 4622 } 4623 var msg = 'This item cannot be shipped directly and must be processed through our store.'; 4624 if (has_nf) { 4625 $(".manufacure_rem_item_non_firearm").css('display','block'); 4626 $('.exclude_manufacturer_nonfirearm').text(msg).css('display', 'block'); 4627 } 4628 if (has_f) { 4629 $(".manufacure_rem_item_firearm").css('display','block'); 4630 $('.exclude_manufacturer_firearm').text(msg).css('display', 'block'); 4631 } 4632 }
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.