diff --git a/packages/Webkul/Customer/src/Http/Controllers/CustomerController.php b/packages/Webkul/Customer/src/Http/Controllers/CustomerController.php index c3c67ce77..f641691cf 100755 --- a/packages/Webkul/Customer/src/Http/Controllers/CustomerController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/CustomerController.php @@ -137,10 +137,19 @@ class CustomerController extends Controller $data = request()->all(); - $customer = $this->customerRepository->findorFail($id); + $customerRepository = $this->customerRepository->findorFail($id); + + $orders = $customerRepository->all_orders->whereIn('status', ['pending', 'processing'])->first(); + + if ( $orders ) { + + session()->flash('error', trans('admin::app.response.order-pending')); + + return redirect()->route($this->_config['redirect']); + } try { - if (Hash::check($data['password'], $customer->password)) { + if ( Hash::check($data['password'], $customerRepository->password) ) { $this->customerRepository->delete($id); @@ -153,13 +162,12 @@ class CustomerController extends Controller return redirect()->route($this->_config['redirect']); } catch(\Exception $e) { - session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Customer'])); + session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Customer'])); - return redirect()->route($this->_config['redirect']); + return redirect()->route($this->_config['redirect']); } } - /** * Load the view for the customer account panel, showing approved reviews. *