Anonymous checkout doesn't properly work Anonymous users are supposed to have access to Commerce cart/checkout by default. In my current project cart remains empty for anonymous users, even if an order is created. When an anonymous user clicks on Add to cart, a new order is correctly created, with the Owned by anonymous status. This is fine, but:

While the current product page is reloaded as expected, the rule displaying the default message (Foo was added to your cart) is not fired

If I manually go to /cart, I get the Cart is empty message. /checkout returns a 404 error.

$_SESSION remains empty (I precise this because of commerce_checkout_access()).
if (empty($_SESSION['commerce_cart_orders']) || !in_array($order-&gt;order_id, $_SESSION['commerce_cart_orders'])) {
  return FALSE;
}



In fact, it seems that in anonymous context, the order cannot be seen.
How do I debug why the cart remains empty, and the order isn't visible  to anonymous users?
My config: clean step by step Commerce install, not Kickstart; some custom line items ;  Access checkout / View own orders of any type / View any product of any type permissions granted for anonymous.
Happy end, and stupid lost time : the lone problem was the Anonymous user was accidentally deleted (don't know how) ! I thank all the gentlemen who tried to help me to debug.

The uid 0 must absolutely be there. If you encounter such case, simply insert an empty row in users table via phpmyadmin or run these 2 queries (for D7) : 

insert into users (name, pass, mail, theme, signature, language, init, timezone) values ('', '', '', '', '', '', '', '');
update users set uid = 0 where name = '';


Meanwhile, I've read many things about Commerce checkout to make sure I was doing right. I share some clues below in case it could help somebody else.

A common issue for empty cart page (and other Commerce Views issues where user can't see products) is due to Referenced Product Relationship: 2 solutions may work depending on your config :


In the View's advanced settings fieldset, disable SQL rewriting.
Enable the not-totally-secure View any product of any type permission. This is discussed &amp; patched here. If you have Commons distribution, you’ll have to disable paranoia (disable with Drush only, it's not visible in the module list).  


Important permissions to grant (admin/people/permissions) : 


Anonymous :


Checkout => Access checkout
Order => Create orders of any type  / Create orders

Authenticated : same ones, plus


Order => View own orders of any type / View own orders



Default behavior in Drupal Commerce :

Anonymous users can add a product to cart, checkout (filling email, name and address), review and complete order. Some documentation to read : Checkout: Anonymous vs. Authenticated  and Anonymous Carts and Logged In Users



An a few useful tips and links to enhance default checkout


How to auto login anonymous user that has completed checkout ? As per duckx answer, you can get this in 3 short steps : checking above rules, enabling Commerce Checkout Complete Registration or Commerce Immediate Login, adding the Login action to the default Commerce "Create new account for anonymous order" Rule.
Use Commerce Checkout Login to provide e-mail validation and an inline login form via AJAX. 


  If the e-mail address an anonymous user enters is already associated
  with a user account, the checkout form will expand with an optional
  password textfield and login button for immediate login.

Use the popular Commerce Checkout Redirect  to redirect anonymous users to a page where they can login or create a new account when they try to checkout. Many settings available…
Use Commerce Address book to allow authenticated customers to reuse
previously entered addresses during checkout. 
How to set up an Express checkout  (a single page checkout process that any user - including an anonymous user - can complete in a snap)
How to set Different payment methods for different product types  adding a condition to the payment method rule.
How to create an order through Drupal Commerce API 
Use Commerce add to cart confirmation to provide an "add to cart" confirmation dialog, shown after the customer has added a product to his cart.
Last, Commerce Extra offers a bundle of features, from which cloning Address information from user's account (instead from previously made orders as Commerce Address book does), and adding an extra step to checkout so that users may log in optionally.