I am running a store, that allows anonymous users to purchase product.

I would like to collect a small amount of "order-level" data from a users before they make a purchase. An example would be whether or not the purchaser is a member of our organization.

The question is where best to do this? I do not want to include a field in each line item, because this is order level and not line item level data.

I could add a field to a checkout pane, but I actually want to use the information I'm gathering to determine what kind of checkout information to collect. People who are already members of our organization, for example, would have to enter much less information because we already have it.

  • Normally you would collect user specific data like this in a commerce customer profile, however I do not know how to use that for choosing the right checkout step. Also how would you validate it when someone claims to be a member? Do your organization members have an account? If they have an address on their user profile, you could also use Commerce Extra Address Populate (From Commerce Extra to autofill the address during checkout). – Neograph734 Apr 3 '17 at 21:27
  • Thanks, Neograph734. To answer your question, we are a small organization, and have not yet felt the need to go to the trouble of creating accounts for our members. What we would like to do is to ask them to check a box indicating that they are members and then fill in their name in a text field. It may be that this is an isolated use case, but I would think that there would be other occasions when stores would like to collect order-level data before transferring the user to checkout. Example: providing discounts to members without requiring them to log in. – Wyckham Seelig Apr 3 '17 at 22:11
  • Please note that just a name cannot identify a person. Multiple people with the same name could live in one City, or even the same street. Maybe combine the name with a membership number? (something unique). But before they found that, they would have filled in their address as well ;) – Neograph734 Apr 3 '17 at 22:23

I think I have figured out how to do this, at least conceptually.

What I need to do is expose the order level data in a form without a Submit button. Then, use javascript to populate hidden fields in the real Add to Cart form with data that the purchaser enters in the exposed order level data fields.

Then use hook_form_alter to redirect the Add to Cart button to my own php routine where I will use the [now filled in] hidden fields in the Add to Cart form to populate order entity properties. [I might also be able to do this in my commerce_mycheckout_submit routine.]

Whether my skills, and the exigencies of project deadlines will let me get this down now remains to be seen, but I think I now have a way forward.

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.