You are here

public static function Utility::addToCart in Basic cart 8.2

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

Add to cart.

Parameters

int $id: Node id.

array $params: Quantity and entity types.

2 calls to Utility::addToCart()
CartController::addToCart in src/Controller/CartController.php
Add node to cart.
CartController::addToCartNoRedirect in src/Controller/CartController.php
Add node to cart.

File

src/Utility.php, line 97

Class

Utility
Utilty functions for basic cart.

Namespace

Drupal\basic_cart

Code

public static function addToCart($id, array $params = array()) {
  $storage = static::getStorage();
  $storage
    ->addToCart($id, $params);
}