I have customers filling out an entry form before sending them to checkout. Is it possible to store, or serialize, the $form_state array in the order? There is a 'data' field in the order. Is it simple as me calling:

$order->data = serialize($form_state);


The data field in the order is an array that gets serialized. So, it looks like I can do:

$order->data['myform'] = $form_state;

2 Answers 2


There is the data attribute on entities, which you cannot access through Entity Metadata Wrappers (per previous answer.)

Do you need the full form state or just values? Also, you do not need to serialize the data, as the entity controller will do this for you.

I would do something like:

$order->data['myform_values'] = $form_state['values'];

form_state_values_clean() will remove build IDs and such.


You would need to add a field to commerce_order called field_data and then save it, yes.

The pattern might be more like:

$order_wrapper = entity_metadata_wrapper('commerce_wrapper', $order_id);
$order_wrapper->field_data = serialize($form_state);
  • There is already a data field in the order. Am I not able to use that one?
    – vintorg
    Jun 22, 2015 at 23:22

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.