You are here

function hook_uc_cart_pane in Ubercart 7.3

Registers callbacks for a cart pane.

The default cart view page displays a table of the cart contents and a few simple form features to manage the cart contents. For a module to add information to this page, it must use hook_uc_cart_pane() to define extra panes that may be ordered to appear above or below the default information.

Parameters

$items: The current contents of the shopping cart.

Return value

The function is expected to return an array of pane arrays, keyed by the internal ID of the pane, each with the following members:

  • "title"

    • type: string
    • value: The name of the cart pane displayed to the user. Use t().
  • "enabled"
    • type: boolean
    • value: Whether the pane is enabled by default or not. (Defaults to TRUE.)
  • "weight"
    • type: integer
    • value: The weight of the pane to determine its display order. (Defaults to 0.)
  • "body"
    • type: array
    • value: The body of the pane to be rendered on the cart view screen.

The body gets printed to the screen if it is on the cart view page. For the settings page, the body field is ignored. You may want your function to check for a NULL argument before processing any queries or foreach() loops.

2 functions implement hook_uc_cart_pane()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

uc_cart_uc_cart_pane in uc_cart/uc_cart.module
Implements hook_uc_cart_pane().
uc_quote_uc_cart_pane in shipping/uc_quote/uc_quote.module
Implements hook_uc_cart_pane().
1 invocation of hook_uc_cart_pane()
uc_cart_cart_pane_list in uc_cart/uc_cart.module
Gets all of the enabled, sorted cart panes.

File

uc_cart/uc_cart.api.php, line 220
Hooks provided by the Cart module.

Code

function hook_uc_cart_pane($items) {
  $body = array();
  if (!is_null($items)) {
    $body = drupal_get_form('uc_cart_view_form', $items) + array(
      '#prefix' => '<div id="cart-form-pane">',
      '#suffix' => '</div>',
    );
  }
  $panes['cart_form'] = array(
    'title' => t('Default cart form'),
    'enabled' => TRUE,
    'weight' => 0,
    'body' => $body,
  );
  return $panes;
}