1var token = $('meta[name="csrf-token"]').attr('content'); 2$(document).ready(function () { 3 if ($('.cart-table').length > 0) { 4 $('html, body').animate({ 5 scrollTop: $("body").offset().top 6 }, 500); 7 8 //getRecommendedSideCart(); 9 } 10 //DisplayPopupFreeGift(); 11 $('[data-toggle="tooltip"]').tooltip({html: true }); 12 /* 13 if($("#shopcartpage").length > 0 || $('#proddetails').length > 0) 14 { 15 AfterpaySetup(); 16 } 17 */ 18 19 $(document).click(function(event) { 20 if (!$(event.target).closest('#cart-open, .cart-link').length) { 21 if($('#cart-open').css('right')=='0px'){ 22 $("#imgmodal").removeAttr("style"); 23 $('#cart-open').animate({ 24 right: '-480px' 25 }); 26 $('body').toggleClass('slide-open'); 27 $("#imgmodal").attr("style","display:none;"); 28 } 29 30 } 31 }); 32 33 if (!sessionStorage.getItem("freeGiftClosed")) { 34 if ($('.cart-table').length > 0) { 35 $('html, body').animate({ 36 scrollTop: $("body").offset().top 37 }, 500); 38 } 39 DisplayPopupFreeGift(); 40 } 41 42 $(document).on('click', '#FreeGiftViewPopup .close', function () { 43 sessionStorage.setItem("freeGiftClosed", "true"); 44 }); 45 46 if (!sessionStorage.getItem("freeSampleClosed")) { 47 if ($('.cart-table').length > 0) { 48 $('html, body').animate({ 49 scrollTop: $("body").offset().top 50 }, 500); 51 } 52 DisplayPopupSampleProducts(); 53 } 54 55 $(document).on('click', '#FreeSampleProductsViewPopup .close', function () { 56 sessionStorage.setItem("freeSampleClosed", "true"); 57 }); 58 59}); 60$(document).on('click', ".addtocart", function () { 61 var productID = $(this).attr('data-product'); 62 if($(this).attr('data-type') == 'sticky') 63 //var prodqty = $(".sticky-qty #prodqty").val(); 64 var prodqty = $("#prodqty-sticky").val(); 65 else 66 var prodqty = $("#prodqty").val(); 67 AddToCart(productID, prodqty); 68}); 69$(document).on('click', ".prodaddcart", function () { 70 var productID = $(this).attr('data-product'); 71 var prodqty = 1; 72 AddToCart(productID, prodqty); 73}); 74$(document).on('click', "#buyitnow", function () { 75 var productID = $(this).attr('data-product'); 76 var prodqty = 1; 77 AddToCart(productID, prodqty, 'buynow'); 78}) 79$(document).on('click', '#clear-bag', function () { 80 ClearBag(); 81}); 82$(document).on('click',"#btnpaybycc", function(){ 83 $('#fund_type').val('card'); 84 $('#frmfund').submit(); 85}); 86$("#btnreorder").click(function(){ 87 var prodDetails = new Array(); 88 $(".chkitem").each(function (index, ele) { 89 if($(this).prop('checked')) 90 { 91 var productID = $(this).val(); 92 var prodqty = $('#prodqty_'+productID).val(); 93 prodDetails.push({'productID' : productID, 'prodqty' : prodqty}); 94 } 95 }); 96 if(prodDetails.length > 0 ) 97 { 98 AddToCartForReorder(prodDetails); 99 } else { 100 alert('Please select product.'); 101 return false; 102 } 103}); 104$(document).on("click",".wproduct",function(){ 105 var productID = $(this).attr('id'); 106 var prodqty = $('#prodqty_'+productID).val(); 107 console.log(productID+'==='+prodqty); 108 if(prodqty == '' || prodqty == '0') 109 { 110 alert('Please add product quantity'); 111 return false; 112 } 113 AddToCart(productID, prodqty); 114}); 115$(".btnwproduct").click(function(){ 116 var prodDetails = new Array(); 117 $(".wprodqty").each(function (index, ele) { 118 if($(this).val() != '' && $(this).val() != '0') 119 { 120 var ExpID = $(this).attr('id').split('_'); 121 var productID = ExpID[1]; 122 var prodqty = $(this).val(); 123 prodDetails.push({'productID' : productID, 'prodqty' : prodqty}); 124 } 125 }); 126 if(prodDetails.length > 0 ) 127 { 128 AddToCartForReorder(prodDetails); 129 } else { 130 alert('Please add quantity for product.'); 131 return false; 132 } 133}) 134 135$(document).on('click','#btnfreeSample', function(){ 136 137 var ProductIDVal = $('input[name="txtradio[]"]:checked').map(function() { 138 return $(this).val(); 139 }).get(); 140 141 var ProductID = ProductIDVal.toString().replace(/,/g, ','); 142 143 $.ajax({ 144 type: 'POST', 145 url: site_url + 'cart', 146 headers: { 147 'X-CSRF-TOKEN': token 148 }, 149 datatype: 'JSON', 150 data: { 151 action: 'FreeSample', 152 products_id: ProductID 153 }, 154 success: function (data) { 155 window.location.reload(); 156 } 157 }); 158}) 159 160$(document).on('click','#btnfreegift', function(){ 161 var ProductIDVal = $('input[name="txtradio[]"]:checked').map(function() { 162 return $(this).val(); 163 }).get(); 164 var FreeGiftProductID = $("#freeproductsid").val(); 165 var ProductID = ProductIDVal.toString().replace(/,/g, ','); 166 var currentPage = $("#checkout-page").length > 0 ? "checkout" : "cart"; 167 168 $.ajax({ 169 type: 'POST', 170 url: site_url + 'cart', 171 headers: { 172 'X-CSRF-TOKEN': token 173 }, 174 datatype: 'JSON', 175 data: { 176 action: 'FreeGift', 177 products_id: ProductID, 178 freeproductsid: FreeGiftProductID 179 }, 180 success: function (data) { 181 //window.location.href=site_url+"shoppingcart"; 182 $("#cover-spin").hide(); 183 if($("#Pagename").val()=="PaymentPage") 184 { 185 window.location.href = site_url + 'payment'; 186 } 187 else if (currentPage === "checkout") { 188 window.location.href = site_url + 'checkout'; 189 } else { 190 window.location.href = site_url + 'shoppingcart'; 191 } 192 } 193 }); 194}) 195$(document).on('click', ".cartItemDel, .shopcartItemDel", function () { 196 if(confirm('Are you sure you want to remove the item?')) 197 { 198 $("#page-spinner").show(); 199 var CartID = $(this).attr('data-index'); 200 var Page = "sidecart"; 201 if ($('.cart-table').length > 0) { 202 $("#page-spinner").show(); 203 Page = "Shopcart"; 204 } 205 $.ajax({ 206 type: 'POST', 207 url: site_url + 'cart', 208 headers: { 209 'X-CSRF-TOKEN': token 210 }, 211 datatype: 'JSON', 212 data: { 213 CartID: CartID, 214 action: 'remove', 215 }, 216 success: function (data) { 217 if(data.IsYotpoFreeProduct && data.IsYotpoFreeProduct == 'Yes') 218 { 219 $("#yotpo-loyalty-cart-data").attr('data-has-free-product',false); 220 } 221 GetCart(); 222 if (Page == "Shopcart") { 223 GetCartPartial(data.message); 224 } 225 226 if($("#cart_items").length > 0){ 227 window.location.reload(); 228 return; 229 } 230 $("#page-spinner").hide(); 231 DisplayPopupFreeGift(); 232 DisplayPopupSampleProducts(); 233 234 } 235 }); 236 } 237}); 238var showspinner = 'Y';
239$(document).on('click', '.cart-table .btn-number,#cart_items .btn-number',function (e) { 240 e.preventDefault(); 241 242 var $btn = $(this); 243 var $container; 244 if ($btn.closest('.cart-table').length) { 245 $container = $btn.closest('.cart-table'); 246 } else if ($btn.closest('#cart_items').length) { 247 $container = $btn.closest('#cart_items'); 248 } 249 250 fieldName = $(this).attr('data-field'); 251 type = $(this).attr('data-type'); 252 var input = $container.find("input[name='" + fieldName + "']"); //$(".cart-table input[name='" + fieldName + "']"); 253 var currentVal = parseInt(input.val()); 254 255 var rwUserType = $(this).attr('data-usertype'); 256 var userType = (typeof rwUserType === 'undefined' || rwUserType === '') ? 'retailer' : rwUserType.toLowerCase(); 257 var max = (userType === 'retailer') ? 20 : 9999; 258 if (!isNaN(currentVal)) { 259 if (type == 'minus') { 260 showspinner = 'Y'; 261 if (currentVal > input.attr('min')) { 262 input.val(currentVal - 1).change(); 263 } 264 if (parseInt(input.val()) == input.attr('min')) { 265 $(this).attr('disabled', true); 266 } 267 } 268 else if (type == 'plus') { 269 showspinner = 'Y'; 270 if (currentVal < max) { 271 newVal = currentVal + 1; 272 input.val(newVal).change(); 273 } else if (userType === 'retailer') { 274 showspinner = 'Y'; 275 newVal = currentVal + 1; 276 input.val(newVal).change(); 277 } 278 } 279 // else if (type == 'plus') { 280 // //if (currentVal < input.attr('max')) { 281 // input.val(currentVal + 1).change(); 282 // //} 283 // /*if (parseInt(input.val()) == input.attr('max')) { 284 // $(this).attr('disabled', true); 285 // }*/ 286 // } 287 } else { 288 input.val(0); 289 } 290}); 291$(document).on('click', '.cart-table .btn-number,#cart_items .btn-number', function () { 292 var ProductID = $(this).attr('data-product'); 293 //$("#page-spinner").show(); 294 if(showspinner == 'Y'){ 295 $("#page-spinner").show(); 296 } 297 298 var isFromMiniCart = $(this).closest('#shopcart').length > 0; 299 var from_mini_cart = 'N'; 300 if(isFromMiniCart == true){ 301 from_mini_cart = 'Y'; 302 } 303 304 //setTimeout(UpdateCart, 1000, ProductID); 305 setTimeout(function() { 306 UpdateCart(ProductID,'No', from_mini_cart); 307 }, 1000); 308}) 309 310$(document).on('input propertychange paste', '.cart-table .input-number,#cart_items .input-number', function () { 311 var ExpProd = $(this).attr('id').split('_'); 312 var ProductID = ExpProd[1]; 313 $("#page-spinner").show(); 314 315 var isFromMiniCart = $(this).closest('#shopcart').length > 0; 316 var from_mini_cart = 'N'; 317 if(isFromMiniCart == true){ 318 from_mini_cart = 'Y'; 319 } 320 setTimeout(function() { 321 UpdateCart(ProductID,'No', from_mini_cart); 322 }, 1000); 323 324 //setTimeout(UpdateCart, 1000, ProductID); 325}) 326 327$(document).on('click', '.clsgiftbox', function () { 328 var giftwrap = 'No'; 329 if ($(this).prop('checked')) { 330 giftwrap = 'Yes'; 331 } 332 var ProductID = $(this).attr('data-product'); 333 UpdateCart(ProductID, giftwrap); 334}) 335$(document).on('click', "#btncouponapply", function () { 336 ApplyCouponCode(); 337 $('html, body').animate({ 338 scrollTop: $("body").offset().top 339 }, 500); 340}); 341$(document).on('click', "#btncredit", function () { 342 ApplyCreditLimit(); 343 $('html, body').animate({ 344 scrollTop: $("body").offset().top 345 }, 500); 346}); 347$(document).on('click', "#btnremovecred", function () { 348 RemoveCreditLimit(); 349 $('html, body').animate({ 350 scrollTop: $("body").offset().top 351 }, 500); 352}); 353 354$(document).on('click', "#btngiftcard", function () { 355 ApplyGiftCoupon(); 356 $('html, body').animate({ 357 scrollTop: $("body").offset().top 358 }, 500); 359}); 360$(document).on('click', '.remdis', function () { 361 var dataid = $(this).attr('data-id'); 362 if(dataid == 'CouponDiscount') 363 { 364 RemoveCouponDiscount(); 365 } 366 if (dataid == 'GiftCoupon') { 367 RemoveGiftCoupon(); 368 } 369 if (dataid == 'YotpoRewardDiscount') { 370 RemoveYotpoRewardDiscount(); 371 } 372 373}) 374$(document).on("click",".max_coupon_box .coupan_boxhd", function(){ 375 $(this).parents(".max_coupon_box").toggleClass("active") 376}); 377function AddToCart(productID, prodqty, btnFrom = '') { 378 $("#page-spinner").show(); 379 var Page = $("main").attr('id'); 380 $.ajax({ 381 type: 'POST', 382 url: site_url + 'cart', 383 headers: { 384 'X-CSRF-TOKEN': token 385 }, 386 datatype: 'JSON', 387 data: { 388 products_id: productID, 389 prodqty: prodqty, 390 action: 'insert', 391 }, 392 success:function(data){ 393 //console.log(data) 394 $("#page-spinner").hide(); 395 if (btnFrom == 'buynow') { 396 window.location.href = site_url + 'billing'; 397 } else { 398 GetCart(); 399 400 $('#cart-open').animate({ 401 right: '0px' 402 }); 403
404 if($('#cart-open').is(':visible')){ 405 $('body').addClass('slide-open'); 406 }else{ 407 $('body').removeClass('slide-open'); 408 } 409 410 //$('body').toggleClass('slide-open'); 411 412 var getPage = ''; 413 414 if ($('.cart-table').length > 0) { 415 $("#page-spinner").show(); 416 getPage = "Shopcart"; 417 } 418 419 if (getPage == "Shopcart") { 420 if ($("#shopcartpage").length > 0 || $("#checkout-page").length > 0) { 421 GetCartPartial(); 422 } else { 423 GetCartPartial('','', 'add_to_cart'); 424 } 425 //window.location.reload(); 426 } 427 428 //////// 429 //getRecommendedSideCart(); 430 //////// 431 432 /*setTimeout(function() { 433 setIntelliSuggestTrackingCart(); 434 }, 1000);*/ 435 } 436 } 437 }); 438} 439 440function AddToCartForYotpoFreeGift(products_id,yotpo_free_gift_coupon) { 441 var added = false; 442 $.ajax({ 443 type: 'POST', 444 url: site_url + 'cart', 445 headers: { 446 'X-CSRF-TOKEN': token 447 }, 448 datatype: 'JSON', 449 data: { 450 products_id: products_id, 451 action: 'yotpo_free_gift_insert', 452 yotpo_free_gift_coupon: yotpo_free_gift_coupon, 453 }, 454 async : false, 455 success: function (data) { 456 GetCart(); 457 $('#cart-open').animate({ 458 right: '0px' 459 }); 460 $('body').toggleClass('slide-open'); 461 462 if(data.Added && parseInt(data.Added) == 1) 463 { 464 added = true; 465 } else { 466 added = false; 467 } 468 } 469 }); 470 return added; 471} 472 473function AddToCartForReorder(prodDetails) { 474 $.ajax({ 475 type: 'POST', 476 url: site_url + 'cart', 477 headers: { 478 'X-CSRF-TOKEN': token 479 }, 480 datatype: 'JSON', 481 data: { 482 prodDetails: prodDetails, 483 action: 'reorder', 484 }, 485 success: function (data) { 486 GetCart(); 487 $('#cart-open').animate({ 488 right: '0px' 489 }); 490 $('body').toggleClass('slide-open'); 491 } 492 }); 493} 494function UpdateCart(ProductID, giftwrap = 'No', is_from_minicart = 'N') { 495 var prodqty = $("#prodqty_" + ProductID).val(); 496 if(is_from_minicart == 'N' && $('.cartitem').find('#prodqty_' + ProductID).length > 0){ 497 prodqty = $('.cartitem').find('#prodqty_' + ProductID).val(); //$("#prodqty_" + ProductID).attr('data-qty'); 498 } 499 //$("#page-spinner").show(); 500 if(prodqty != '' && prodqty <= 0){ 501 $("#prodqty_" + ProductID).val("1"); 502 prodqty = 1; 503 } 504 if(showspinner == 'Y'){ 505 $("#page-spinner").show(); 506 } 507 var isMiniCart = 'N'; 508 var isCheckoutPage = 'N'; 509 var isShoppingCartPage = 'N'; 510 if($("#isMiniCart").length > 0){ 511 isMiniCart = 'Y'; 512 } 513 if($("#cart_items").length > 0){ 514 isCheckoutPage = 'Y'; 515 } 516 if($(".cartpage-page").length > 0) 517 { 518 isShoppingCartPage = 'Y'; 519 } 520 $.ajax({ 521 type: 'POST', 522 url: site_url + 'cart', 523 headers: { 524 'X-CSRF-TOKEN': token 525 }, 526 datatype: 'JSON', 527 data: { 528 products_id: ProductID, 529 prodqty: prodqty, 530 giftwrap: giftwrap, 531 action: 'update', 532 }, 533 success: function (data) { 534 if(isCheckoutPage == 'Y'){ 535 window.location.reload(); 536 return; 537 // if (data.CartErrors) { 538 // window.location.href = site_url + 'shoppingcart'; 539 // return 540 // } else { 541 // window.location.reload(); 542 // return; 543 // } 544 } 545 if (data.CartErrors) { 546 var msg = ''; 547 for (var i = 0; i < data.CartErrors.length; i++) { 548 msg += data.CartErrors[i] + '<br>'; 549 } 550 551 var $input = $('#shopcartinfo').find('#prodqty_'+ProductID); 552 if ($input.length) { 553 var cart_old_qty = $input.attr('data-qty'); 554 $input.val(cart_old_qty); 555 } 556 557 var OldQty = $("#prodqty_" + ProductID).attr('data-qty'); 558 $("#prodqty_" + ProductID).val(OldQty); 559 560 if ($('#cart-open').css('right') === '0px') { 561 if($("#sidec.sp-content").length > 0){ 562 $("#sidec.sp-content").html('<div class="alert alert-danger" role="alert" style="">'+msg+'</div>'); 563 } 564 } 565 566 ShowMsg('error_cart', msg); 567 $("#page-spinner").hide(); 568 } else { 569 GetCart(); 570 if(isShoppingCartPage == 'Y' || isCheckoutPage == 'Y') 571 { 572 GetCartPartial(); 573 } else { 574 GetCartPartial('','','update_side_cart'); 575 } 576 DisplayPopupFreeGift(); 577 DisplayPopupSampleProducts(); 578 } 579 } 580 }); 581} 582function GetCartPartial(message = '',msgtype='', pageFrom='') { 583 $.ajax({ 584 type: 'POST', 585 url: site_url + 'getshopcart', 586 headers: { 587 'X-CSRF-TOKEN': token 588 }, 589 datatype: 'JSON', 590 data: { 591 pageFrom: pageFrom, 592 }, 593 success: function (data) { 594 if (data.TotalItemInCart > 0) { 595 $("#alldata").html(data.Cart); 596 $("#cartsubtotal").html(data.SubtotalBoxHTML); 597 //$("#checkoutbox").html(data.CheckoutBoxHTML); 598 $("#credcoupboxes").html(data.CreditCouponBoxesHtml); 599 $("#page-spinner").hide(); 600 $("#shoptotal").html(data.Total); 601 602 $("#setSectionMainCart").html(data.allSectionRecommendedPrds); 603 604 //Show Bogo Discount Message 605 $("#shopcart").html(data.SideCartHTML); 606 //Show Bogo Discount Message 607 608 if(msgtype == 'error') 609 ShowMsg('error_cart', message); 610 else 611 ShowMsg('cart_msg', message); 612 //AfterpaySetup(); 613 } else { 614 $("#shopcart").html(data.SideCartHTML); 615 $("#shopcartpage").html(data.EmptyCartHTML); 616 $("#setSectionMainCart").hide(); 617 } 618 $("#page-spinner").hide(); 619 } 620 }); 621 return true; 622} 623function GetCart() { 624 $.ajax({ 625 type: 'POST', 626 url: site_url + 'getcart', 627 headers: { 628 'X-CSRF-TOKEN': token 629 }, 630 async:false, 631 datatype: 'JSON', 632 data: { 633 cartpopup: 1, 634 }, 635 success: function (data) { 636 $("#shopcart").html(data.ShoppingCart); 637 var TotalItemInCart = data.TotalItemInCart; 638 if (TotalItemInCart == 0) 639 TotalItemInCart = ''; 640 if(TotalItemInCart != '' && TotalItemInCart > 0) 641 { 642 $(".cart-qty").show(); 643 $(".cart-qty").html(TotalItemInCart); 644 } else { 645 $(".cart-qty").hide(); 646 $(".cart-qty").html(TotalItemInCart); 647 } 648
649 //////// 650 /*setTimeout(function() { 651 //getRecommendedSideCart(); 652 console.log($('.mini-products-slider').length); 653 654 if (typeof $.fn.slick === 'function') { 655 console.log("script loaded"); 656 } 657 658 $('.mini-products-slider').slick(); 659 }, 2000); */ 660 //////// 661 662 /* 663 if(data.MerchantID && data.MerchantID != '' ) 664 { 665 var authRequest; 666 OffAmazonPayments.Button("AmazonPayButtonAll", data.MerchantID, { 667 type: "PwA", 668 size: "large", 669 authorization: function () { 670 loginOptions = { scope: "profile postal_code payments:widget payments:shipping_address", popup: true }; 671 authRequest = amazon.Login.authorize(loginOptions, data.CallBackURL); 672 }, 673 onError: function (error) { 674 // something bad happened 675 } 676 }); 677 } 678 */ 679 } 680 }); 681} 682function ClearBag() { 683 if(confirm('Are you sure you want to remove all items?')) 684 { 685 $.ajax({ 686 type: 'POST', 687 url: site_url + 'cart', 688 headers: { 689 'X-CSRF-TOKEN': token 690 }, 691 datatype: 'JSON', 692 data: { 693 action: 'clear_bag', 694 }, 695 success: function (data) { 696 window.location.reload(); 697 } 698 }); 699 } 700} 701function ApplyCouponCode() { 702 var coupon_number = $("#coupon_number").val(); 703 if (coupon_number == "") { 704 alert("Please enter coupon"); 705 return false; 706 } 707 $("#page-spinner").show(); 708 $.ajax({ 709 type: 'POST', 710 url: site_url + 'cart', 711 headers: { 712 'X-CSRF-TOKEN': token 713 }, 714 datatype: 'JSON', 715 data: { 716 coupon_number: coupon_number, 717 action: 'apply_coupon', 718 }, 719 success: function (data) { 720 if (data.CartErrors) { 721 $("#page-spinner").hide(); 722 } else { 723 if(!$("#btncouponapply").hasClass('checkout')) 724 { 725 GetCart(); 726 var msgType = ''; 727 if(data.error && data.error == 1) 728 msgType = 'error'; 729 GetCartPartial(data.message,msgType); 730 $("#page-spinner").hide(); 731 } else { 732 window.location.reload(); 733 } 734 } 735 } 736 }); 737} 738 739function ApplyCreditLimit() { 740 $("#page-spinner").show(); 741 $.ajax({ 742 type: 'POST', 743 url: site_url + 'cart', 744 headers: { 745 'X-CSRF-TOKEN': token 746 }, 747 datatype: 'JSON', 748 data: { 749 action: 'apply_credit_limit', 750 }, 751 success: function (data) { 752 if (data.CartErrors) { 753 $("#page-spinner").hide(); 754 } else { 755 GetCart(); 756 GetCartPartial(data.message); 757 if(data.NetTotal > 0) 758 { 759 $("#Paymethods").show(); 760 } else { 761 $("#Paymethods").hide(); 762 } 763 } 764 } 765 }); 766} 767function RemoveCreditLimit() { 768 $("#page-spinner").show(); 769 $.ajax({ 770 type: 'POST', 771 url: site_url + 'cart', 772 headers: { 773 'X-CSRF-TOKEN': token 774 }, 775 datatype: 'JSON', 776 data: { 777 action: 'remove_credit_limit', 778 }, 779 success: function (data) { 780 if (data.CartErrors) { 781 $("#page-spinner").hide(); 782 } else { 783 GetCart(); 784 GetCartPartial(data.message); 785 if(data.NetTotal > 0) 786 { 787 $("#Paymethods").show(); 788 } else { 789 $("#Paymethods").hide(); 790 } 791 } 792 } 793 }); 794} 795function ApplyGiftCoupon() { 796 var giftcard = $("#txtgiftcard").val(); 797 if (giftcard == "") { 798 alert("Please enter gift card"); 799 return false; 800 } 801 $("#page-spinner").show(); 802 $.ajax({ 803 type: 'POST', 804 url: site_url + 'cart', 805 headers: { 806 'X-CSRF-TOKEN': token 807 }, 808 datatype: 'JSON', 809 data: { 810 giftcard: giftcard, 811 action: 'apply_gift_coupon', 812 }, 813 success: function (data) { 814 if(!$("#btncouponapply").hasClass('checkout')) 815 { 816 817 GetCart(); 818 var msgType = ''; 819 if(data.error && data.error == 1) 820 msgType = 'error'; 821 GetCartPartial(data.message,msgType); 822 } else { 823 window.location.reload(); 824 } 825 } 826 }); 827} 828 829function RemoveCouponDiscount() { 830 $("#page-spinner").show(); 831 $.ajax({ 832 type: 'POST', 833 url: site_url + 'cart', 834 headers: { 835 'X-CSRF-TOKEN': token 836 }, 837 datatype: 'JSON', 838 data: { 839 action: 'remove_coupon', 840 }, 841 success: function (data) { 842 if (data.CartErrors) { 843 $("#page-spinner").hide(); 844 } else { 845 if($(".remdis").hasClass('checkout')) 846 { 847 window.location.reload(); 848 } else { 849 GetCart(); 850 GetCartPartial(data.message); 851 } 852 } 853 } 854 }); 855} 856 857function RemoveYotpoRewardDiscount() { 858 $("#page-spinner").show(); 859 $.ajax({ 860 type: 'POST', 861 url: site_url + 'cart', 862 headers: { 863 'X-CSRF-TOKEN': token 864 }, 865 datatype: 'JSON', 866 data: { 867 action: 'remove_yotporeward', 868 }, 869 success: function (data) { 870 if (data.CartErrors) { 871 $("#page-spinner").hide(); 872 } else { 873 if($(".remdis").hasClass('checkout')) 874 { 875 window.location.reload(); 876 } else { 877 GetCart(); 878 GetCartPartial(data.message); 879 } 880 881 } 882 } 883 }); 884} 885 886function RemoveGiftCoupon() { 887 $("#page-spinner").show(); 888 $.ajax({ 889 type: 'POST', 890 url: site_url + 'cart', 891 headers: { 892 'X-CSRF-TOKEN': token 893 }, 894 datatype: 'JSON', 895 data: { 896 action: 'remove_gift_coupon', 897 }, 898 success: function (data) { 899 if (data.CartErrors) { 900 $("#page-spinner").hide(); 901 } else { 902 if($(".remdis").hasClass('checkout')) 903 { 904 window.location.reload(); 905 } else { 906 GetCart(); 907 GetCartPartial(data.message); 908 } 909 } 910 } 911 }); 912} 913 914function ShowMsg(msgid, message) { 915 if (message != '') { 916 $("#" + msgid).show().html(message); 917 } 918} 919
920function DisplayPopupSampleProducts(){ 921 if ($("#shopcartpage").length > 0 || $("#checkout-page").length > 0) { 922 var token = $('meta[name="csrf-token"]').attr('content'); 923 $.ajax({ 924 type: 'POST', 925 url: site_url + 'get_freesample_products', 926 data: { }, 927 headers: { 928 'X-CSRF-TOKEN': token 929 }, 930 success: function (data) { 931 if (data) { 932 if (typeof $.fn.modal === 'undefined') { 933 $.getScript(modal_js, function () { 934 $("#cover-spin").hide(); 935 $("#FreeSampleProductsViewPopup").html(data); 936 $("#FreeSampleProductsViewPopup").modal('show'); 937 }); 938 } 939 else 940 { 941 $("#cover-spin").hide(); 942 $("#FreeSampleProductsViewPopup").html(data); 943 $("#FreeSampleProductsViewPopup").modal('show'); 944 } 945 } 946 } 947 }); 948 } 949} 950 951function DisplayPopupFreeGift() { 952 if ($("#shopcartpage").length > 0 || $("#checkout-page").length > 0) { 953 //var TotalValue = parseFloat($(".business_page").attr('data-total')); 954 //if (TotalValue > 0) { 955 var token = $('meta[name="csrf-token"]').attr('content'); 956 $("#FreeGiftViewPopup").html(''); 957 $("#cover-spin").show(); 958 $.ajax({ 959 type: 'POST', 960 url: site_url + 'get_freegift_products', 961 data: { }, 962 headers: { 963 'X-CSRF-TOKEN': token 964 }, 965 success: function (data) { 966 if (data) { 967 968 if (typeof $.fn.modal === 'undefined') { 969 $.getScript(modal_js, function () { 970 $("#cover-spin").hide(); 971 $("#FreeGiftViewPopup").html(data); 972 $("#FreeGiftViewPopup").modal('show'); 973 }); 974 } 975 else 976 { 977 $("#cover-spin").hide(); 978 $("#FreeGiftViewPopup").html(data); 979 $("#FreeGiftViewPopup").modal('show'); 980 } 981 982 } 983 } 984 }); 985 //} 986 } 987} 988 989/* 990function loadIntelliSuggestTrackingScript(lib) { 991 var script = document.createElement('script'); 992 script.type = 'text/javascript'; 993 script.setAttribute('src', lib); 994 document.getElementsByTagName('head')[0].appendChild(script); 995 return script; 996} 997 998function isLoadedScript(lib) { 999 return document.querySelectorAll('[src="' + lib + '"]').length > 0 1000} 1001 1002$(".header_icon .cart-link").click(function() { 1003 setIntelliSuggestTrackingCart(); 1004}); 1005 1006function setIntelliSuggestTrackingCart(){ 1007 $.ajax({ 1008 type: 'POST', 1009 url: site_url + 'setIntelliSuggestTrackingCart', 1010 headers: { 1011 'X-CSRF-TOKEN': token 1012 }, 1013 datatype: 'JSON', 1014 data: { 1015 }, 1016 success: function (data) { 1017 //console.log(data); 1018 if(data != ''){ 1019 1020 if (!isLoadedScript('//cdn.searchspring.net/intellisuggest/is.min.js')) { 1021 loadScript(lib); 1022 document.head.appendChild(script); 1023 } 1024 1025 var getData = data.split("@@@"); 1026 var mySkuArr = JSON.parse(getData[0]); 1027 var myIDArr = JSON.parse(getData[1]); 1028 var myPriceArr = JSON.parse(getData[2]); 1029 var myQtyArr = JSON.parse(getData[3]); 1030 var skus = getData[4]; 1031 1032 try{ 1033 IntelliSuggest.init({siteId: 'faltym', context: 'Basket', seed: [skus]}); 1034 1035 for(var i=0;i<mySkuArr.length;i++){ 1036 IntelliSuggest.haveItem({ 1037 uid: myIDArr[i], 1038 childUid: '', 1039 sku: mySkuArr[i], 1040 childSku: '', 1041 price: myPriceArr[i], 1042 qty: myQtyArr[i] 1043 }); 1044 } 1045 IntelliSuggest.setCurrency({ code: 'USD' }); 1046 IntelliSuggest.inBasket({}); 1047 } catch(err) {} 1048 } 1049 } 1050 }); 1051} 1052*/ 1053 1054function getRecommendedSideCart(){ 1055 $('.mini-products-slider').on('init', function(event, slick){ 1056 $('.cover-spin').hide(); 1057 //$('.sectionMiniCart').find(".cover-spin").hide(); 1058 }); 1059 1060 $('.mini-products-slider').slick({ 1061 lazyLoad: 'ondemand', 1062 dots: true, 1063 infinite: false, 1064 speed: 300, 1065 arrows: true, 1066 centerMode: true, 1067 centerPadding: '0', 1068 slidesToShow: 1, 1069 slidesToScroll: 2, 1070 /*responsive: [ 1071 { breakpoint: 1600, settings: { slidesToShow: 5, slidesToScroll: 5 } }, 1072 { breakpoint: 1200, settings: { slidesToShow: 4, slidesToScroll: 4 } }, 1073 { breakpoint: 992, settings: { slidesToShow: 3, slidesToScroll: 3 } }, 1074 { breakpoint: 768, settings: { slidesToShow: 2, slidesToScroll: 2 } } 1075 ],*/ 1076 nextArrow: '<button class="slick-next round-btn-sl" aria-label="Next recommended product"><svg class="svg svg-slick-right" aria-hidden="true" width="24" height="24" role="img"><use href="#sv-right-arrow" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#sv-right-arrow"></use></svg></button>', 1077 prevArrow: '<button class="slick-prev round-btn-sl" aria-label="Previous recommended product"><svg class="svg svg-slick-left" width="24" height="24" aria-hidden="true" role="img"><use href="#sv-left-arrow" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#sv-left-arrow"></use></svg></button>', 1078 }); 1079}
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.