Okay
  Public Ticket #2973204
Different stock levels for B2B customers
Closed

Comments

  •  1
    Laura started the conversation

    Hi there, is there a way to allow different stock levels or allow backorders for B2B customers only? I have a client with a combined B2C and B2B store and she'd like B2B customers to have the option to order in bulk even if she doesn't have the product in stock at that moment, but wants the B2C customer stock levels to still remain. Or is there a plugin I could combine that would work with B2BKing to allow the inventory to be pulled from a secondary location? Thanks! 

  •  2,218
    WebWizards replied

    Hi there,

    Thank you for purchasing the plugin!

    You can add the following PHP snippet to a site, to enable backorders and allow purchases for B2B users.


    $is_b2b_user = get_user_meta(get_current_user_id(),'b2bking_b2buser', true);
    if ($is_b2b_user === 'yes'){
        // Enable backorders on all products
        add_filter( 'woocommerce_product_get_backorders', 'filter_get_backorders_callback', 10, 2 );
        add_filter( 'woocommerce_product_variation_get_backorders', 'filter_get_backorders_callback', 10, 2 );
        
        // Change all products stock statuses to 'instock'
        add_filter( 'woocommerce_product_get_stock_status', 'filter_get_stock_status_callback', 10, 2 );
        add_filter( 'woocommerce_product_variation_get_stock_status', 'filter_get_stock_status_callback', 10, 2 );
        
    }
    function filter_get_stock_status_callback( $stock_status, $product ){
        return is_admin() ? $stock_status : 'instock';
    }
    function filter_get_backorders_callback( $backorders_status, $product ){
        return 'yes'; // Enable without notifications
    }
    

    A PHP snippet can be added to functions.php, or by following our guide here: https://woocommerce-b2b-plugin.com/docs/how-to-add-a-snippet-php-or-js/


    We are actually looking to add a feature to allow separate inventories for B2C / B2B. Hope you can see this soon.


    Let me know if I can help with anything, or if you have any questions,

    Kind regards,

    Stefan




  •  1
    Laura replied

    Hi Stefan,

    This is fantastic, thanks so much! This seems to work well and we'll look forward to the future update!


  •  2,218
    WebWizards replied

    Glad to hear that worked!

    Let me know if there's anything I can help with,


    Have a nice weekend,