Hiding the offers tab could be achieved with code snippets, but at least right now it's not something we want to add directly to the plugin as it could make many confused about why the tab doesn't show.
You can do it with this PHP snippet:
add_filter('option_b2bking_enable_offers_setting', function($value){
if (!is_admin()){
// if no offers, set to 0
$user_id = get_current_user_id();
$account_type = get_user_meta($user_id,'b2bking_account_type', true);
if ($account_type === 'subaccount'){
// Check if user has permission to view all account offers
$permission_view_account_offers = filter_var(get_user_meta($user_id, 'b2bking_account_permission_view_offers', true), FILTER_VALIDATE_BOOLEAN);
if ($permission_view_account_offers === true){
// for all intents and purposes set current user as the subaccount parent
$parent_user_id = get_user_meta($user_id, 'b2bking_account_parent', true);
$user_id = $parent_user_id;
}
}
$user = get_user_by('id', $user_id) -> user_login;
$currentusergroupidnr = get_user_meta( $user_id, 'b2bking_customergroup', true );
// Define custom query parameters
$custom_query_args = array( 'post_type' => 'b2bking_offer',
'post_status' => 'publish',
'posts_per_page' => 5,
'meta_query'=> array(
'relation' => 'OR',
array(
'key' => 'b2bking_group_'.$currentusergroupidnr,
'value' => '1',
),
array(
'key' => 'b2bking_user_'.$user,
'value' => '1',
),
));
// Instantiate custom query
$custom_query = new WP_Query( $custom_query_args );
// Output custom query loop
if ( ! $custom_query->have_posts() ) {
$value = 0;
}
}
return $value;
});
I think it's a bit frustrating the customer clicking there and not having an offer.
My suggestion would place a class when it has offer, or Body Class
: D
Hi Orlando,
Hiding the offers tab could be achieved with code snippets, but at least right now it's not something we want to add directly to the plugin as it could make many confused about why the tab doesn't show.
You can do it with this PHP snippet:
To add a PHP snippet: https://woocommerce-b2b-plugin.com/docs/how-to-add-a-snippet-php-or-js/