public function CartController::listing in Ubercart 8.4
Displays the cart view page.
Show the products in the cart with a form to adjust cart contents or go to checkout.
1 string reference to 'CartController::listing'
- uc_cart.routing.yml in uc_cart/
uc_cart.routing.yml - uc_cart/uc_cart.routing.yml
File
- uc_cart/
src/ Controller/ CartController.php, line 46
Class
- CartController
- Controller routines for the shopping cart.
Namespace
Drupal\uc_cart\ControllerCode
public function listing() {
// Load the array of shopping cart items.
$cart = $this->cartManager
->get();
$items = $cart
->getContents();
// Display the empty cart page if there are no items in the cart.
if (empty($items)) {
$build = [
'#theme' => 'uc_cart_empty',
];
\Drupal::service('renderer')
->addCacheableDependency($build, $cart);
return $build;
}
return $this
->formBuilder()
->getForm('Drupal\\uc_cart\\Form\\CartForm', $cart);
}