This is a short code snippet to programmatically show number of items in your Drupal Commerce shopping cart block.
You can use this code anywhere, in your theme.
<?php
global $user;
$quantity = 0;
$order = commerce_cart_order_load($user->uid);
if ($order) {
$wrapper = entity_metadata_wrapper('commerce_order', $order);
$line_items = $wrapper->commerce_line_items;
$quantity = commerce_line_items_quantity($line_items, commerce_product_line_item_types());
$total = commerce_line_items_total($line_items);
$currency = commerce_currency_load($total['currency_code']);
}
print format_plural($quantity, '1 item', '@count items');