This can be done by WordPress conditional function has_term()
for targeting a specific product category (code will go in function.php)
// Set a different Download limit for specific downloadable products
add_filter('woocommerce_product_get_download_limit', 'product_get_download_limit_filter_callback', 30, 2 ); // Simple
add_filter('woocommerce_product_variation_get_download_limit', 'product_get_download_limit_filter_callback', 30, 2 ); // Variation
function product_get_download_limit_filter_callback( $value, $product ) {
$categories = array( 'action', 'adventure' ); // <== HERE define your product categories (terms ids, slugs or names)
if( has_term( $categories, 'product_cat', $product->get_id() ) && $value <= 0 ) {
$value = 3;
}
return $value;
}
// Set a different Download expiration for specific downloadable products
add_filter('woocommerce_product_get_download_expiry', 'product_get_download_expiry_filter_callback', 30, 2 ); // Simple
add_filter('woocommerce_product_variation_get_download_expiry', 'product_get_download_expiry_filter_callback', 30, 2 ); // Variation
function product_get_download_expiry_filter_callback( $value, $product ) {
$categories = array( 'action', 'adventure' ); // <== HERE define your product categories (terms ids, slugs or names)
if( has_term( $categories, 'product_cat', $product->get_id() ) && $value <= 0 ) {
$value = 3;
}
return $value;
}