title: Make WC_Cart add_to_cart method working for guests in Woocommerce
body: <p>Im trying to get my code to work. Searching for hours now.
  I found similar questions like <a href="https://stackoverflow.com/questions/52871936/woocommerce-wc-cart-add-to-cart-is-not-working-for-visitors-but-works-for">this one</a>. But unfortunately noone seems to find a solution. </p>
  
  <p>In my custom plugin I want to add a specific item to the WC cart and redirect the user directly to the checkout. As a logged in user it works like a charm but for guests it shows a blank page on checkout (woocommerce_checkout shortcode seems to return nothing in this case). 
  So I came up with a check if the cart iss till empty. Apparently it is because the "cart-page" shows "There are no items in the cart yet".</p>
  
  <p>In code i check if the cart is still empty but it tells me its not!</p>
  
  <p>Here is my code:</p>
  
  <pre><code>if(!$wooID = $wpdb-&gt;get_var("SELECT wooID FROM ".$wpdb-&gt;prefix."ceb_events WHERE id = $event")) die("ERROR GETTING WOOID");
  
  WC()-&gt;cart-&gt;empty_cart();
  
  if(!WC()-&gt;cart-&gt;add_to_cart( $wooID, 1 )) die("CART GOT NOT UPDATED. THERE IS AN ERROR 1.");
  
  if(WC()-&gt;cart-&gt;get_cart_contents_count() == 0) die("CART GOT NOT UPDATED. THERE IS AN ERROR 2."); 
  
  //Here follows the redirect to checkout page
  </code></pre>
  
  <p>The code runs without errors. And it works 100% as a logged in user / admin. Just not as guest, even tho I allowed the guest checkout in the woocommerce settings.</p>