Skip navigation
Help

hook_uc_cart_pane

7 uc_cart.api.php hook_uc_cart_pane($items)

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.

Related topics

2 functions implement hook_uc_cart_pane()

1 invocation of hook_uc_cart_pane()

File

ubercart/uc_cart/uc_cart.api.php, line 221
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;
}