You are here

function commerce_cart_blocks_get_carts in Commerce Cart Blocks 8

Get carts.

2 calls to commerce_cart_blocks_get_carts()
commerce_cart_blocks_cart_count in ./commerce_cart_blocks.module
Return the cart count.
commerce_cart_blocks_show_cart_dialog_command in ./commerce_cart_blocks.module
Dialog command callback.

File

./commerce_cart_blocks.module, line 445
Contains commerce_cart_blocks.module.

Code

function commerce_cart_blocks_get_carts() {

  /** @var \Drupal\commerce_order\Entity\OrderInterface[] $carts */
  $carts = \Drupal::service('commerce_cart.cart_provider')
    ->getCarts();
  $carts = array_filter($carts, function ($cart) {

    /** @var \Drupal\commerce_order\Entity\OrderInterface $cart */
    return $cart
      ->hasItems() && $cart->cart->value;
  });
  return $carts;
}