@extends('admin/layout') @section('title') {{ labels('admin_labels.edit_orders', 'Edit Orders') }} @endsection @section('content')

{{ labels('admin_labels.order_details', 'Order Details') }}

{{ labels('admin_labels.see_every_detail_steer_every_step', 'See Every Detail Steer Every Step') }}

{{ 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( 'users', ['id' => $sellers[$i]['user_id']], ['username', 'fcm_id'], ); $seller_otp = fetchDetails( 'order_items', ['order_id' => $order_detls[0]->order_id, 'seller_id' => $sellers[$i]['id']], 'otp', )[0]->otp; $order_caharges_data = fetchDetails('order_charges', [ 'order_id' => $order_detls[0]->order_id, 'seller_id' => $sellers[$i]['id'], ]); $seller_order = 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_caharges_data[0]->otp) ? $order_caharges_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 . ','; } } $order_item_ids = explode(',', trim($ids, ',')); $order_tracking_data = getShipmentId( $order_item_ids[0], $order_detls[0]->order_id, ); $shiprocket_order = isset($order_tracking_data[0]['shiprocket_order_id']) && $order_tracking_data[0]['shiprocket_order_id'] != 0 ? get_shiprocket_order($order_tracking_data[0]['shiprocket_order_id']) : []; foreach ($order_item_ids as $id) { $active_status = fetchDetails( 'order_items', ['id' => $id, 'seller_id' => $sellers[$i]['id']], 'active_status', )[0]->active_status; if ( isset($shiprocket_order['data']) && $shiprocket_order['data']['status'] == 'PICKUP SCHEDULED' && $active_status != 'shipped' ) { updateOrder( ['active_status' => 'shipped'], ['id' => $id, 'seller_id' => $sellers[$i]['id']], false, 'order_items', ); updateOrder( ['status' => 'shipped'], ['id' => $id, 'seller_id' => $sellers[$i]['id']], true, 'order_items', ); $type = ['type' => 'customer_order_shipped']; $order_status = 'shipped'; } if ( isset($shiprocket_order['data']) && ($shiprocket_order['data']['status'] == 'CANCELED' || $shiprocket_order['data']['status'] == 'CANCELLATION REQUESTED') && $active_status != 'cancelled' ) { updateOrder( ['active_status' => 'cancelled'], ['id' => $id, 'seller_id' => $sellers[$i]['id']], false, 'order_items', ); updateOrder( ['status' => 'cancelled'], ['id' => $id, 'seller_id' => $sellers[$i]['id']], true, 'order_items', ); $type = ['type' => 'customer_order_cancelled']; $order_status = 'cancelled'; } if ( isset($shiprocket_order['data']) && strtolower($shiprocket_order['data']['status']) == 'delivered' && $active_status != 'delivered' ) { updateOrder( ['active_status' => 'delivered'], ['id' => $id, 'seller_id' => $sellers[$i]['id']], false, 'order_items', ); updateOrder( ['status' => 'delivered'], ['id' => $id, 'seller_id' => $sellers[$i]['id']], true, 'order_items', ); $type = ['type' => 'customer_order_delivered']; $order_status = 'delivered'; } if ( isset($shiprocket_order['data']) && $shiprocket_order['data']['status'] == 'READY TO SHIP' && $active_status != 'processed' ) { updateOrder( ['active_status' => 'processed'], ['id' => $id, 'seller_id' => $sellers[$i]['id']], false, 'order_items', ); updateOrder( ['status' => 'processed'], ['id' => $id, 'seller_id' => $sellers[$i]['id']], true, 'order_items', ); $type = ['type' => 'customer_order_processed']; $order_status = 'processed'; } //send notification while shiprocket order status changed if (isset($type) && !empty($type)) { $settings = getSettings('system_settings', true); $settings = json_decode($settings, true); $app_name = isset($settings['app_name']) && !empty($settings['app_name']) ? $settings['app_name'] : ''; $custom_notification = fetchDetails('custom_messages', $type, '*'); $hashtag_customer_name = '< customer_name >'; $hashtag_order_id = '< order_item_id >'; $hashtag_application_name = '< application_name >'; $string = isset($custom_notification) && !empty($custom_notification) ? json_encode( $custom_notification[0]->message, JSON_UNESCAPED_UNICODE, ) : ''; $hashtag = html_entity_decode($string); $data = str_replace( [ $hashtag_customer_name, $hashtag_order_id, $hashtag_application_name, ], [$order_detls[0]->uname, $order_detls[0]->id, $app_name], $hashtag, ); $message = outputEscaping(trim($data, '"')); $customer_msg = !empty($custom_notification) ? $message : 'Hello Dear ' . $order_detls[0]->uname . ' Order status updated to' . $order_status . ' for order ID #' . $order_detls[0]->id . ' please take note of it! Thank you. Regards ' . $app_name . ''; $seller_msg = !empty($custom_notification) ? $message : 'Hello Dear ' . $seller_data[0]->username . ' Order status updated to' . $order_status . ' for order ID #' . $order_detls[0]->id . ' please take note of it! Thank you. Regards ' . $app_name . ''; $fcmMsg = [ 'title' => !empty($custom_notification) ? $custom_notification[0]->title : 'Order status updated', 'body' => $customer_msg, 'type' => 'order', 'store_id' => "$store_id", ]; $seller_fcmMsg = [ 'title' => !empty($custom_notification) ? $custom_notification[0]->title : 'Order status updated', 'body' => $seller_msg, 'type' => 'order', 'store_id' => "$store_id", ]; $user_res = fetchDetails( 'users', ['id' => $order_detls[0]->user_id], 'fcm_id', ); $fcm_ids = $seller_fcm_ids = []; //send notification to customer if (!empty($user_res[0]->fcm_id)) { $fcm_ids[0][] = $user_res[0]->fcm_id; sendNotification('', $fcm_ids, $fcmMsg); } //send notification to seller if (!empty($seller_data[0]->fcm_id)) { $seller_fcm_ids[0][] = $seller_data[0]->fcm_id; sendNotification('', $seller_fcm_ids, $seller_fcmMsg); } } } @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 = getShipmentId( $item['id'], $order_detls[0]->id, ); @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', ]; 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') }}
{{ $item['pname'] }}
{{ 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 }}
@if ( $shipping_method['shiprocket_shipping_method'] == 1 && isset($pickup_location[$j]) && !empty($pickup_location[$j]) && $pickup_location[$j] != 'NULL')
@if ($items[0]['product_type'] != 'digital_product' && empty($order_tracking_data[0]['shipment_id'])) @endif
{{ labels('admin_labels.pickup_location', 'Pickup Location') }} :

{{ $pickup_location[$j] }}

@if (isset($items[0]['product_type']) && $items[0]['product_type'] != 'digital_product') @if ($shipping_method['shiprocket_shipping_method'] == 1) @endif @endif
@php $isShipmentCreated = !empty($shiprocket_order) && isset($shiprocket_order['data']) && !empty($shiprocket_order['data']) && isset($order_tracking_data[0]['shipment_id']) && !empty($order_tracking_data[0]['shipment_id']) && $order_tracking_data[0]['is_canceled'] != 1 && $shiprocket_order['data']['status'] != 'CANCELED'; @endphp @if ($isShipmentCreated)
Order created
@endif @php $isProductTypeNotDigital = isset($items[0]['product_type']) && $items[0]['product_type'] != 'digital_product'; $isShipmentIdEmpty = empty($order_tracking_data[0]['shipment_id']); @endphp @if ($isProductTypeNotDigital && $isShipmentIdEmpty)
Order not created
@endif @php $isOrderCancelled = (!empty($shiprocket_order) && isset($shiprocket_order['data']) && !empty($shiprocket_order['data']) && (isset($order_tracking_data[0]['is_canceled']) && $order_tracking_data[0]['is_canceled'] != 0)) || (isset($shiprocket_order['data']) && $shiprocket_order['data']['status'] == 'CANCELED'); @endphp @if ($isOrderCancelled)
Order cancelled
@endif
@if (isset($order_tracking_data[0]) && isset($order_tracking_data[0]['shipment_id']) && $order_tracking_data[0]['shipment_id'] != 0) @if (isset($order_tracking_data[0]['shipment_id']) && (empty($order_tracking_data[0]['awb_code']) || $order_tracking_data[0]['awb_code'] == 'NULL') && isset($shiprocket_order['data']) && $shiprocket_order['data']['status'] != 'CANCELED') @else @if ( !empty($shiprocket_order) && empty($order_tracking_data[0]['pickup_scheduled_date']) && ($shiprocket_order['data']['status_code'] != 4 || $shiprocket_order['data']['status'] != 'PICKUP SCHEDULED') && $shiprocket_order['data']['status'] != 'CANCELED' && $shiprocket_order['data']['status'] != 'CANCELLATION REQUESTED') @endif @if (isset($order_tracking_data[0]['is_canceled']) && $order_tracking_data[0]['is_canceled'] == 0) @endif @if (isset($order_tracking_data[0]['label_url']) && !empty($order_tracking_data[0]['label_url'])) Label @else @endif @if (isset($order_tracking_data[0]['invoice_url']) && !empty($order_tracking_data[0]['invoice_url'])) Invoice @else @endif @if (isset($order_tracking_data[0]['awb_code']) && !empty($order_tracking_data[0]['awb_code'])) @endif @endif @endif
@endif @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') }}: {{ $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 $isPublicDisk = $row1->disk == 'public' ? 1 : 0; $imagePath = $isPublicDisk ? getImageUrl($row1->attachments) : $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') }} {{ formateCurrency(formatePriceDecimal($item_subtotal)) }}
{{ labels('admin_labels.delivery_charges', 'Shipping Charges') }} {{ formateCurrency(formatePriceDecimal($items[0]['seller_delivery_charge'])) }}
{{ labels('admin_labels.wallet_balance', 'Wallet Balance') }} {{ formateCurrency(formatePriceDecimal($items[0]['wallet_balance'])) }}
{{ labels('admin_labels.discount_amount', 'Discount Amount') }} {{ formateCurrency(formatePriceDecimal($items[0]['seller_promo_discount'])) }}

@php $total = $item_subtotal + (float) ('' . $order_detls[0]->delivery_charge) - $order_detls[0]->promo_discount - $items[0]['wallet_balance']; @endphp {{ labels('admin_labels.total_amount', 'Total Amount') }}
{{ formateCurrency(formatePriceDecimal($total)) }}
@endsection