How can I set different date ranges for per product tag?

Top WooCommerce & WordPress Plugins Forums Maximum Products per User for WooCommerce How can I set different date ranges for per product tag?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #100844
    Panos
    Guest

    Hi! 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

    #100845
    Panos
    Guest

    Clarification:

    • 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
    #100846
    Zohaib
    Participant

    Hi,

    Unfortunately, it is not possible to have 2 different time ranges for the maximum limits. Only one time range is possible.

    #100847
    Pablo
    Moderator
    Plugin Support

    Hi 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 😉

    #100848
    Panos
    Guest

    I had to change 'Y-m-01' to 'm-01-Y' and it worked.

    Thanks a lot !

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.