Ejemplo n.º 1
0
 /**
  * Добавление товара в корзину
  */
 public function addAction()
 {
     if (!isset($_POST['id']) || !isset($_POST['count']) || !isset($_POST['type'])) {
         $this->errorAction(1001, 'Custom system error', ['postArgument' => 'noPostArgument']);
     }
     $id = getInt($_POST['id']);
     $count = getInt($_POST['count']);
     $type = htmlspecialchars(trim($_POST['type']));
     // Вернуть количество товаров и их общую сумму, новую
     $cart = new ModelCart();
     $status = $cart->add($id, $count, $type);
     if (!$status) {
         $this->errorAction(1002);
     }
     $summ = $cart->getCostItems();
     $count = $cart->getCountItems();
     $this->addData(['succes' => 'Ok', 'count' => $count, 'summ' => $summ]);
     $this->successAction();
 }