Drupal - Anonymous checkout doesn't properly work

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 & 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.

Tags:

Users

Commerce