Redirect customer to login page (with other signup plugin) if user not logged in when proceeding to checkout

I find and use below code for when user in cart page and cart not empty:

add_filter('woocommerce_get_checkout_url', 'dj_redirect_checkout');
function dj_redirect_checkout($url) {
     global $woocommerce;
     if(is_cart() && !is_user_logged_in() ){
          $checkout_url="digits login url";
     }
     else{
         $checkout_url="https://yoursite.com/checkout/";
     }
     return  $checkout_url; 
}