@extends('admin/layout') @section('title') {{ labels('admin_labels.edit_orders', 'Edit Orders') }} @endsection @section('content') @php use App\Models\OrderCharges; use App\Services\MediaService; use App\Services\ShiprocketService; use App\Services\CurrencyService; use App\Services\OrderService; @endphp
{{ labels('admin_labels.order_number', 'Order Number') }}

#{{ $order_detls[0]->id }}

{{ labels('admin_labels.order_date', 'Order Date') }} : 01 Jan, 1970 {{ labels('admin_labels.invoice', 'Invoice') }}
{{ labels('admin_labels.customer_info', 'Customer Info') }}
{{ labels('admin_labels.name', 'Name') }}: {{ $order_detls[0]->user_name }}
{{ labels('admin_labels.mobile', 'Contact') }}: @if ($order_detls[0]->mobile != '' && isset($order_detls[0]->mobile)) {{ $order_detls[0]->mobile }} @else {{ isset($mobile_data) ? $mobile_data[0]->mobile : '' }} @endif
{{ labels('admin_labels.email', 'Email') }}: {{ $order_detls[0]->email }}
{{ labels('admin_labels.shipping_info', 'Shipping Info') }}
{{ labels('admin_labels.name', 'Name') }}: {{ $order_detls[0]->user_name }}
{{ labels('admin_labels.mobile', 'Contact') }}: @if ($order_detls[0]->mobile != '' && isset($order_detls[0]->mobile)) {{ $order_detls[0]->mobile }} @else {{ isset($mobile_data) ? $mobile_data[0]->mobile : '' }} @endif
{{ labels('admin_labels.address', 'Address') }}: {{ $order_detls[0]->address }}
{{ labels('admin_labels.seller_info', 'Seller Info') }}
{{ labels('admin_labels.seller_name', 'Seller Name') }}: {{ $sellers[0]['seller_name'] }}
{{ labels('admin_labels.mobile', 'Contact') }}: {{ $sellers[0]['seller_mobile'] }}
{{ labels('admin_labels.email', 'Email') }}: {{ $sellers[0]['seller_email'] }}
@for ($i = 0; $i < count($sellers); $i++) @php $seller_data = fetchDetails( \App\Models\User::class, ['id' => $sellers[$i]['user_id']], ['username', 'fcm_id'], ); $seller_otp = fetchDetails( \App\Models\OrderItems::class, ['order_id' => $order_detls[0]->order_id, 'seller_id' => $sellers[$i]['id']], 'otp', )[0]->otp; $order_charges_data = fetchDetails(OrderCharges::class, [ 'order_id' => $order_detls[0]->order_id, 'seller_id' => $sellers[$i]['id'], ]); $seller_order = app(OrderService::class)->getOrderDetails( ['o.id' => $order_detls[0]->order_id, 'oi.seller_id' => $sellers[$i]['id']], '', '', $store_id, ); $pickup_location = collect($seller_order) ->pluck('pickup_location') ->unique() ->values() ->all(); @endphp
{{ labels('admin_labels.seller', 'Seller') }}

{{ $seller_data[0]->username }}

{{ labels('admin_labels.otp', 'OTP') }}

{{ isset($order_charges_data[0]->otp) ? $order_charges_data[0]->otp : $seller_otp }}

