You are here

public static function Utility::cartCount in Basic cart 8.4

Same name and namespace in other branches
  1. 8.6 src/Utility.php \Drupal\basic_cart\Utility::cartCount()
  2. 8.2 src/Utility.php \Drupal\basic_cart\Utility::cartCount()
  3. 8.3 src/Utility.php \Drupal\basic_cart\Utility::cartCount()
  4. 8.5 src/Utility.php \Drupal\basic_cart\Utility::cartCount()

Get Cart count.

2 calls to Utility::cartCount()
CartController::addToCart in src/Controller/CartController.php
Add node to cart.
CountBlock::build in src/Plugin/Block/CountBlock.php
Builds and returns the renderable array for this block plugin.

File

src/Utility.php, line 443

Class

Utility
Utilty functions for basic cart.

Namespace

Drupal\basic_cart

Code

public static function cartCount() {
  $cart = Utility::getCart();
  return isset($cart['cart_quantity']) ? array_sum($cart['cart_quantity']) : 0;
}