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.