public function CartTable::loggedInActionCart in Basic cart 8
Same name and namespace in other branches
- 8.6 src/CartTable.php \Drupal\basic_cart\CartTable::loggedInActionCart()
- 8.0 src/CartTable.php \Drupal\basic_cart\CartTable::loggedInActionCart()
- 8.2 src/CartTable.php \Drupal\basic_cart\CartTable::loggedInActionCart()
- 8.3 src/CartTable.php \Drupal\basic_cart\CartTable::loggedInActionCart()
- 8.4 src/CartTable.php \Drupal\basic_cart\CartTable::loggedInActionCart()
- 8.5 src/CartTable.php \Drupal\basic_cart\CartTable::loggedInActionCart()
File
- src/
CartTable.php, line 111
Class
- CartTable
- Class CartTable.
Namespace
Drupal\basic_cartCode
public function loggedInActionCart() {
if (isset($_SESSION['basic_cart']['cart']) && isset($_SESSION['basic_cart']['cart_quantity'])) {
foreach ($_SESSION['basic_cart']['cart'] as $id => $value) {
$param = array();
$param['uid'] = $this->user_id;
$param['id'] = $id;
$param['entitytype'] = $value
->getEntityTypeId();
$table_data = $this->cart_storage
->load($param);
if ($table_data) {
$param['quantity'] = $_SESSION['basic_cart']['cart_quantity'][$id];
$table_data = $this->cart_storage
->update($param);
}
else {
$param['quantity'] = $_SESSION['basic_cart']['cart_quantity'][$id];
$this->cart_storage
->insert($param);
}
}
}
$param = array();
$param['uid'] = $this->user_id;
$exist_data = $this->cart_storage
->load($param);
foreach ($exist_data as $key) {
if (!isset($_SESSION['basic_cart']['cart'][$key->id])) {
$_SESSION['basic_cart']['cart_quantity'][$key->id] = $key->quantity;
$_SESSION['basic_cart']['cart'][$key->id] = \Drupal::entityTypeManager()
->getStorage($key->entitytype)
->load($key->id);
}
}
}