• Resolved aleksdab

    (@aleksdab)


    Hi,

    1. Is it possible to make only B2B customers able to place an order with a negative stock (-)?
    2. Can B2B orders have a different status (of placing an order) from B2C?

    I would be grateful for your support.

    Best regards,

    Alex

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author WebWizards

    (@webwizardsdev)

    Hi Alex,

    Thank you for getting in touch with us,

    (1) There is a setting in B2BKing for “always in stock for b2b”: https://woocommerce-b2b-plugin.com/docs/separate-stock-b2b-b2c-users-wholesale-woocommerce/ . When this is enabled, all B2B users (only b2b) are able to order any product regardless of stock status (including out of stock products).

    I have to mention that this feature is currently available only in the paid version of B2BKing,

    (2) There is no specific feature for this by default. I believe we may be able to help with a custom code snippet to assign B2B orders a different status. Which status would you like to assign?

    Kind regards,

    Stefan

    Hi,

    thank you very much for your support.

    1. We will buy the Premium version.
    2. We have created the custom status by code, the status is called “Zamówienie B2B” ($order_statuses[‘wc-custom-status’] = ‘Zamówienie B2B’;).

    We have created the custom role (group of users) as well, following your instruction published online, the ID is: “b2bking_role_47”.

    We would like to assign the Woocommerce status “Zamówienie B2B” to B2B customers with the role “B2B users” directly after placing orders, it should be their first WooCommerce status.

    Best regards,

    Alex

    Plugin Author WebWizards

    (@webwizardsdev)

    Thank you for the details,

    For (2), please try adding / testing the following PHP code snippet:

    function set_custom_order_status_based_on_user_role($order_id) {
    if (!$order_id) {
    return;
    }

    $order = wc_get_order($order_id);
    if (!$order) {
    return;
    }

    $customer_id = $order->get_customer_id();
    if (!$customer_id) {
    return;
    }

    $user = get_userdata($customer_id);
    if (!$user) {
    return;
    }

    // Check if the user has the role 'b2bking_role_47'
    if (in_array('b2bking_role_47', $user->roles)) {
    $order->update_status('wc-custom-status');
    }
    }
    add_action('woocommerce_thankyou', 'set_custom_order_status_based_on_user_role');

    This code runs on the “thank you” (order confirmation) page, so it’s important that page is reached. Let me know if that can solve it for you.

    (For clarity, this code can be added to functions.php of the child theme, or to any code snippets plugin).

    • This reply was modified 7 months, 3 weeks ago by WebWizards.

    Hi,

    it works, thank you very much!!!! <3

    Best regards,

    Aleksandra

    Plugin Author WebWizards

    (@webwizardsdev)

    Glad to hear it : )?If there’s anything else I can help with, please let me know.

    Also, if you feel it deserves it, I would really appreciate it if you considered?leaving a quick?rating for the plugin?– it’s a big help to us.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Negative stock for B2B’ is closed to new replies.