@for ($j = 0; $j < count($pickup_location); $j++) @php // --------------------------------------- code for shiprocket //----------------------------------------------- $ids = ''; foreach ($seller_order as $row) { if ($row->pickup_location == $pickup_location[$j]) { $ids .= $row->order_item_id . ','; } } @endphp @php $total = 0; $tax_amount = 0; @endphp
@php $item_subtotal = 0; $total = 0; $tax_amount = 0; @endphp @foreach ($items as $item) @php $selected = ''; $item['discounted_price'] = $item['discounted_price'] == '' ? 0 : $item['discounted_price']; $total += $subtotal = $item['quantity'] != 0 && ($item['discounted_price'] != '' && $item['discounted_price'] > 0) && $item['price'] > $item['discounted_price'] ? $item['price'] - $item['discounted_price'] : $item['price'] * $item['quantity']; $tax_amount += $item['tax_amount']; $total += $subtotal = $tax_amount; $item_subtotal += $item['item_subtotal']; @endphp @if ($sellers[$i]['id'] == $item['seller_id']) @if ($pickup_location[$j] == $item['pickup_location']) @php $order_tracking_data = app( ShiprocketService::class, )->getShipmentId($item['id'], $order_detls[0]->id); $product_name = json_decode($row->pname, true); $product_name = $product_name['en'] ?? ''; // dd($item) @endphp @php $badges = [ 'awaiting' => 'secondary', 'received' => 'primary', 'processed' => 'info', 'shipped' => 'warning', 'delivered' => 'success', 'returned' => 'danger', 'cancelled' => 'danger', 'return_request_approved' => 'success', 'return_request_decline' => 'danger', 'return_request_pending' => 'warning', 'return_pickedup' => 'success', ]; if ( $item['active_status'] == 'return_request_pending' ) { $status = 'Return Requested'; } elseif ( $item['active_status'] == 'return_request_approved' ) { $status = 'Return Approved'; } elseif ( $item['active_status'] == 'return_request_decline' ) { $status = 'Return Declined'; } else { $status = $item['active_status']; } @endphp @if ($item['product_type'] == 'digital_product' && $item['download_allowed'] == 0 && $item['is_sent'] == 0) @endif @endif @endif @endforeach
{{ labels('admin_labels.product_items', 'Product Items') }} {{ labels('admin_labels.variations', 'Variation') }} {{ labels('admin_labels.discount', 'Discount') }} {{ labels('admin_labels.price', 'Price') }} {{ labels('admin_labels.quantity', 'Qty') }} {{ labels('admin_labels.deliver_by', 'Deliver By') }} {{ labels('admin_labels.active_status', 'Active Status') }}
{{ $product_name }}
{{ isset($item['product_variants']) && !empty($item['product_variants']) ? str_replace(',', ' | ', $item['product_variants'][0]['variant_values']) : '-' }} {{ $item['discounted_price'] }} {{ $item['price'] }} {{ $item['quantity'] }} {{ $item['deliver_by'] }} {{ $status }}
@endfor
@endfor
{{ labels('admin_labels.payment_info', 'Payment Info') }}
@if (isset($order_detls[0]->txn_id) && !empty($order_detls[0]->txn_id))
{{ labels('admin_labels.id', 'ID') }}: #{{ $order_detls[0]->txn_id }}
@endif
{{ labels('admin_labels.payment_method', 'Payment Method') }}: {{ ucfirst(str_replace('_', ' ', $order_detls[0]->payment_method)) }} @if (isset($transaction_search_res) && !empty($transaction_search_res)) {{ labels('admin_labels.edit', 'Edit') }} @endif
@if (!empty($bank_transfer))
@php $status = ['history', 'ban', 'check']; @endphp
@php $i = 1; @endphp @foreach ($bank_transfer as $row1) @php $imagePath = asset('/storage/' . $row1->attachments); @endphp
[Attachment{{ $i }} ] @if ($row1->status == 0) @elseif ($row1->status == 1) @elseif ($row1->status == 2) @else @endif
@php $i++; @endphp @endforeach
@endif
{{ labels('admin_labels.total_order_amount', 'Total Order Amount') }}
{{ labels('admin_labels.sub_total', 'Sub Total') }} {{ app(CurrencyService::class)->formateCurrency(formatePriceDecimal($item_subtotal)) }}
{{ labels('admin_labels.delivery_charges', 'Shipping Charges') }} {{ app(CurrencyService::class)->formateCurrency(formatePriceDecimal($items[0]['seller_delivery_charge'])) }}
{{ labels('admin_labels.wallet_balance', 'Wallet Balance') }} {{ app(CurrencyService::class)->formateCurrency(formatePriceDecimal($items[0]['wallet_balance'])) }}
{{ labels('admin_labels.discount_amount', 'Discount Amount') }} {{ app(CurrencyService::class)->formateCurrency(formatePriceDecimal($items[0]['seller_promo_discount'])) }}

{{-- @dd($order_detls[0]); --}}
{{-- @php $total = $item_subtotal + (float) ('' . $order_detls[0]->delivery_charge) - $order_detls[0]->promo_discount - $items[0]['wallet_balance']; @endphp --}} {{-- apply seller delivery charge because if order return than it update delivery charge as 0 --}} @php $deliveryCharge = (float) ('' . $order_detls[0]->delivery_charge); // If delivery_charge is 0, use seller_delivery_charge if ($deliveryCharge == 0) { $deliveryCharge = (float) $items[0]['seller_delivery_charge']; } $total = $item_subtotal + $deliveryCharge - $order_detls[0]->promo_discount - $items[0]['wallet_balance']; @endphp {{ labels('admin_labels.total_amount', 'Total Amount') }}
{{ app(CurrencyService::class)->formateCurrency(formatePriceDecimal($total)) }}
@endsection