I would like to add a select list box to a checkout pane in drupal commerce that will allow me to use the selected value as a token to be added to the completed order email?
Typically, you'd alter a form via hook_form_alter() and then sort out through a custom validate / submit handler how to process and save the data so it could be used later. However, I'd recommend something different, because in that approach you'd have to also create a place to store the data and a way to render it in a token, field, Rules data selector etc. yourself.
The easiest way to collect data and use it later in these various scenarios is to use a field. So instead of altering the form directly, I'd figure out how to get a custom field into the checkout form. You have two basic options:
- If the data has something to do with customer profile information, like billing or shipping information, simply add the field to the customer profile type and it will appear on the checkout form. I'm not entirely sure how the token system works with respect to the Rules e-mail action, but the data will be there and field tokens will be there to make it happen somehow. Might require further investigation or a module.
- If this data is stand alone and you just need it to appear on the form in its own checkout pane, I'd add the field to the order in a fieldgroup and use the Commerce Fieldgroup Panes module to make it into a checkout pane. Then you'd have the field data on your order usable from a token as well.