function menu_badges_commerce_cart_item_count in Menu Badges 7
Drupal Commcerce cart items count callback.
Parameters
array $arguments:
1 string reference to 'menu_badges_commerce_cart_item_count'
- menu_badges_menu_badges_options in ./
menu_badges.module - Implements hook_menu_badges_options().
File
- ./
menu_badges.module, line 337 - Menu Badges module file.
Code
function menu_badges_commerce_cart_item_count() {
global $user;
if (module_exists('commerce_cart') && ($order = commerce_cart_order_load($user->uid))) {
// Count the number of product line items on the order.
$wrapper = entity_metadata_wrapper('commerce_order', $order);
$quantity = commerce_line_items_quantity($wrapper->commerce_line_items, commerce_product_line_item_types());
if ($quantity > 0) {
return $quantity;
}
}
return NULL;
}