Set download limit and expiry for WooCommerce downloadable products in specific categories
Question
I have the following code that set a global download limit and expiry, for all WooCommerce downloadable products:
//FOR VARIATION DOWNLOADABLE PRODUCTS
// set 3 downloads for all variation downloadable products
add_filter('woocommerce_product_variation_get_download_limit', function ($val, $obj) {
return $val <= 0 ? 3 : $val;
}, 30, 2);
// set 3 days expiration for all variation downloadable products
add_filter('woocommerce_product_variation_get_download_expiry', function ($val, $obj) {
return $val <= 0 ? 3 : $val;
}, 30, 2);
//FOR SIMPLE DOWNLOADABLE PRODUCTS
// set 3 downloads for all simple downloadable products
add_filter('woocommerce_product_get_download_limit', function ($val, $obj) {
return $val <= 0 ? 3 : $val;
}, 30, 2);
// set 3 days expiration for all simple downloadable products
add_filter('woocommerce_product_get_download_expiry', function ($val, $obj) {
return $val <= 0 ? 3 : $val;
}, 30, 2);
MY PROBLEM:
I don’t want to set the download limit and expiry globally (for all downloadable products), but only for specific product categories instead.
Any help is appreciated.
0
4 months
0 Answers
19 views
0
Leave an answer
You must login or register to add a new answer .