1jQuery(function ($) { 2 if (typeof wp !== "undefined" && wp.hooks) { 3 wp.hooks.addAction( 4 "experimental__woocommerce_blocks-cart-set-item-quantity", 5 "core/i18n", 6 function (name, functionName, callback, priority) { 7 setTimeout(function () { 8 window.location.reload(); 9 }, 3000); 10 }, 11 10 12 ); 13 14 wp.hooks.addAction( 15 "experimental__woocommerce_blocks-cart-remove-item", 16 "core/i18n", 17 function (name, functionName, callback, priority) { 18 setTimeout(function () { 19 window.location.reload(); 20 }, 3000); 21 }, 22 10 23 ); 24 } 25 26 if (typeof window.wc !== "undefined" && window.wc.blocksCheckout) { 27 const { registerCheckoutFilters } = window.wc.blocksCheckout; 28 const wpcdCartItemClass = (defaultValue, extensions, args) => { 29 const key = "_free_gift"; 30 const value = "yes"; 31 if (args && args.cartItem && args.cartItem.item_data) { 32 if (WPCDHasKeyValuePair(args.cartItem.item_data, key, value)) { 33 return defaultValue + "wpcd-free-gift-class"; 34 } 35 } 36 return defaultValue; 37 }; 38 registerCheckoutFilters("woo-product-category-discount", { 39 cartItemClass: wpcdCartItemClass, 40 }); 41 } 42 43 function WPCDHasKeyValuePair(array, key, value) { 44 for (let i = 0; i < array.length; i++) { 45 if (array[i].key === key && array[i].value === value) { 46 return true; 47 } 48 } 49 return false; 50 } 51});
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.