Skip navigation
Help

uc_order_pane_callback

7 uc_order.api.php uc_order_pane_callback($op, $order, &$form = NULL, &$form_state = NULL)

Builds and processes an order pane defined by hook_uc_order_pane().

Parameters

$op: The operation the pane is performing. Possible values are "view", "customer", "edit-form", "edit-theme" or "edit-process".

$order: The order being viewed or edited.

$form: The order's edit form. NULL for non-edit ops.

&$form_state: The form state array of the edit form. NULL for non-edit ops.

Return value

Varies according to the value of $op:

  • view: A render array showing admin-visible order data.
  • customer: A render array showing customer-visible order data.
  • edit-form: $form with the pane grafted in.
  • edit-theme: The rendered portion of the $form that the pane added.
  • edit-process: An array of values to be modified on the order object, keyed by the object's property, or NULL to signify no change on the order object.

Related topics

File

ubercart/uc_order/uc_order.api.php, line 349
Hooks provided by the Order module.

Code

function uc_order_pane_callback($op, $order, &$form = NULL, &$form_state = NULL) {
  global $user;

  switch ($op) {
    case 'view':
      $comments = uc_order_comments_load($order->order_id, TRUE);
      return tapir_get_table('uc_op_admin_comments_view_table', $comments);

    case 'edit-form':
      $form['admin_comment_field'] = array(
        '#type' => 'fieldset', 
        '#title' => t('Add an admin comment'), 
        '#collapsible' => TRUE, 
        '#collapsed' => TRUE,
      );
      $form['admin_comment_field']['admin_comment'] = array(
        '#type' => 'textarea', 
        '#description' => t('Admin comments are only seen by store administrators.'),
      );
      return $form;

    case 'edit-theme':
      $comments = uc_order_comments_load($form['order_id']['#value'], TRUE);
      if (is_array($comments) && count($comments) > 0) {
        foreach ($comments as $comment) {
          $items[] = '[' . theme('uc_uid', array('uid' => $comment->uid)) . '] ' . filter_xss_admin($comment->message);
        }
      }
      else {
        $items = array(t('No admin comments have been entered for this order.'));
      }
      $output = theme('item_list', array('items' => $items)) . drupal_render($form['admin_comment_field']);
      return $output;

    case 'edit-process':
      if (!empty($order['admin_comment'])) {
        uc_order_comment_save($order['order_id'], $user->uid, $order['admin_comment']);
      }
      return;
  }
}