function commerce_registration_information_checkout_form_submit in Commerce Registration 7
Same name and namespace in other branches
- 7.3 includes/commerce_registration.checkout_pane.inc \commerce_registration_information_checkout_form_submit()
- 7.2 includes/commerce_registration.checkout_pane.inc \commerce_registration_information_checkout_form_submit()
Commerce checkout pane form submit callback.
File
- includes/
commerce_registration.checkout_pane.inc, line 158 - Checkout pane callback functions.
Code
function commerce_registration_information_checkout_form_submit($form, &$form_state, $checkout_pane, $order) {
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
foreach ($order_wrapper->commerce_line_items as $delta => $line_item_wrapper) {
$type = $line_item_wrapper->commerce_product->type
->value();
$can_register = registration_entity_registration_status(array(
'id' => $line_item_wrapper->commerce_product->product_id
->value(),
'type' => 'commerce_product',
'bundle' => $type,
));
if ($can_register == 1) {
$product = $line_item_wrapper->commerce_product;
$quantity = (int) $line_item_wrapper->quantity
->value();
for ($i = 0; $i < $quantity; $i++) {
$entity = $order->data['register_entities']['prod-' . $product->sku
->value()][$i];
field_attach_submit('registration', $entity, $form['registration_information']['prod-' . $product->sku
->value()]['prod-' . $product->sku
->value() . '-reg-' . $i], $form_state);
commerce_registration_entity_update_fields($entity, $form_state['values']['registration_information']['prod-' . $product->sku
->value()]['prod-' . $product->sku
->value() . '-reg-' . $i]);
entity_save('registration', $entity);
}
}
}
}