Top WooCommerce & WordPress Plugins › Forums › Maximum Products per User for WooCommerce › How can I set different date ranges for per product tag?
- Support forum for the Maximum Products per User for WooCommerce.
- This topic has 4 replies, 3 voices, and was last updated 1 year, 7 months ago by
Panos.
- AuthorPosts
-
January 27, 2022 at 3:46 pm #100844
Panos
GuestHi! I have purchased the premium version of your plugin. So far it has been working great!
However I need to “complicate” things a bit more and I would like to ask you if and how is it possible to have a formula which allows for different Date Ranges per Product Tag.
Specifically:a) I would like customers to be able to purchase only 5 items per month from Product Tag A
b) I would like customers to be able to purchase only 1 item per lifetime from Product Tab B
Thank you
January 29, 2022 at 12:22 am #100845Panos
GuestClarification:
- By customers I mean only registered users (customer role)
- For point a, I mean per calendar month (not last 30 days).
- Tag A has Tag_ID 574
- Tag B has Tag_ID 600
February 1, 2022 at 11:28 am #100846Zohaib
ParticipantHi,
Unfortunately, it is not possible to have 2 different time ranges for the maximum limits. Only one time range is possible.
February 7, 2022 at 2:00 pm #100847Hi Panos,
I’m sorry. What is not possible is to use multiple different modes. Two different date ranges are actually possible. Please try this:
– Enable “Limits > Per product tag”
– Enable “Formula > Limits by formula”
– 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 );
Let me know if it helps 😉
February 7, 2022 at 6:58 pm #100848Panos
GuestI had to change
'Y-m-01'
to'm-01-Y'
and it worked.Thanks a lot !
- AuthorPosts
- You must be logged in to reply to this topic.