1

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);
commerce_order_save($order);

EDIT:

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

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

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:

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

form_state_values_clean() will remove build IDs and such.

0

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);
$order_wrapper->save();
  • There is already a data field in the order. Am I not able to use that one? – vintorg Jun 22 '15 at 23:22

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.