function insert_order_details_to_db($order_details = array('cat_item' => array('ID' => 0, 'orderID' => '', 'productID' => 0, 'price' => 0, 'quanlity' => 1, 'discount' => 0, 'subtotal' => 0))) { $orderID = get_order_id_with_session(); foreach ($order_details as $key => $cart_item) { $cart_item['orderID'] = $orderID; insert_cart_item_to_db($cart_item); } return true; }
function get_order_details_with_id($order_details = array('cat_item' => array('ID' => 0, 'orderID' => '', 'productID' => 0, 'price' => 0, 'quanlity' => 1, 'discount' => 0, 'subtotal' => 0))) { $orderdetails = array(); foreach ($order_details as $key => $cat_item) { $cat_item['orderID'] = get_order_id_with_session()->ID; $orderdetails[$key] = $cat_item; } return $orderdetails; }
$price = number_format($product_price, 0, ',', '.'); $cart = get_cart_in_session(); if (wp_verify_nonce($_POST['action_contact'], 'contact')) { global $wpdb; $errors = array(); $cart_tt = get_cart_in_session(); $ten = $_POST['fullname']; $dienthoai = $_POST['phone']; $diachi = $_POST['address']; $email = $_POST['khachemail']; $chitiet = $_POST['message']; $order = $wpdb->prefix . 'order'; $userID = $current_user->ID; if ($cart_tt) { if (insert_cart_to_db()) { $orderid = get_order_id_with_session(); gui_noi_dung_don_hang_admin($ten, $dienthoai, $diachi, $email, $chitiet, $orderid); gui_noi_dung_don_hang_khach($ten, $dienthoai, $diachi, $email, $chitiet, $orderid); $wpdb->get_results("UPDATE {$order} SET email='{$email}' WHERE ID='{$orderid}'"); //session_regenerate_id(); session_unset(); //echo '<script>alert("Đặt hàng thành công. Vui lòng kiểm tra email !");</script>'; ?> <script type="text/javascript"> function AAA() { location.href="<?php bloginfo('url'); ?> /success" }