prepare('SELECT ti.*, p.productcode, p.name FROM transactions t JOIN transactions_items ti ON ti.txn_id = t.txn_id LEFT JOIN products p ON p.id = ti.item_id WHERE t.id = ?'); $stmt->execute([ $_GET['id'] ]); $order_items = $stmt->fetchAll(PDO::FETCH_ASSOC); // Retrieve order details $stmt = $pdo->prepare('SELECT a.email, a.id AS a_id, a.first_name AS a_first_name, a.last_name AS a_last_name, a.address_street AS a_address_street, a.address_city AS a_address_city, a.address_state AS a_address_state, a.address_zip AS a_address_zip, a.address_country AS a_address_country, a.address_phone AS a_address_phone, t.* FROM transactions t LEFT JOIN transactions_items ti ON ti.txn_id = t.txn_id LEFT JOIN accounts a ON a.id = t.account_id WHERE t.id = ?'); $stmt->execute([ $_GET['id'] ]); $order = $stmt->fetch(PDO::FETCH_ASSOC); // Get tax $stmt = $pdo->prepare('SELECT * FROM taxes WHERE country = ?'); $stmt->execute([$order['a_address_country']]); $tax = $stmt->fetch(PDO::FETCH_ASSOC); $tax_rate = $tax ? $tax['rate'] : 0.00; //Add giftcards if (isset($_GET['add_giftcard'])){ createGiftCart($pdo, $order['txn_id']); } //Get connected giftcards $giftcards_template = $order['txn_id'].'#%#%'; $stmt = $pdo->prepare('SELECT * from discounts WHERE discount_code like ?'); $stmt->execute([$giftcards_template]); $giftcards = $stmt->fetchAll(PDO::FETCH_ASSOC); // Get the current date $current_date = strtotime((new DateTime())->format('Y-m-d H:i:s')); // Delete transaction if (isset($_GET['delete'])) { // Delete the transaction $stmt = $pdo->prepare('DELETE t, ti FROM transactions t LEFT JOIN transactions_items ti ON ti.txn_id = t.txn_id WHERE t.id = ?'); $stmt->execute([ $_GET['id'] ]); // Deactive giftcards removeGiftCart($pdo, $_GET['txn']); header('Location: index.php?page=orders&success_msg=3'); exit; } if (!$order) { exit('Invalid ID!'); } ?> =template_admin_header('Orders', 'orders')?>
=$order['id']?>
=$order['txn_id']?>
=$order['shipping_method'] ? htmlspecialchars($order['shipping_method'], ENT_QUOTES) : '--'?>
=$order['payment_method']?>
=$order['payment_status']?>
=date('F j, Y H:ia', strtotime($order['created']))?>
=htmlspecialchars($order['discount_code'], ENT_QUOTES)?>
=htmlspecialchars($order['a_first_name'], ENT_QUOTES)?> =htmlspecialchars($order['a_last_name'], ENT_QUOTES)?>
=htmlspecialchars($order['a_address_street'], ENT_QUOTES)?>
=htmlspecialchars($order['a_address_city'], ENT_QUOTES)?>
=htmlspecialchars($order['a_address_state'], ENT_QUOTES)?>
=htmlspecialchars($order['a_address_zip'], ENT_QUOTES)?>
=htmlspecialchars($order['a_address_country'], ENT_QUOTES)?>
=htmlspecialchars($order['a_address_phone'], ENT_QUOTES)?>
The order is not associated with an account.
=htmlspecialchars($order['payer_email'], ENT_QUOTES)?>
=htmlspecialchars($order['first_name'], ENT_QUOTES)?> =htmlspecialchars($order['last_name'], ENT_QUOTES)?>
=htmlspecialchars($order['address_street'], ENT_QUOTES)?>
=htmlspecialchars($order['address_city'], ENT_QUOTES)?>
=htmlspecialchars($order['address_state'], ENT_QUOTES)?>
=htmlspecialchars($order['address_zip'], ENT_QUOTES)?>
=htmlspecialchars($order['address_country'], ENT_QUOTES)?>
=htmlspecialchars($order['a_address_phone'], ENT_QUOTES)?>
| Product | Options | Qty | Price | Total |
| There are no order items | ||||
| =$item['productcode']?> =$item['name'] ? htmlspecialchars($item['name'], ENT_QUOTES) : '(Product ' . $item['item_id'] . ')'?> | =$item['item_options'] ? htmlspecialchars(str_replace(',', ', ', $item['item_options']), ENT_QUOTES) : '--'?> | =$item['item_quantity']?> | =currency_code?>=number_format($item['item_price'], 2)?> | =currency_code?>=number_format($item['item_price']*$item['item_quantity'], 2)?> |
| Subtotal | =currency_code?>=number_format($subtotal, 2)?> | |||
| Shipping | =currency_code?>=number_format($order['shipping_amount'], 2)?> | |||
| Discount | =currency_code?>=number_format(($order['payment_amount']+$order['shipping_amount'])-($subtotal), 2)?> | |||
| VAT | =currency_code?>=number_format($order['tax_amount'], 2)?> | |||
| Total | =currency_code?>=number_format($order['payment_amount'], 2)?> | |||
| 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'?> | =currency_code?>=number_format($giftcard['discount_value'], 2)?> | ||