Merge pull request #958 from openclassify/muammertop

addCart action changed and added cart count
This commit is contained in:
Fatih Alp 2021-02-18 18:19:29 +03:00 committed by GitHub
commit 8eab51e20e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 14 deletions

View File

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

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