You are here

function hook_cart_pane in Ubercart 6.2

Same name and namespace in other branches
  1. 5 docs/hooks.php \hook_cart_pane()

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_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 with the following keys:

  • "id"

    • type: string
    • value: The internal ID of the pane, using a-z, 0-9, and - or _.
  • "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: string
    • value: The body of the pane when 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.

3 functions implement hook_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_cart_pane in uc_cart/uc_cart.module
Implements hook_cart_pane().
uc_paypal_cart_pane in payment/uc_paypal/uc_paypal.module
Implements hook_cart_pane().
uc_quote_cart_pane in shipping/uc_quote/uc_quote.module
Implements hook_cart_pane().
1 invocation of hook_cart_pane()
uc_cart_cart_pane_list in uc_cart/uc_cart.module
Gets all of the enabled, sorted cart panes.

File

docs/hooks.php, line 327
These are the hooks that are invoked by the Ubercart core.

Code

function hook_cart_pane($items) {
  $panes[] = array(
    'id' => 'cart_form',
    'title' => t('Default cart form'),
    'enabled' => TRUE,
    'weight' => 0,
    'body' => !is_null($items) ? drupal_get_form('uc_cart_view_form', $items) : '',
  );
  return $panes;
}