function theme_basic_cart_render_cart_element in Basic cart 7
Same name and namespace in other branches
- 7.3 basic_cart.theme.inc \theme_basic_cart_render_cart_element()
- 7.2 basic_cart.theme.inc \theme_basic_cart_render_cart_element()
Theme implementation for rendering the cart element.
1 theme call to theme_basic_cart_render_cart_element()
- basic_cart_cart_form in ./
basic_cart.cart.inc - Shopping cart form.
File
- ./
basic_cart.cart.inc, line 82 - Basic cart shopping cart implementation functions.
Code
function theme_basic_cart_render_cart_element($variables) {
// Element name and nid.
$name = $variables['form']['#name'];
$nid = (int) str_replace(array(
'cartcontents[',
']',
), '', $name);
if (empty($nid)) {
return '';
}
// Delete image.
$vars = array(
'path' => base_path() . drupal_get_path('module', 'basic_cart') . '/images/delete.gif',
'alt' => t('Remove from cart'),
'title' => t('Remove from cart'),
'attributes' => array(
'class' => 'basic-cart-delete-image-image',
),
);
$delete_link = l(theme('image', $vars), 'cart/remove/' . $nid, array(
'html' => TRUE,
));
// Getting the node for it's title and description.
$node = basic_cart_get_cart($nid);
// Node description.
$desc = '';
if (isset($node->basic_cart_node_description)) {
$desc = drupal_strlen($node->basic_cart_node_description) > 50 ? truncate_utf8($node->basic_cart_node_description, 50) : $node->basic_cart_node_description;
}
// Prefix.
$prefix = '<div class="basic-cart-cart-contents row">';
$prefix .= ' <div class="basic-cart-cart-quantity cell">';
$prefix .= ' <div class="cell">';
// Suffix.
$suffix = ' </div>';
$suffix .= ' <div class="cell basic-cart-cart-x">x</div>';
$suffix .= ' </div>';
$suffix .= ' <div class="basic-cart-cart-node-title cell">' . l($node->title, 'node/' . $nid) . '<br />';
$suffix .= ' <span class="basic-cart-cart-node-summary">' . $desc . '</span>';
$suffix .= ' </div>';
$suffix .= ' <div class="basic-cart-delete-image cell">' . $delete_link . '</div>';
$suffix .= '</div>';
// Rendering the element as textfield.
$quantity = theme('textfield', $variables['form']);
// Full view return.
return $prefix . $quantity . $suffix;
}