You are here

function commerce_registration_create_product_registration in Commerce Registration 7.2

Same name and namespace in other branches
  1. 7.3 includes/commerce_registration.checkout_pane.inc \commerce_registration_create_product_registration()

Helper function to create a new registration for a product.

Parameters

int $product_id:

string $bundle:

int $order_id:

Return value

RegistrationEntity

1 call to commerce_registration_create_product_registration()
commerce_registration_information_checkout_form in includes/commerce_registration.checkout_pane.inc
Commerce checkout pane form builder callback.

File

includes/commerce_registration.checkout_pane.inc, line 459
Checkout pane callback functions.

Code

function commerce_registration_create_product_registration($product_id, $bundle, $order_id) {
  global $user;
  $entity = entity_get_controller('registration')
    ->create(array(
    'type' => $bundle,
  ));
  $entity->registration_id = NULL;
  $entity->entity_type = 'commerce_product';
  $entity->entity_id = $product_id;
  $entity->created = REQUEST_TIME;
  $entity->updated = REQUEST_TIME;
  $entity->author_uid = $user->uid;
  $entity->order_id = $order_id;
  $entity->count = 1;
  return $entity;
}