public function CartController::addToCartNoRedirect in Basic cart 8.3
Same name and namespace in other branches
- 8.6 src/Controller/CartController.php \Drupal\basic_cart\Controller\CartController::addToCartNoRedirect()
- 8 src/Controller/CartController.php \Drupal\basic_cart\Controller\CartController::addToCartNoRedirect()
- 8.0 src/Controller/CartController.php \Drupal\basic_cart\Controller\CartController::addToCartNoRedirect()
- 8.2 src/Controller/CartController.php \Drupal\basic_cart\Controller\CartController::addToCartNoRedirect()
- 8.4 src/Controller/CartController.php \Drupal\basic_cart\Controller\CartController::addToCartNoRedirect()
- 8.5 src/Controller/CartController.php \Drupal\basic_cart\Controller\CartController::addToCartNoRedirect()
Add node to cart.
Parameters
int $nid: Node id of the cart content.
Return value
Object Redirect Object response
1 string reference to 'CartController::addToCartNoRedirect'
File
- src/
Controller/ CartController.php, line 155
Class
- CartController
- Contains the cart controller.
Namespace
Drupal\basic_cart\ControllerCode
public function addToCartNoRedirect($nid) {
\Drupal::service('page_cache_kill_switch')
->trigger();
$query = \Drupal::request()->query;
$config = Utility::cartSettings();
$param['entitytype'] = $query
->get('entitytype') ? $query
->get('entitytype') : "node";
$param['quantity'] = $query
->get('quantity') ? is_numeric($query
->get('quantity')) ? (int) $query
->get('quantity') : 1 : 1;
Utility::addToCart($nid, $param);
return new RedirectResponse(Url::fromUserInput("/" . trim($config
->get('add_to_cart_redirect'), '/'))
->toString());
}