mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-09 23:06:08 -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()
|
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']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1200,6 +1200,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');
|
||||||
@ -1208,8 +1210,6 @@ class AdvsController extends PublicController
|
|||||||
$response['status'] = "guest";
|
$response['status'] = "guest";
|
||||||
}
|
}
|
||||||
|
|
||||||
$count = $cart->getItems()->count;
|
|
||||||
$response['count'] = $count;
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user