mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
addCart action changed and added cart count
This commit is contained in:
parent
160a3ecc0c
commit
7c06f4338c
@ -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']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user