Product Visibility Compatibility

Below are some PHP snippets + guides to make B2BKing product visibility compatible with 3rd party plugins.

Here is a guide for adding PHP snippets: Add PHP/JS Snippets

Barn2 WooCommerce Product Table #

To make B2BKing visibility work with table:

  • Make sure to disable the Product Table Cache in their plugin's settings:
6531233623.png
This should be DISABLED
  • Add the following PHP snippet
add_filter( 'wc_product_table_query_args', function( $args, $table_query ) {
    // do something with $args
    $currentval = $args['post__in'];
    
    $allTheIDs = get_transient('b2bking_user_'.get_current_user_id().'_ajax_visibility');
    $allTheIDs = apply_filters('b2bking_ids_post_in_visibility', $allTheIDs);
    $args['post__in'] = $allTheIDs;
    
    if (!empty($currentval)){
        $allTheIDs = array_intersect($allTheIDs, $currentval);
    }
    
    return $args;
}, 10, 2 );
  • It is recommended to enable the B2BKing visibility cache in B2BKing -> Settings -> Other -> Product Visibility Cache.

Powered by BetterDocs