You are here

commerce_registration.api.php in Commerce Registration 7.2

API documentation for Commerce Registration module.

File

commerce_registration.api.php
View source
<?php

/**
 * @file
 * API documentation for Commerce Registration module.
 */

/**
 * Allow modules to alter the operation links on the order registration tables.
 *
 * This is used, for example, in commerce_registration_defer to add a defer
 * link for each registration on the order edit page.
 *
 * @param array $actions
 *   An array of links to perform actions on the registration. By default there
 *   is the view and edit links if the current user has permission to use them.
 *
 * @param array $context
 *   array(
 *     'registration' => The registration to provide action links for,
 *     'order' => The order that is being edited,
 *     'prodkey' => The line item product key combo, within
 *                  $order->data['register_entities'] for this registration,
 *    );
 */
function hook_commerce_registration_order_ops(&$actions, $context) {

  // Don't provide a deferral link if the registration is already deferred.
  if ($context['registration']->state === 'deferred') {
    return;
  }

  // Check that the user has access to defer a registration.
  if (entity_access('defer', 'registration', $context['registration'])) {
    $actions['defer'] = l(t('Defer'), 'admin/commerce/orders/' . $context['order']->order_id . '/defer/' . $context['registration']->registration_id, array(
      'query' => drupal_get_destination(),
    ));
  }
}

/**
 * Allow other modules to alter the commerce registration pane form.
 *
 * @param array $pane_form
 *   The commerce registration pane form that contains the registration info
 *   for the order.
 *
 * @param array $form_state
 *   The form's state array.
 */
function hook_commerce_registration_information_checkout_form_alter(&$pane_form, $form_state) {

  // Lets add some custom instructions to the top of the form.
  $pane_form['custom_instructions'] = array(
    '#markup' => '<h2>' . t('Please fill out all fields for each registration.') . '</h2>',
    '#weight' => -100,
  );
}

Functions

Namesort descending Description
hook_commerce_registration_information_checkout_form_alter Allow other modules to alter the commerce registration pane form.
hook_commerce_registration_order_ops Allow modules to alter the operation links on the order registration tables.