1

We have a product that is being sold with Drupal Commerce (using Drupal 7). This specific product is going to be advertised in more ways than just the Drupal site (e.g. email, other sites).

These other sites can have a form in which the user enters some basic information (Name, phone, email). This data is sent to Drupal (curl), a cart and session is created (anonymous unless the user is logged in our site) and the session ID is sent back to the calling website.

The user is redirected to our Drupal site, and the session is restored using the id that was passed.

Everything is working fine, but the user has enter the name, phone and email twice because Drupal tries to pre-populate the checkout fields with the user data, and in this case the user is anonymous, even though I have the user data from the first call.

Is it possible to add this information (name, email, phone) after calling commerce_cart_product_add() for anonymous users? The fields in checkout should get pre-populated even if the user is anonymous.

1 Answer 1

-1

You can do one of two things: store the incoming data in the session somehow and alter it into the appropriate fields via hook_form_alter() or immediately create the relevant customer profiles for the session and reference them from the cart order you create. Default rules in Drupal Commerce will handle assigning those customer profiles to any user account that gets created during checkout for your anonymous sessions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.