How can I set different date ranges for different customers?

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

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #100464
    Jacob
    Guest

    Is it possible to set date ranges on a customer level? Example customer 1 has a 3 order limit per 30 days, customer 2 has a 3 order limit per 2 weeks.

    Also, for the frontend messages, I would like to use some of the placeholders that are available in the customer message for the single product page, specifically %bought_plus_in_cart%. Can this be done?

    #100465
    Tom Anbinder
    Moderator
    Plugin Support

    Hi Jacob,

    1. Date ranges on a customer level…

    Yes, that’s possible, however, with a small PHP snippet. You need to set your “Date range” to “Last 30 days” in plugin settings, as you would normally do, and add exceptions for some users:

    add_filter( 'alg_wc_mppu_date_to_check', 'my_alg_wc_mppu_date_to_check', 10, 6 );
    if ( ! function_exists( 'my_alg_wc_mppu_date_to_check' ) ) {
        function my_alg_wc_mppu_date_to_check( $date_to_check, $date_range, $current_time, $product_or_term_id, $current_user_id, $is_product ) {
    
            // TODO: You need to add your user exceptions here; in "user ID => days" format.
            $users = array(
                123 => 14,
                124 => 14,
            );
    
            return ( isset( $users[ $current_user_id ] ) ? ( $current_time - $users[ $current_user_id ] * DAY_IN_SECONDS ) : $date_to_check );
        }
    }
    

    You only need to change the code in the snippet where it says “TODO: You need to add your user exceptions here”.

    Please note that for this filter to be applied, the “Date range” option must not be set to “Lifetime”.

    Please give it a try and let me know if something is not working as expected, or if you have any questions.

    2. Placeholders in the “Single product page” message…

    Unfortunately, currently, not all placeholders are available in the “Single product page” option, but let me try to add them there. Will get back to you about this asap.

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