You are here

function commerce_cart_blocks_cart_count in Commerce Cart Blocks 8

Return the cart count.

Return value

int Cart count.

1 call to commerce_cart_blocks_cart_count()
commerce_cart_blocks_ajax_callback in ./commerce_cart_blocks.module
Ajax callback for variation product form.

File

./commerce_cart_blocks.module, line 427
Contains commerce_cart_blocks.module.

Code

function commerce_cart_blocks_cart_count() {
  $carts = commerce_cart_blocks_get_carts();
  $count = 0;
  if (!empty($carts)) {
    foreach ($carts as $cart_id => $cart) {
      foreach ($cart
        ->getItems() as $order_item) {
        $count += (int) $order_item
          ->getQuantity();
      }
    }
  }
  return $count;
}