getConnection(); $data = json_decode(file_get_contents("php://input")); $shipping = array( "full_name" => $data->profile->first_name." ".$data->profile->last_name, "address" => $data->profile->address, "city" => $data->profile->city, "zip_code" => $data->profile->zip_code, "province" => $data->profile->province ); $query = "INSERT INTO `orders` (`id`, `uid`, `date`, `items`, `total`, `status`, `token`, `shipping`, `traking`) VALUES (NULL, ".intval($data->uid).", NOW(), '".json_encode($data->cart)."', ".floatval($data->total).", '".($data->paid ? 'PAID' : 'CREATED')."', '".trim($data->token)."', '".json_encode($shipping)."', '')"; $stmt = $conn->prepare($query); if($stmt->execute()) { $toEmail = $data->profile->email; $toName = $data->profile->first_name." ".$data->profile->last_name; $subject = 'Ordine n. '.$conn->lastInsertId(); $body = emailHeader(); $body .= '