• Resolved FrictionNL

    (@frictionnl)


    Hi,

    I have two types of roles, normal customer and wholesale customers. The wholesale customers should be able to place backorders and the normal customers are not allow to place backorders. I am not a php developer and my code is not working yet, please help me out to make it work:

    add_filter( 'woocommerce_product_backorders_allowed', 'woocommerce_product_backorders_allowed', 10, 3 );
    function woocommerce_product_backorders_allowed( $backorder_allowed, $product_id, $product ){
        $targeted_user_role = 'zakelijke_klant'; // The slug in "lowercase"
        $user_data = get_userdata(get_current_user_id());
        if ( in_array( $targeted_user_role, $user_data->roles ) ) {
             $backorder_allowed = true;
        }
        return $backorder_allowed;
    }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Backorders only allowed for specific user role’ is closed to new replies.