I'm interested in the possibility of a multi-tiered approval store. The idea is that any tier can place orders but any tier below the first needs to receive approval from the preceding first before it reaches Tier 1.
Example tiers:
Tier 1: Regional Approver
Tier 2: Venue Approver
Tier 3: Employee
I noticed that there is an option to create more than 2 tier users (https://woocommerce-b2b-plugin.com/docs/multiple-buyers-per-account-subaccounts/#10-toc-title) but it appears that this also allows the last tier to continue creating subaccounts and so on. I only need 3 tiers and the employees cannot set up their own subaccounts. When this is activated, all the orders are sent directly to main (non-sub) account, bypassing the point of the tiers I want set up.
Also, is there a way for the orders to skip the payment screen once approved? Once approved, payment is not required and can go straight to processing however prices need to exist.
I understand you're looking to implement a multi-tiered approval system. Let me address those questions
1. I can provide you with a code snippet that will restrict subaccount creation to exactly 3 tiers and prevent employees (Tier 3) from creating additional subaccounts.
2. For the payment screen, this is a bit more difficult but I believe I can also write code snippet that would allow approved orders to bypass payment and go directly to processing while maintaining price display.
3. However, I need to point out an important limitation: B2BKing's approval system (https://woocommerce-b2b-plugin.com/docs/company-order-approval/) currently only supports a simple subaccount/parent account approval relationship. The system isn't built to handle sequential multi-tier approvals where orders need to pass through each tier level. This is quite difficult to change unfortunately, because it's based on custom order statuses (e.g. pending approval, approved, we do not have an "intermediary" status).
Would you still like me to provide the code snippets for points 1 and 2?
An a slightly related note, how does the company order approval manage inventory?
I find that you are able to place as any orders as you want irrespective of actual stock level assuming it does not exceed the amount "in stock" before pending orders are approved.
E.g. 5 stock left for a product. Someone can place an order for 5, order pending approval. Another person could place another order for 5. Both of these orders can then be approved and stock would go into the negatives.
Is there any way to prevent this behaviour? Ideally the stock would be removed when an order is pending approval, and returned to stock if the order is rejected.
Let me clarify how the system currently handles this situation:
The way B2BKing's order approval system works is that stock checks are performed at the payment stage, rather than when the order is placed for approval. This means when an approved order proceeds to payment, the system will show a message saying "Sorry, there is not enough stock for this order, therefore it cannot be paid for" if there isn't sufficient inventory available. And only after payment the stock would be reduced.
Reducing stock for pending approval orders that may or may not be approved creates additional complexity - for example, how long should we reserve that stock if orders remain in limbo without being approved or rejected? Or maybe the order itself should expire but then you get into more complexity, order expiration reminders etc.
These orders (since they're not actual final orders yet) are also not shown in the backend admin area, so we don't want to get into a situation where the admin does not see the order, but stock has been reduced.
So I guess it is difficult to find an ideal solution here, which is why we went with the above.
Ah, that actually makes sense. Yes, since we're skipping that stage with the snippet, there's practically no check for stock anymore.
We could adjust the approval snippet as follows, so that it only sets the order to Processing if there's enough stock.
add_action('b2bking_after_approve_order', function($order){
$order_id = $order->get_id();
// First check if there's enough stock
if (!b2bking()->order_has_enough_stock($order_id)){
wc_print_notice( __( 'Sorry, there is not enough stock for this order, therefore it cannot be approved.', 'b2bking' ), 'error' );
return;
}
// If we have enough stock, proceed with approval
$order->update_status( 'processing', esc_html__( 'Order approved.', 'b2bking' ) );
$order->save();
}, 10, 1);
I'm interested in the possibility of a multi-tiered approval store. The idea is that any tier can place orders but any tier below the first needs to receive approval from the preceding first before it reaches Tier 1.
Example tiers:
Tier 1: Regional Approver
Tier 2: Venue Approver
Tier 3: Employee
I noticed that there is an option to create more than 2 tier users (https://woocommerce-b2b-plugin.com/docs/multiple-buyers-per-account-subaccounts/#10-toc-title) but it appears that this also allows the last tier to continue creating subaccounts and so on. I only need 3 tiers and the employees cannot set up their own subaccounts. When this is activated, all the orders are sent directly to main (non-sub) account, bypassing the point of the tiers I want set up.
Also, is there a way for the orders to skip the payment screen once approved? Once approved, payment is not required and can go straight to processing however prices need to exist.
Hi John,
I understand you're looking to implement a multi-tiered approval system. Let me address those questions
1. I can provide you with a code snippet that will restrict subaccount creation to exactly 3 tiers and prevent employees (Tier 3) from creating additional subaccounts.
2. For the payment screen, this is a bit more difficult but I believe I can also write code snippet that would allow approved orders to bypass payment and go directly to processing while maintaining price display.
3. However, I need to point out an important limitation: B2BKing's approval system (https://woocommerce-b2b-plugin.com/docs/company-order-approval/) currently only supports a simple subaccount/parent account approval relationship. The system isn't built to handle sequential multi-tier approvals where orders need to pass through each tier level. This is quite difficult to change unfortunately, because it's based on custom order statuses (e.g. pending approval, approved, we do not have an "intermediary" status).
Would you still like me to provide the code snippets for points 1 and 2?
Kind regards,
Stefan
Hi Stefan,
Thanks for getting back to me. Please provide the snippets for 1 & 2.
Appreciate the information on three. Unfortunate but I haven't been able to find another plugin that provides that functionality either.
Hi again,
For (1) please use this code snippet:
It should no longer allow level 3 subaccounts from creating further subaccounts.
For (2), I believe you can use this snippet:
Let me know if these work for you,
Kind regards,
Stefan
Hi Stefan,
Thanks, those two snippets appear to work.
An a slightly related note, how does the company order approval manage inventory?
I find that you are able to place as any orders as you want irrespective of actual stock level assuming it does not exceed the amount "in stock" before pending orders are approved.
E.g. 5 stock left for a product. Someone can place an order for 5, order pending approval. Another person could place another order for 5. Both of these orders can then be approved and stock would go into the negatives.
Is there any way to prevent this behaviour? Ideally the stock would be removed when an order is pending approval, and returned to stock if the order is rejected.
Hi John,
Thanks for your thoughts on this and feedback.
Let me clarify how the system currently handles this situation:
The way B2BKing's order approval system works is that stock checks are performed at the payment stage, rather than when the order is placed for approval. This means when an approved order proceeds to payment, the system will show a message saying "Sorry, there is not enough stock for this order, therefore it cannot be paid for" if there isn't sufficient inventory available. And only after payment the stock would be reduced.
Reducing stock for pending approval orders that may or may not be approved creates additional complexity - for example, how long should we reserve that stock if orders remain in limbo without being approved or rejected? Or maybe the order itself should expire but then you get into more complexity, order expiration reminders etc.
These orders (since they're not actual final orders yet) are also not shown in the backend admin area, so we don't want to get into a situation where the admin does not see the order, but stock has been reduced.
So I guess it is difficult to find an ideal solution here, which is why we went with the above.
Kind regards,
Stefan
Hi Stefan,
Thank you for the information.
Based on the code spinnet skipping payment, is it possible that this check for stock no longer works?
Ah, that actually makes sense. Yes, since we're skipping that stage with the snippet, there's practically no check for stock anymore.
We could adjust the approval snippet as follows, so that it only sets the order to Processing if there's enough stock.