protected function CartBlockBase::getCartCount in Commerce Cart Blocks 8
4 calls to CartBlockBase::getCartCount()
- CartBlock::build in src/
Plugin/ Block/ CartBlock.php - Builds the cart block.
- CartBlockBase::getCountText in src/
Plugin/ Block/ CartBlockBase.php - Gets the text representation of the count of items.
- CartBlockBase::shouldHide in src/
Plugin/ Block/ CartBlockBase.php - CartButtonBlock::build in src/
Plugin/ Block/ CartButtonBlock.php - Builds the cart block.
File
- src/
Plugin/ Block/ CartBlockBase.php, line 303
Class
- CartBlockBase
- CartBlockBase class.
Namespace
Drupal\commerce_cart_blocks\Plugin\BlockCode
protected function getCartCount() {
$carts = $this
->getCarts();
$count = 0;
foreach ($carts as $cart_id => $cart) {
foreach ($cart
->getItems() as $order_item) {
$count += (int) $order_item
->getQuantity();
}
}
return $count;
}