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;
}

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée.