protected function CartController::getCartViews in Commerce Core 8.2
Gets the cart views for each cart.
Parameters
\Drupal\commerce_order\Entity\OrderInterface[] $carts: The cart orders.
Return value
array An array of view ids keyed by cart order ID.
1 call to CartController::getCartViews()
- CartController::cartPage in modules/
cart/ src/ Controller/ CartController.php - Outputs a cart view for each non-empty cart belonging to the current user.
File
- modules/
cart/ src/ Controller/ CartController.php, line 94
Class
- CartController
- Provides the cart page.
Namespace
Drupal\commerce_cart\ControllerCode
protected function getCartViews(array $carts) {
$order_type_ids = array_map(function ($cart) {
/** @var \Drupal\commerce_order\Entity\OrderInterface $cart */
return $cart
->bundle();
}, $carts);
$order_type_storage = $this
->entityTypeManager()
->getStorage('commerce_order_type');
$order_types = $order_type_storage
->loadMultiple(array_unique($order_type_ids));
$cart_views = [];
foreach ($order_type_ids as $cart_id => $order_type_id) {
/** @var \Drupal\commerce_order\Entity\OrderTypeInterface $order_type */
$order_type = $order_types[$order_type_id];
$cart_views[$cart_id] = $order_type
->getThirdPartySetting('commerce_cart', 'cart_form_view', 'commerce_cart_form');
}
return $cart_views;
}