title: Redirect to register page if not logged in and try to access restricted page
body: <p>I would like to restrict the access to a product on my woocommerce website.
  If user are not login, I want to redirect them to register page.
  I'm using this code but all my products redirect to register page :</p>
  
  <pre><code>function wpse_131562_redirect() {
      if (! is_user_logged_in()
  
  &amp;&amp; (is_woocommerce() || is_cart() || is_single(1735) || is_checkout())
  ) {
  
     // feel free to customize the following line to suit your needs
  
     wp_redirect( 'https://www.la-chaine-maconnique.fr/my-account/' );
  
     exit;
     }
  }
   add_action('template_redirect', 'wpse_131562_redirect');
  </code></pre>
  
  <p>To you think of Something  ?</p>