You are here

public function CartController::removeFromCart in Basic cart 8.3

Same name and namespace in other branches
  1. 8.6 src/Controller/CartController.php \Drupal\basic_cart\Controller\CartController::removeFromCart()
  2. 8 src/Controller/CartController.php \Drupal\basic_cart\Controller\CartController::removeFromCart()
  3. 8.0 src/Controller/CartController.php \Drupal\basic_cart\Controller\CartController::removeFromCart()
  4. 8.2 src/Controller/CartController.php \Drupal\basic_cart\Controller\CartController::removeFromCart()
  5. 8.4 src/Controller/CartController.php \Drupal\basic_cart\Controller\CartController::removeFromCart()
  6. 8.5 src/Controller/CartController.php \Drupal\basic_cart\Controller\CartController::removeFromCart()

Remove node from cart.

Parameters

int $nid: Node id of the cart content.

Return value

Object Redirect to HTTP_REFERER

1 string reference to 'CartController::removeFromCart'
basic_cart.routing.yml in ./basic_cart.routing.yml
basic_cart.routing.yml

File

src/Controller/CartController.php, line 60

Class

CartController
Contains the cart controller.

Namespace

Drupal\basic_cart\Controller

Code

public function removeFromCart($nid) {
  \Drupal::service('page_cache_kill_switch')
    ->trigger();
  Utility::removeFromCart($nid);
  return new RedirectResponse(Url::fromUri($_SERVER['HTTP_REFERER'])
    ->toString());
}