title: Disable create account during WooCommerce checkout when guest checkout is enabled for specified products
body: <p>I have a WooCommerce store on my wordpress website, and I am trying to enable guest checkout for specific products in my store, and require account creation for other products.</p>
  <p>I have the following code in my <code>functions.php</code> file to enable guest checkout on products I specify, but when I navigate to checkout with the product that has guest checkout enabled, the WooCommerce checkout page still is requiring one to create an account.</p>
  <pre class="lang-php prettyprint-override"><code>// Display Guest Checkout Field
      
      add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
          function woo_add_custom_general_fields() {
              global $woocommerce, $post;
            
              echo '&lt;div class=&quot;options_group&quot;&gt;';
            
              // Checkbox
              woocommerce_wp_checkbox( array( 
                  'id'            =&gt; '_allow_guest_checkout', 
                  'wrapper_class' =&gt; 'show_if_simple', 
                  'label'         =&gt; __('Checkout', 'woocommerce' ), 
                  'description'   =&gt; __('Allow Guest Checkout', 'woocommerce' ) 
              ) );
          
            
              echo '&lt;/div&gt;';
          }
      
      // Save Guest Checkout Field
      add_action( 'woocommerce_process_product_meta', 'woo_add_custom_general_fields_save' );
      function woo_add_custom_general_fields_save( $post_id ){
          $woocommerce_checkbox = isset( $_POST['_allow_guest_checkout'] ) ? 'yes' : 'no';
          update_post_meta( $post_id, '_allow_guest_checkout', $woocommerce_checkbox );
      }
  
      
      
      // Custom conditional function that checks if checkout registration is required
      function is_checkout_registration_required() {
          if ( ! WC()-&gt;cart-&gt;is_empty() ) {
              // Loop through cart items
              foreach ( WC()-&gt;cart-&gt;get_cart() as $item ) {
                  // Check if there is any item in cart that has not the option &quot;Guest checkout allowed&quot;
                  if ( get_post_meta( $item['product_id'], '_allow_guest_checkout', true ) !== 'yes' ) {
                      return true; // Found: Force checkout user registration and exit
                  }
              }
          }
          return false;
      }
      
      add_filter( 'woocommerce_checkout_registration_required', 'change_tax_class_user_role', 900 );
      function change_tax_class_user_role( $registration_required ) {
          return is_checkout_registration_required();
      }
          add_action( 'template_redirect', 'checkout_redirect_non_logged_to_login_access');
          function checkout_redirect_non_logged_to_login_access() {
              if( is_checkout() &amp;&amp; !is_user_logged_in() &amp;&amp; is_checkout_registration_required() ){
                  wp_redirect( get_permalink( get_option('woocommerce_myaccount_page_id') ) );
                  exit;
              }
          }
  </code></pre>
  <hr />
  <p>I believe the reason why the account creation fields are still listed on the checkout page is because I have enabled <code>Allow customers to create an account during checkout</code> under WooCommerce &gt; Settings &gt; Accounts &amp; Privacy page.</p>
  <p><strong>So my question is:</strong> how can I disable this setting when I enabled the guest checkout by marking the guest checkout box upon product creation (See my code for the guest checkout checkbox).</p>