You are here

function commerce_registration_create_product_registration in Commerce Registration 7.3

Same name and namespace in other branches
  1. 7.2 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. @TODO: don't create registration objects if the host entity isn't allowing registrations.

File

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

Code

function commerce_registration_create_product_registration($product_id, $bundle, $lineitem_id, $slots = 1) {
  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->lineitem_id = $lineitem_id;
  $entity->count = $slots;
  registration_save($entity);
  return $entity;
}