1const { registerCheckoutFilters } = window.wc.blocksCheckout; 2 3 4const modifyItemName = ( defaultValue, extensions, args ) => { 5 const isCartContext = args?.context === 'summary'; 6 7 if ( ! isCartContext ) { 8 return defaultValue; 9 } 10 11 if (extensions.plugify_ucoc_extra_data.is_rule_applied === true) { 12 13 const key = args?.cartItem.key; 14 const quantity = args?.cartItem.quantity; 15 const prodName = extensions.plugify_ucoc_extra_data.prod_name; 16 const clrfrtrsh = extensions.plugify_ucoc_extra_data.clrfrtrsh; 17 const trashIcon = extensions.plugify_ucoc_extra_data.trash_icon; 18 19 const trash_icon = `<i prod_name="${prodName}" 20 style="color: ${clrfrtrsh}; cursor:pointer;" 21 class="fa fa-${trashIcon} remove-icon" is_block="true" aria-hidden="true"> 22 <button style="display:none;" class="finded" id="finded" value="${key}">Remove</button> 23 </i>`; 24 25 const quantity_selector = `<br> 26 <div class="wc-block-componenets-text-input" data-key="${key}" style="display: inline-flex; align-items: center; gap: 0; "> 27 <button class="qty-minus" data-action="decrease" 28 style="padding: 4px 8px; border: 2px solid black; border-right:unset; background: #fff; border-radius: 4px 0 0 4px; cursor: pointer;outline: none; "> 29 â 30 </button> 31 <input type="text" class="pro_quantity" 32 value="${quantity}" min="1" 33 cartitemattr="${key}" prod_name="${prodName}" 34 style=" padding: 4px 8px; text-align: center; border:2px solid black; border-right:unset; border-left:unset; background:#fff; outline: none; box-shadow:none;" /> 35 <button class="qty-plus" data-action="increase" 36 style="padding: 4px 8px; border: 2px solid black; border-left:unset; background: #fff; border-radius: 0 4px 4px 0; cursor: pointer; outline: none;"> 37 ï¼ 38 </button> 39 </div> 40 `; 41 42 43 return `${trash_icon} ${defaultValue} ${quantity_selector}`; 44 } 45 46 return defaultValue; 47}; 48 49registerCheckoutFilters( 'plugify-ucoc-block', { 50 itemName: modifyItemName, 51}); 52 53document.addEventListener('click', function (e) { 54 55 const isMinus = e.target.classList.contains('qty-minus'); 56 const isPlus = e.target.classList.contains('qty-plus'); 57 58 if (isMinus || isPlus) { 59 const button = e.target; 60 const container = button.closest('.wc-block-componenets-text-input'); 61 if (!container) return; 62 63 const input = container.querySelector('input.pro_quantity'); 64 let currentValue = parseInt(input.value, 10) || 1; 65 66 if (isPlus) { 67 currentValue += 1; 68 } else if (isMinus && currentValue > 1) { 69 currentValue -= 1; 70 } 71 72 input.value = currentValue; 73 74 input.dispatchEvent(new Event('change', { bubbles: true })); 75 76 button.blur(); 77 } 78});
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.