1(function($){$(function(){$('body').on('click','.wdt-add-to-cart-button',function(e){e.preventDefault();let tableId=Number(this.dataset.value);let tableSelector=$('table.wpDataTable[data-wpdatatable_id='+tableId+']').get(0).id;let selectedRows=wpDataTables[tableSelector].DataTable().rows({selected:!0}).data();let selectedIndexes=wpDataTables[tableSelector].DataTable().rows({selected:!0}).indexes();let productColumnIndex=getColumnIndexByHeader('product_id',tableSelector) 2let productIds=[];selectedRows.each(function(value){let cleanedValue=value[productColumnIndex].replace(/[^\d]/g,'');productIds.push(parseInt(cleanedValue,10))});var button=this;setButtonLoadingState(button,!0);if(productIds.length>0){$.ajax({url:wdt_ajax_object.ajaxurl,type:'POST',data:{wdtNonce:$('#wdtNonce').val(),action:'wpdatatables_add_multiple_products_to_cart',productIds:productIds},success:function(data){if(data.success){updateCartInfo();selectedRows.each(function(value,index){let product_id=productIds[index];let cartHtml=` 3 <div class="wdt-woo-mini-cart" name="wdt-woo-mini-cart"> 4 <a href="${data.data.cart_url}" class="wdt-woo-mini-cart-icon"> 5 <i class="wpdt-icon-cart"></i> 6 <span class="wdt-woo-cart-quantity">`+data.data.product_quantities[product_id]+`</span> 7 </a> 8 </div> 9 `;let table=wpDataTables[tableSelector].DataTable();let columnIndex=getColumnIndexByHeader('add_to_cart_button',tableSelector);let rowId=wpDataTables[tableSelector].DataTable().rows({selected:!0}).indexes()[index];let currentContent=table.cell(rowId,columnIndex).node();if(!currentContent.children.namedItem('wdt-woo-mini-cart')){$(currentContent).append(cartHtml)}else{$(currentContent).find('.wdt-woo-mini-cart').find('span.wdt-woo-cart-quantity').text(data.data.product_quantities[product_id])}});setButtonLoadingState(button,!1)}else{wdtNotify(wpdatatables_frontend_strings.error_wpdatatables,wpdatatables_frontend_strings.error_adding_to_cart_wpdatatables,'danger') 10setButtonLoadingState(button,!1)}},error:function(){wdtNotify(wpdatatables_frontend_strings.error_wpdatatables,wpdatatables_frontend_strings.error_adding_to_cart_wpdatatables,'danger') 11setButtonLoadingState(button,!1)}})}else{wdtNotify(wpdatatables_frontend_strings.error_wpdatatables,wpdatatables_frontend_strings.select_products_for_cart_wpdatatables,'danger') 12setButtonLoadingState(button,!1)}});function updateCartInfo(){$.ajax({url:wdt_ajax_object.ajaxurl,type:'POST',data:{action:'wpdatatables_get_cart_info',},success:function(data){if(data.success){$('.cart-count').html(data.data.item_count);$('.cart-total').html(data.data.total_sum);if(!$('.cart-info').is(':visible')&&data.data.total_sum){$('.cart-info').show()}}},error:function(){wdtNotify(wpdatatables_frontend_strings.error_wpdatatables,wpdatatables_frontend_strings.error_fetching_cart_info_wpdatatables,'danger')}})} 13$('body').on('click','.single_add_to_cart_button',function(e){e.preventDefault();let tableId=Number(this.dataset.value);let tableSelector=$('table.wpDataTable[data-wpdatatable_id='+tableId+']').get(0).id;let button=$(this);let productId=parseInt(button.data('product_id').toString().replace(/[^\d]/g,''),10);let quantity=button.closest('.wdt-woo-product').find('input[name="quantity"]').val();let variations={};var buttonLoader=this;setButtonLoadingState(buttonLoader,!0);button.closest('.wdt-woo-variable-product').find('.wdt-woo-variation-selector').each(function(){let attributeName='attribute_'+$(this).data('attribute-name');let attributeValue=$(this).val();variations[attributeName]=attributeValue});let rowId=button.closest('tr')[0]._DT_RowIndex;$.ajax({url:wdt_ajax_object.ajaxurl,type:'POST',data:{action:'wpdatatables_add_single_product_to_cart',product_id:productId,quantity:quantity,variations:variations,},success:function(data){if(data.success){if(data.data.notAdded){wdtNotify(wpdatatables_frontend_strings.error_wpdatatables,wpdatatables_frontend_strings.could_not_add_to_cart_wpdatatables,'danger') 14setButtonLoadingState(buttonLoader,!1);return} 15updateCartInfo();let cartHtml=` 16 <div class="wdt-woo-mini-cart" name="wdt-woo-mini-cart"> 17 <a href="${data.data.cart_url}" class="wdt-woo-mini-cart-icon"> 18 <i class="wpdt-icon-cart"></i>
19 <span class="wdt-woo-cart-quantity">${data.data.product_quantities}</span> 20 </a> 21 </div> 22 `;let table=wpDataTables[tableSelector].DataTable();let columnIndex=getColumnIndexByHeader('add_to_cart_button',tableSelector) 23let currentContent=table.cell(rowId,columnIndex).node();if(!currentContent.children.namedItem('wdt-woo-mini-cart')){$(currentContent).append(cartHtml)}else{$(currentContent).find('.wdt-woo-mini-cart').find('span.wdt-woo-cart-quantity').text(data.data.product_quantities)} 24setButtonLoadingState(buttonLoader,!1)}else{setButtonLoadingState(buttonLoader,!1);wdtNotify(wpdatatables_frontend_strings.error_wpdatatables,wpdatatables_frontend_strings.error_adding_to_cart_wpdatatables,'danger')}}})});$('body').on('change','.wdt-woo-product-attribute',function(){let $row=$(this).closest('.wdt-woo-variable-product');let allSelected=!0;$row.find('.wdt-woo-product-attribute').each(function(){if(!$(this).val()){allSelected=!1}});if(allSelected){$row.find('.single_add_to_cart_button').prop('disabled',!1)}else{$row.find('.single_add_to_cart_button').prop('disabled',!0)}});$('body').on('change','.wdt-woo-variation-selector',function(){let allSelected=!0;$(this).closest('.wdt-woo-variable-product').find('.wdt-woo-variation-selector').each(function(){if($(this).val()===''){allSelected=!1}});let addToCartButton=$(this).closest('.wdt-woo-variable-product').find('.single_add_to_cart_button');if(allSelected){addToCartButton.prop('disabled',!1)}else{addToCartButton.prop('disabled',!0)}});$('body').on('change','.wdt-woo-product-quantity',function(){let quantity=$(this).val();if(quantity<1){$(this).val(1)}});$('body').on('change','#wdt-shot-woo-cart-information',function(e){wpdatatable_config.setShowCartInformation($(this).is(':checked')?1:0)});setTimeout(function(){$('.wdt-woo-variable-product').each(function(){let allPreselected=!0;$(this).find('.wdt-woo-variation-selector').each(function(){let preselectedValue=$(this).find('option[selected]').val();if(preselectedValue){$(this).val(preselectedValue)}else{allPreselected=!1}});let addToCartButton=$(this).find('.single_add_to_cart_button');if(allPreselected){addToCartButton.prop('disabled',!1)}})},500);function getColumnIndexByHeader(originalHeader,selector){let table=wpDataTables[selector].DataTable();let columnIndex=-1;table.columns().every(function(index){let classList=this.header().classList;let columnClass=Array.from(classList).find(cls=>cls.startsWith('column-'));let headerText=columnClass?columnClass.slice(7):null;if(headerText===originalHeader){columnIndex=index}});return columnIndex} 25function setButtonLoadingState(buttonElement,isLoading=!0){const buttonText=buttonElement.querySelector('.wdt-woo-button-text');const loader=buttonElement.querySelector('.wdt-woo-loader');if(isLoading){buttonElement.classList.add('disabled');if(buttonText)buttonText.style.opacity='0.5';if(loader)loader.style.display='inline-block'}else{buttonElement.classList.remove('disabled');if(buttonText)buttonText.style.opacity='1';if(loader)loader.style.display='none'}}})})(jQuery)
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.