public function CartTable::getCart in Basic cart 8
Same name and namespace in other branches
- 8.6 src/CartTable.php \Drupal\basic_cart\CartTable::getCart()
- 8.0 src/CartTable.php \Drupal\basic_cart\CartTable::getCart()
- 8.2 src/CartTable.php \Drupal\basic_cart\CartTable::getCart()
- 8.3 src/CartTable.php \Drupal\basic_cart\CartTable::getCart()
- 8.4 src/CartTable.php \Drupal\basic_cart\CartTable::getCart()
- 8.5 src/CartTable.php \Drupal\basic_cart\CartTable::getCart()
* Function for shopping cart retrieval. * *
Parameters
int $nid: * We are using the node id to store the node in the shopping cart * * @return mixed * Returning the shopping cart contents. * An empty array if there is nothing in the cart
Overrides CartInterface::getCart
1 call to CartTable::getCart()
File
- src/
CartTable.php, line 36
Class
- CartTable
- Class CartTable.
Namespace
Drupal\basic_cartCode
public function getCart($nid = NULL) {
if (isset($nid)) {
return array(
"cart" => $_SESSION['basic_cart']['cart'][$nid],
"cart_quantity" => $_SESSION['basic_cart']['cart_quantity'][$nid],
);
}
if (isset($_SESSION['basic_cart']['cart'])) {
return array(
"cart" => $_SESSION['basic_cart']['cart'],
"cart_quantity" => $_SESSION['basic_cart']['cart_quantity'],
);
}
// Empty cart.
return array(
"cart" => array(),
"cart_quantity" => array(),
);
}