Order Issue Fixed

This commit is contained in:
Devansh 2020-07-30 12:40:15 +05:30
parent 3dba7b9177
commit dfc346ec76
3 changed files with 56 additions and 31 deletions

View File

@ -64,12 +64,12 @@ class CustomerController extends Controller
CustomerGroupRepository $customerGroupRepository,
ChannelRepository $channelRepository
)
{
$this->_config = request('_config');
$this->middleware('admin');
$this->customerRepository = $customerRepository;
$this->customerAddressRepository = $customerAddressRepository;
$this->customerGroupRepository = $customerGroupRepository;
$this->channelRepository = $channelRepository;
@ -200,12 +200,20 @@ class CustomerController extends Controller
$customer = $this->customerRepository->findorFail($id);
try {
$this->customerRepository->delete($id);
if (!$this->customerRepository->checkIfCustomerHasOrderPendingOrProcessing($customer)) {
$this->customerRepository->delete($id);
} else {
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Customer']));
return response()->json(['message' => false], 400);
}
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Customer']));
return response()->json(['message' => true], 200);
} catch (\Exception $e) {
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Customer']));
}

View File

@ -157,37 +157,41 @@
</div>
</accordian>
<accordian :title="'{{ __('admin::app.sales.orders.address') }}'" :active="true">
<div slot="body">
@if ($order->billing_address || $order->shipping_address)
<accordian :title="'{{ __('admin::app.sales.orders.address') }}'" :active="true">
<div slot="body">
<div class="sale-section">
<div class="secton-title">
<span>{{ __('admin::app.sales.orders.billing-address') }}</span>
</div>
@if($order->billing_address)
<div class="sale-section">
<div class="secton-title">
<span>{{ __('admin::app.sales.orders.billing-address') }}</span>
</div>
<div class="section-content">
@include ('admin::sales.address', ['address' => $order->billing_address])
<div class="section-content">
@include ('admin::sales.address', ['address' => $order->billing_address])
{!! view_render_event('sales.order.billing_address.after', ['order' => $order]) !!}
</div>
</div>
@endif
@if ($order->shipping_address)
<div class="sale-section">
<div class="secton-title">
<span>{{ __('admin::app.sales.orders.shipping-address') }}</span>
</div>
<div class="section-content">
@include ('admin::sales.address', ['address' => $order->shipping_address])
{!! view_render_event('sales.order.shipping_address.after', ['order' => $order]) !!}
</div>
</div>
@endif
{!! view_render_event('sales.order.billing_address.after', ['order' => $order]) !!}
</div>
</div>
@if ($order->shipping_address)
<div class="sale-section">
<div class="secton-title">
<span>{{ __('admin::app.sales.orders.shipping-address') }}</span>
</div>
<div class="section-content">
@include ('admin::sales.address', ['address' => $order->shipping_address])
{!! view_render_event('sales.order.shipping_address.after', ['order' => $order]) !!}
</div>
</div>
@endif
</div>
</accordian>
</accordian>
@endif
<accordian :title="'{{ __('admin::app.sales.orders.payment-and-shipping') }}'" :active="true">
<div slot="body">

View File

@ -16,4 +16,17 @@ class CustomerRepository extends Repository
{
return 'Webkul\Customer\Contracts\Customer';
}
/**
* Check if customer has order pending or processing.
*
* @param Webkul\Customer\Models\Customer
* @return boolean
*/
public function checkIfCustomerHasOrderPendingOrProcessing($customer)
{
return $customer->all_orders->pluck('status')->contains(function ($val) {
return $val === 'pending' || $val === 'processing';
});
}
}