You can modify the settings of a variations datatable with our filter. The filter to use is “woocommerce_variations_table_datatables_options”.
In this example for the product ID 581 we disable the filtering and for product 605 we enable paging.
add_filter( 'woocommerce_variations_table_datatables_options', 'datatable_options', 10, 1 ); function datatable_options($options) { global $product; $product_id = $product->get_id(); if($product_id == 581) { $options['searching'] = true; $options['filtering'] = false; $options['buttons'] = array(); } if($product_id == 605) { $options['searching'] = true; $options['filtering'] = false; $options['paging'] = true; $options['ScrollCollapse'] = true; $options['scrollY'] = '450px'; $options['buttons'] = array(); } return $options; }
What would be the option to disable add to cart button?
Please use this filter: https://www.welaunch.io/en/knowledge-base/faq/modify-variations-table-data-fields/
I was after a solution to hide price and add to cart button when product price is 0. Pasted solution below for future searches.
/* remove add to cart and price from variation table if price is 0 */
function modify_variations_table_data($data) {
global $product;
$product->get_id();
if( $product->get_price() == 0 ) {
unset($data[‘enabled’][‘ca’]);
unset($data[‘enabled’][‘pr’]);
}
return $data;
}
add_filter( ‘woocommerce_variations_table_data’, ‘modify_variations_table_data’, 10, 1 );