You are here

protected function CartBlockBase::getCartViews in Commerce Cart Blocks 8

Gets the cart views for each cart.

Return value

array An array of view ids keyed by cart order ID.

2 calls to CartBlockBase::getCartViews()
CartBlock::buildItems in src/Plugin/Block/CartBlock.php
CartButtonBlock::getCartViews in src/Plugin/Block/CartButtonBlock.php
Gets the cart views for each cart.
1 method overrides CartBlockBase::getCartViews()
CartButtonBlock::getCartViews in src/Plugin/Block/CartButtonBlock.php
Gets the cart views for each cart.

File

src/Plugin/Block/CartBlockBase.php, line 341

Class

CartBlockBase
CartBlockBase class.

Namespace

Drupal\commerce_cart_blocks\Plugin\Block

Code

protected function getCartViews() {
  $carts = $this
    ->getCarts();
  $availableViews = $this
    ->getAvailableViews($carts);
  $cartViews = [];
  foreach ($carts as $cartId => $cart) {
    $cartViews[] = [
      '#prefix' => '<div class="cart cart-block">',
      '#suffix' => '</div>',
      '#type' => 'view',
      '#name' => $availableViews[$cartId],
      '#arguments' => [
        $cartId,
      ],
      '#embed' => TRUE,
    ];
  }
  return $cartViews;
}