You are here

function uc_cart_view_table in Ubercart 6.2

Same name and namespace in other branches
  1. 5 uc_cart/uc_cart.module \uc_cart_view_table()
  2. 7.3 uc_cart/uc_cart.module \uc_cart_view_table()

Lists the products in the cart in a TAPIr table.

1 string reference to 'uc_cart_view_table'
uc_cart_view_form in uc_cart/uc_cart.module
Displays a page allowing the customer to view the contents of his or her cart.

File

uc_cart/uc_cart.module, line 1098

Code

function uc_cart_view_table($table) {
  $table['#attributes'] = array(
    'width' => '100%',
  );
  $table['#columns'] = array(
    'remove' => array(
      'cell' => t('Remove'),
      'weight' => 0,
    ),
    'image' => array(
      'cell' => t('Products'),
      'weight' => 1,
    ),
    'desc' => array(
      'cell' => '',
      'weight' => 2,
    ),
    'qty' => array(
      'cell' => t('Qty.'),
      'weight' => 3,
    ),
    'total' => array(
      'cell' => t('Total'),
      'weight' => 4,
    ),
  );
  $subtotal = 0;
  foreach (element_children($table) as $i) {
    $subtotal += $table[$i]['#total'];
    $table[$i]['remove']['#cell_attributes'] = array(
      'align' => 'center',
      'class' => 'remove',
    );
    $table[$i]['image']['#cell_attributes'] = array(
      'class' => 'image',
    );
    $table[$i]['desc']['#cell_attributes'] = array(
      'class' => 'desc',
    );
    $table[$i]['qty']['#cell_attributes'] = array(
      'class' => 'qty',
    );
    $table[$i]['total']['#cell_attributes'] = array(
      'class' => 'price',
    );
    $table[$i]['#attributes'] = array(
      'valign' => 'top',
    );
  }
  $context = array(
    'revision' => 'themed-original',
    'type' => 'amount',
  );
  $table[] = array(
    'total' => array(
      '#value' => '<span id="subtotal-title">' . t('Subtotal:') . '</span> ' . uc_price($subtotal, $context),
      '#cell_attributes' => array(
        'colspan' => 'full',
        'class' => 'subtotal',
      ),
    ),
  );
  return $table;
}