Here’s how to set you minimum purchase by category in woocommerce .

[membership level=”1″]


add_action( 'woocommerce_check_cart_items', 'wc_minimum_order_amount' );

function wc_minimum_order_amount() {
	global $woocommerce;
	$minimum = 35;
	$esdtotal=0;
	$esd =0;
if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) {

	 foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
	 $_product = $values['data'];
	 $quantity= $values['quantity'];

          /* Get category ID */
	 $term_list = wp_get_post_terms($_product->id,'product_cat',array('fields'=>'ids'));
	 $cat_id = (int)$term_list[0];

	 //echo $cat_id;
	 global $wpdb;

	 $parent = $wpdb->get_var("SELECT parent FROM ".$wpdb->prefix."term_taxonomy WHERE term_id = ". $cat_id );
	 $parent2 = $wpdb->get_var("SELECT parent FROM ".$wpdb->prefix."term_taxonomy WHERE term_id = ". $parent );

	 /* 2720 is the $parent2 category
         /* add all the prices of all product under that category

		 if($parent==2720 || $parent2==2720){

			 $price= get_post_meta( $_product->id, '_regular_price', true);
			 //echo $price;
			 $esdtotal+= (float)$price * $quantity;
			 $esd=1;
		 }

	 }
 }

	if ( $esdtotal < $minimum && sizeof( $woocommerce->cart->get_cart() ) > 0 && $esd==1 ) {

		$woocommerce->add_error( sprintf( 'You must have an order with a minimum of %s to place your order for all ESD products.' , $minimum ) );
	}
}

[/membership]