1

I'm trying to figure out how exactly does Drupal Commerce store Addresses for anonymous users?

Let's say an anonymous user creates a shopping cart and fills in the shipping information, but has not yet completed the checkout (payment for example, so shipping information is already stored with the order). At this point, has the system already created a shipping entity, if so, then to whom, as the anonymous user ID is 0.

Else if the Shipping information gets stored only upon checkout completion, still, to whom is it assigned? Who is the owner of the address.

Commerce also allows for an anonymous user to later create an account that has all their order history and shipping addresses, has there been assigned a new unused user ID for the user, just in case they decide to register, to associate all this information, or is the address originally only tied to the order it self, with owner ID 0, and the user profile is created upon registration based on the order details?

Why I'm asking for all this, is that I'm creating an order process where the address is assigned for each product separately, and on checkout each product with different shipping address is moved to a new order with the specific shipping address. And with this in mind I still wish to keep the possibility for making anonymous purchases, and am trying to figure out the dynamics of the shipping addresses :)

Best regards,

Alari

1

As billing or shipping data gets entered during checkout, it gets created as a customer profile. Each order has a commerce_customer_billing address field and maybe even a commerce_customer_shipping field (if shipping is enabled). It holds a reference to the billing profile that got entered during checkout (even for anonymous users).

This is the same for logged in users as well, the only difference is that they are associated with the user.

If you've enabled the rule Create a new account for an anonymous order, it will also set the UID of the billing and shipping profiles to the new user as well.

  • Hey, thanks for the answer. So until a user is created, the profile is owned by anonymous (uid=0) and referenced to by the order, and upon user creation this owner is changed to the actual new user? – Alari Truuts Mar 6 '16 at 18:43
  • Yes. (Now filling space to be able to submit...) – Ryan Szrama Mar 6 '16 at 20:17
1

Commerce will always create a new user upon completion of the checkout process of anonymous orders. This happens in a rule named "Create a new account for an anonymous order":

admin/config/workflow/rules/reaction/manage/commerce_checkout_new_account

If you want to clone the order, then, just act after the aforementioned rule has executed by creating a rule with a higher weight.

  • Hey, thanks for the answer. But in the meanwhile, if the checkout hasn't completed yet but the address fields data has already been filled, how is the data stored? Owner uid=0? and the profile owner is changed to the newly created user upon checkout completion? – Alari Truuts Mar 6 '16 at 18:42
  • nvahalik answered to your questions. Note that you can't checkout multiple orders at the same time. If you want to have multiple addresses on the same order, you will have to add multiple address fields to the customer profile entity. – peterpoe Mar 7 '16 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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