addCart action changed and added cart count

This commit is contained in:
Muammer Top 2021-02-18 18:12:55 +03:00
parent 160a3ecc0c
commit 7c06f4338c
2 changed files with 17 additions and 14 deletions

View File

@ -60,22 +60,25 @@ class OptionConfigurationController extends PublicController
public function ajaxConfAddCart()
{
if($conf = $this->optionConfigurationRepository->find($this->request->configuration))
{
$conf->name = $conf->getName();
if (\auth()->check()) {
if($conf = $this->optionConfigurationRepository->find($this->request->configuration))
{
$conf->name = $conf->getName();
$this->adv_model->authControl();
$this->adv_model->authControl();
if ($conf->stock < $this->request->quantity){
return $this->response->json(['status' => 'error', 'msg' => trans('visiosoft.module.carts::message.error1in2')]);
}else{
$cart = $this->dispatch(new GetCart());
$cart->add($conf, $this->request->quantity);
if ($conf->stock < $this->request->quantity){
return $this->response->json(['status' => 'error', 'msg' => trans('visiosoft.module.carts::message.error1in2')]);
}else{
$cart = $this->dispatch(new GetCart());
$cart->add($conf, $this->request->quantity);
$count = $cart->getItems()->count;
return $this->response->json(['status'=> 'success', 'count' => $count]);
$count = $cart->getItems()->count;
return $this->response->json(['status'=> 'success', 'count' => $count]);
}
}
return $this->response->json(['status' => 'error', 'msg' => trans('visiosoft.module.carts::message.error2')]);
}
return $this->response->json(['status' => 'error', 'msg' => trans('visiosoft.module.carts::message.error2')]);
return $this->response->json(['status' => 'guest']);
}
}

View File

@ -1200,6 +1200,8 @@ class AdvsController extends PublicController
if ($adv) {
$cart = $thisModel->addCart($adv, $quantity, $name);
$response['status'] = "success";
$count = $cart->getItems()->count;
$response['count'] = $count;
} else {
$response['status'] = "error";
$response['msg'] = trans('visiosoft.module.advs::message.error_added_cart');
@ -1208,8 +1210,6 @@ class AdvsController extends PublicController
$response['status'] = "guest";
}
$count = $cart->getItems()->count;
$response['count'] = $count;
return $response;
}