1jQuery(document).ready(function() { 2 //console.log(FGWWdata.showslider_item_desktop); 3 //add to cart click action 4 document.querySelectorAll('.fgw_gift_atc_btn a').forEach(function(anchor) { 5 anchor.addEventListener('click', function(event) { 6 event.preventDefault(); // Prevent the default action 7 var redirectUrl = this.getAttribute('data-href'); // Get the URL from data-href 8 if (redirectUrl) { // Ensure redirectUrl is not null or empty 9 window.location.href = redirectUrl; // Redirect to the URL 10 } else { 11 console.warn('No redirect URL found'); 12 } 13 }); 14 }); 15 16 jQuery('body').on('click', '.fgw_gift_btn', function() { 17 18 if (jQuery(".fgw_gift_div").length > 0) { 19 jQuery('html, body').animate({scrollTop: jQuery('.fgw_gift_div').offset().top - 100}, 'fast'); 20 } else { 21 jQuery('body').addClass("fgw_body_gift"); 22 jQuery('#fgw_gifts_popup').css('display', 'block'); 23 jQuery('.fgw_gifts_popup_overlay').css("display", "block"); 24 } 25 26 return false; 27 }); 28 29 jQuery('body').on('click', '.fgw_gifts_popup_close', function() { 30 jQuery("#fgw_gifts_popup").css("display", "none"); 31 jQuery('.fgw_gifts_popup_overlay').css("display", "none"); 32 jQuery('body').removeClass("fgw_body_gift"); 33 }); 34 35 jQuery('body').on('click', '.fgw_gifts_popup_overlay', function() { 36 jQuery("#fgw_gifts_popup").css("display", "none"); 37 jQuery('.fgw_gifts_popup_overlay').css("display", "none"); 38 jQuery('body').removeClass("fgw_body_gift"); 39 }); 40 41 if (typeof window.wc !== 'undefined' && window.wc.blocksCheckout) { 42 const { registerCheckoutFilters } = window.wc.blocksCheckout; 43 const FGWP_modifyCartItemClass = ( defaultValue, extensions, args ) => { 44 if (args && args.cartItem && args.cartItem.item_data) { 45 console.log(args.cartItem.item_data); 46 const keyToCheck = "Free"; 47 const valueToCheck = "Yes"; 48 if (FGWP_hasKeyValuePair(args.cartItem.item_data, keyToCheck, valueToCheck)) { 49 return defaultValue+ 'FGWP-gift-class'; 50 } 51 } 52 return defaultValue; 53 }; 54 const FGWP_modifyCartItemPrice = ( defaultValue, extensions, args ) => { 55 if (args && args.cartItem && args.cartItem.item_data) { 56 console.log('defaultValue: ', defaultValue); 57 const keyToCheck = "Free"; 58 const valueToCheck = "Yes"; 59 if (FGWP_hasKeyValuePair(args.cartItem.item_data, keyToCheck, valueToCheck)) { 60 return '<price/>Free'; 61 } 62 } 63 return defaultValue; 64 }; 65 registerCheckoutFilters( 'free-gift-checkout', { 66 cartItemClass: FGWP_modifyCartItemClass, 67 cartItemPrice: FGWP_modifyCartItemPrice, 68 }); 69 70 } 71 72 if (typeof wp !== 'undefined' && wp.hooks) { 73 wp.hooks.addAction("experimental__woocommerce_blocks-cart-set-item-quantity", "core/i18n", 74 function (name, functionName, callback, priority) { 75 // console.log("sdgfdg"); 76 setTimeout(function(){ 77 window.location.reload(); 78 }, 3000); 79 }, 80 10 81 ); 82 83 wp.hooks.addAction("experimental__woocommerce_blocks-cart-remove-item", "core/i18n", 84 function (name, functionName, callback, priority) { 85 // console.log("sdgfdg"); 86 setTimeout(function(){ 87 window.location.reload(); 88 }, 3000); 89 }, 90 10 91 ); 92 } 93 }); 94 95function FGWP_hasKeyValuePair(array, key, value) { 96 for (let i = 0; i < array.length; i++) { 97 if (array[i].key === key && array[i].value === value) { 98 return true; 99 } 100 } 101 return false;
vendor: 1 bytes, line 102
102}
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.