Okay
  Public Ticket #3001429
Cart -> get group
Closed

Comments

  •  1
    Prokop Suchanek started the conversation

    Hi there!

    I have some code in a snippet that works on vat:

    add_filter( 'woocommerce_adjust_non_base_location_prices', '__return_false' );

    I would like to exempt b2b users.

    So what I am looking for is wrapping this code in an if statement, that excludes b2b group, such as:

    if ($b2bking_b2buser = false) {

    add_filter( 'woocommerce_adjust_non_base_location_prices', '__return_false' );

    }

    What is the correct syntax for detecting if current user is a member of b2b users?

    Cheers

  •  1
    Prokop Suchanek replied

    I found the answer here:

    https://webwizards.ticksy.com//ticket/2813000/

    $user_id = get_current_user_id();
    $user_is_b2b = get_user_meta($user_id,'b2bking_b2buser', true);
    if ($user_is_b2b === 'yes'){
        $group_id = get_user_meta($user_id, 'b2bking_customergroup', true);
        $group_name = get_the_title($group_id);
    }

    Thanks!


  •  2,218
    WebWizards replied

    Hi there,

    Glad to hear you found that. Yes, you could use the following to exclude B2B users:

    $user_id = get_current_user_id();
    $user_is_b2b = get_user_meta($user_id,'b2bking_b2buser', true);
    if ($user_is_b2b !== 'yes'){
        add_filter( 'woocommerce_adjust_non_base_location_prices', '__return_false' );
    }