'.$button_back.'':''; //Check if allowed if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){ header('location: index.php'); exit; } //GET PARAMETERS && STORE in SESSION for FURTHER USE/NAVIGATION $pagination_page = $_SESSION['p'] = isset($_GET['p']) ? $_GET['p'] : 1; //PAGE Security $page_manage = 'order_manage'; $update_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'U'); $update_allowed_edit = isAllowed($page_manage ,$_SESSION['profile'],$_SESSION['permission'],'U'); $delete_allowed = isAllowed($page_manage ,$_SESSION['profile'],$_SESSION['permission'],'D'); $create_allowed = isAllowed($page_manage ,$_SESSION['profile'],$_SESSION['permission'],'C'); //GET Details from URL $_GET['list'] = 'order'; $GET_VALUES = urlGETdetails($_GET) ?? ''; //CALL TO API $api_url = '/v2/transactions/'.$GET_VALUES; $order = ioServer($api_url,''); //Decode Payload if (!empty($order)){$order = json_decode($order,true);}else{$order = null;} // Handle success messages if (isset($_GET['success_msg'])) { if ($_GET['success_msg'] == 1) { $success_msg = $message_order_1 ?? 'Created'; } if ($_GET['success_msg'] == 2) { $success_msg = $message_order_2 ?? 'Updated'; } if ($_GET['success_msg'] == 3) { $success_msg = $message_order_3 ?? 'Deleted' ; } } template_header('order', 'order', 'view'); $view = '

'.$order['header']['id'].' - '.$order['header']['txn_id'].'

'.$button_cancel.' '; //------------------------------------ // //------------------------------------ if ($update_allowed_edit === 1){ $view .= 'Edit'; } $view .= '
'; if (isset($success_msg)){ $view .= '

'.$success_msg.'

'; } $view .= '
'; $view .='
Order Details

Order ID

' . $order['header']['id'] . '

Transaction ID

' . $order['header']['txn_id'] . '

'; if ($order['header']['shipping_method']) { $view .='

Shipping Method

' . htmlspecialchars($order['header']['shipping_method'], ENT_QUOTES) . '

'; } //Translate status INT to STR $payment_status = 'payment_status_'.$order['header']['payment_status']; $payment_method = 'payment_method_'.$order['header']['payment_method']; $view .='

Payment Method

' . (${$payment_method} ?? $order['header']['payment_method'] ). '

Payment Status

' . (${$payment_status} ?? $order['header']['payment_status'] ). '

Date

'.getRelativeTime($order['header']['created']). '

'; if ($order['header']['discount_code']) { $view .='

Discount Code

' . htmlspecialchars($order['header']['discount_code'], ENT_QUOTES) . '

'; } $view .='
'; // Account Details Block $view .='
Account Details
'; if ($order['customer']['email']) { $view .='

Name

' . htmlspecialchars($order['customer']['name'], ENT_QUOTES) . '

Address

' . htmlspecialchars($order['customer']['street'], ENT_QUOTES) . '
' . htmlspecialchars($order['customer']['city'], ENT_QUOTES) . '
' . htmlspecialchars($order['customer']['state'], ENT_QUOTES) . '
' . htmlspecialchars($order['customer']['zip'], ENT_QUOTES) . '
' . htmlspecialchars($order['customer']['country'], ENT_QUOTES) . '

Contact

' . htmlspecialchars($order['customer']['phone'], ENT_QUOTES) . '

'; } else { $view .='

The order is not associated with an account.

'; } $view .='
'; // Customer Details Block $view .='
Customer Details

Email

' . htmlspecialchars($order['customer']['email'], ENT_QUOTES) . '

Name

' . htmlspecialchars($order['customer']['name'], ENT_QUOTES) . '

Address

' . htmlspecialchars($order['customer']['street'], ENT_QUOTES) . '
' . htmlspecialchars($order['customer']['city'], ENT_QUOTES) . '
' . htmlspecialchars($order['customer']['state'], ENT_QUOTES) . '
' . htmlspecialchars($order['customer']['zip'], ENT_QUOTES) . '
' . htmlspecialchars($order['customer']['country'], ENT_QUOTES) . '

Contact

' . htmlspecialchars($order['customer']['phone'], ENT_QUOTES) . '

'; // Order Items Table $view .='
Order
'; if (empty($order)) { $view .=' '; } else { foreach ($order['products'] as $item) { $view .=' '; } } $view .='
Product Options Qty Price Total
There are no order items
' . ($item['product_name'] ? htmlspecialchars(${$item['product_name']} ?? $item['product_name'] , ENT_QUOTES) : '(Product ' . $item['item_id'] . ')') . ' ' . ($item['options'] ? htmlspecialchars(implode(", ", $item['options']), ENT_QUOTES) : '--') . ' ' . $item['quantity'] . ' ' . number_format($item['price'], 2) . ' ' . number_format($item['line_total'], 2) . '
Subtotal ' . number_format($order['pricing']['subtotal'], 2) . '
Shipping ' . number_format($order['pricing']['shipping_total'], 2) . '
Discount ' . number_format($order['pricing']['discount_total'], 2) . '
VAT ' . number_format($order['pricing']['tax_total'], 2) . '
Total ' . number_format($order['pricing']['payment_amount'], 2) . '
'; // Giftcards Block $view .='
Giftcards
Relate giftcards '; if (empty($giftcards)) { $view .=' '; } else { foreach ($giftcards as $giftcard) { $view .=' '; } } $view .='
Giftcard Valid Value
There are no order items
' . $giftcard['discount_code'] . ' ' . ($current_date >= strtotime($giftcard['start_date']) && $current_date <= strtotime($giftcard['end_date']) ? 'Yes' : 'No') . ' ' . number_format($giftcard['discount_value'], 2) . '
'; // Invoice Block $view .='
Invoice
'; $view .='
'; //OUTPUT echo $view; template_footer() ?>