Hello Stephen,
Yes, it is possible to set multiple date ranges. You can achieve that with a small PHP snippet though.
For example, you may set different date ranges per product, considering the products A, B?and C with ids 1, 2 and 3.?Then you’d need to add this to your (child) theme’s functions.php
file.
add_filter( 'alg_wc_mppu_date_to_check', function ( $date_to_check, $date_range, $current_time, $product_or_term_id, $current_user_id, $is_product ) {
if ( ! $is_product ) {
return $date_to_check;
}
switch ( (int) $product_or_term_id ) {
case 1: // Product A - Lifetime.
$date_to_check = 0;
break;
case 2: // Product B - Last 7 days.
$date_to_check = ( $current_time - WEEK_IN_SECONDS );
break;
case 3: // Product C - Last 24 hours.
$date_to_check = ( $current_time - DAY_IN_SECONDS );
break;
}
return $date_to_check;
}, 10, 6 );
Also, you can have a formula that allows?different Date Ranges per Product Tag. For example,?
a) Customers need to be able to purchase only 5 items per month (this month, not last 30 days) from Product Tag A with an ID of 574.
b) Customers need be able to purchase only 1 item per lifetime from Product Tag B with an id of 600
To achieve this first enable?Limits > Per product tag then? enable Formula > Limits by formula.?Now, add this to formula:
[alg_wc_mppu term_id="574" limit="5"]
[alg_wc_mppu term_id="600" limit="1"]
– Add this to your functions.php
add_filter( 'alg_wc_mppu_date_to_check', function ( $date_to_check, $date_range, $current_time, $product_or_term_id, $current_user_id, $is_product ) {
if ( $is_product ) {
return $date_to_check;
}
if ( in_array( $product_or_term_id, array( 574 ) ) ) {
$date_to_check = strtotime( date( 'Y-m-01' ), $current_time );
} elseif ( in_array( $product_or_term_id, array( 600 ) ) ) {
$date_to_check = 0;
}
return $date_to_check;
}, 10, 6 );
Please give these a try. Let me know if it doesn’t help.