commerce_order_item_checkout_fields
Features
Provides a Drupal Commerce checkout pane that collects additional field data per order item, per unit of quantity — for example, attendee name and email for each ticket in the cart — the information gets stored on the order item.
Collecting this kind of information on the order entity itself proves to be not useful as there could be multiple different event dates/tickets in the cart, that need their specific information on the ticket itself to be clearly identifiable.
Post-Installation
- Add custom fields to an order item type at `/admin/commerce/config/order-item-types/{type}/edit/fields`.
- A checkout pane derivative is generated automatically for every order item type that has at least one qualifying field.
- Enable the pane ("... fields") on the desired step of your checkout flow at `/admin/commerce/config/checkout-flows`.
- During checkout the pane renders one set of widgets per unit and stores the submitted values back on the order items. This is useful to pull information with Views for admins, for example, etc.
Additional Requirements
Here're a few things to consider.
- The module should only activate for order item types where quantity is always integer-valued (e.g., event tickets)
- A user ordering 50 tickets = 50 sets of form fields. This is potentially catastrophic UX. Haven't gotten to this kind of experience, but might require improvement in the future, if it will be useful. E.g. a configurable max per pane, or a paginated/accordion approach
- Any field type works. You are not limited to a particular field type — add plain text fields, e-mail, number, date, list, link, entity reference, Address, `custom_field`, etc. Only `file`/`image` and `entity_reference_revisions` (Paragraphs) are excluded, because they cannot be handled safely in a stateless checkout pane. The exclusion list is alterable via a hook.
- Pick the fields with a form display mode. The pane renders whatever fields are placed on the order item type's chosen form display mode (see below). Create a dedicated "Checkout" mode to control exactly which fields/widgets appear.
- If products can be *combined* in the cart, set those fields' cardinality to *Unlimited*. A combined order item stores one value per product as a field delta. The module warns you (pane save, status report checkout log) if a collected field has limited cardinality.
- Empty values cannot be stored per product. Drupal drops empty field deltas on save, so a blank product is omitted and can misalign multiple separate fields. Use the "Require every field for every product" pane setting, mark fields required, or use one composite field per product.
Similar projects
There is a somewhat similar module Commerce Checkout Order Fields , which collects additional information right on the commerce order entity itself. This use case wasn't applicable in our scenario as we needed information to be more structured and pertain to specific order item purchased, not the whole order.