$_GET['activation_key'], "isverified" => 1), JSON_UNESCAPED_UNICODE); $verified = ioAPIv2('/v2/identity/',$payload,$clientsecret); $verified = json_decode($verified,true); if($verified['status'] == 'updated'){ //USER VERIFIED => LOGIN session_regenerate_id(); $_SESSION['account_loggedin'] = TRUE; $_SESSION['account_id'] = $verified['accountID']; $_SESSION['account_role'] = $account['profile']; $_SESSION['country_code'] = $account['language']; $products_in_cart = isset($_SESSION['cart']) ? $_SESSION['cart'] : []; if ($products_in_cart) { // user has products in cart, redirect them to the checkout page header('Location: ' . url('index.php?page=checkout')); } else { // Redirect the user back to the same page, they can then see their order history header('Location: ' . url('index.php?page=myaccount')); } exit; } else { $error = $error_myaccount; } } else { $error = $error_myaccount; } } // User clicked the "Login" button, proceed with the login process... check POST data and validate email if (isset($_POST['login'], $_POST['email'], $_POST['password']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { //+++++++++++++++++++++++++++++++++++++++++++++++++++++ // LOGIN CONSUMER //+++++++++++++++++++++++++++++++++++++++++++++++++++++ $payload = json_encode(array("login" => "consumer", "email" => $_POST['email'], "password" => $_POST['password']), JSON_UNESCAPED_UNICODE); $account = ioAPIv2('/v2/identity/',$payload,$clientsecret); $account= json_decode($account,true); if ($account && isset($account['accountID'])) { // User has logged in, create session data session_regenerate_id(); $_SESSION['account_loggedin'] = TRUE; $_SESSION['account_id'] = $account['accountID']; $_SESSION['account_role'] = $account['profile']; $_SESSION['country_code'] = $account['language']; $products_in_cart = isset($_SESSION['cart']) ? $_SESSION['cart'] : []; if ($products_in_cart) { //user has products in cart, redirect them to the checkout page header('Location: ' . url('index.php?page=checkout')); } else { //Redirect the user back to the same page, they can then see their order history header('Location: ' . url('index.php?page=myaccount')); } exit; } else { $error = $error_myaccount; } } // Variable that will output registration errors $register_error = ''; // User clicked the "Register" button, proceed with the registration process... check POST data and validate email if (isset($_POST['register'], $_POST['email'], $_POST['password'], $_POST['cpassword']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { // Check if the account exists $account = ioAPIv2('/v2/identity/email='.$_POST['email'],'',$clientsecret); $account = json_decode($account,true); if ($account) { // Account exists! $register_error = 'Account already exists'; ; } else if ($_POST['cpassword'] != $_POST['password']) { $register_error = 'Passwords do not match!'; } else if (strlen($_POST['password']) > 20 || strlen($_POST['password']) < 5) { // Password must be between 5 and 20 characters long. $register_error = 'Password must be between 5 and 20 characters long'; } else { // Account doesnt exist, create new account $payload = json_encode(array("email" => $_POST['email'], "password" => $_POST['password'], "language" => $_SESSION['country_code']), JSON_UNESCAPED_UNICODE); $account = ioAPIv2('/v2/identity/',$payload,$clientsecret); $account= json_decode($account,true); if ($account && isset($account['accountID'])) { //SEND VERIFICATION EMAIL include dirname(__FILE__).'/custom/email/email_template_register.php'; $register_mail = $message; send_mail_by_PHPMailer($account['identity'], $subject, $register_mail,'', ''); $register_error = 'Email send to verify your account'; } } } // Determine the current tab page $tab = (isset($_GET['activation_key']) && strlen($_GET['activation_key']) != 50 ) ? $_GET['activation_key'] : 'orders'; // If user is logged in if (isset($_SESSION['account_loggedin'])) { //CALL TO API $api_url = '/v2/transactions_items/account_id='.$_SESSION['account_id']; $orders = ioAPIv2($api_url,'',$clientsecret); //Decode Payload if (!empty($orders)){$orders = json_decode($orders,true);}else{$orders = null;} // Retrieve account details $api_url = '/v2/identity/userkey='.$_SESSION['account_id']; $identity = ioAPIv2($api_url,'',$clientsecret); //Decode Payload if (!empty($identity)){$identity = json_decode($identity,true);}else{$identity = null;} $identity = $identity[0]; // Update settings if (isset($_POST['save_details'], $_POST['email'], $_POST['password'])) { // Assign and validate input data $first_name = isset($_POST['first_name']) ? $_POST['first_name'] : ''; $last_name = isset($_POST['last_name']) ? $_POST['last_name'] : ''; $address_street = isset($_POST['address_street']) ? $_POST['address_street'] : ''; $address_city = isset($_POST['address_city']) ? $_POST['address_city'] : ''; $address_state = isset($_POST['address_state']) ? $_POST['address_state'] : ''; $address_zip = isset($_POST['address_zip']) ? $_POST['address_zip'] : ''; $address_country = isset($_POST['address_country']) ? $_POST['address_country'] : ''; $address_phone = isset($_POST['address_phone']) ? $_POST['address_phone'] : ''; // Check if account exists with captured email if ($_POST['email'] != $identity['email']) { // Check if the account exists $account = ioAPIv2('/v2/identity/email='.$_POST['email'],'',$clientsecret); $account = json_decode($account,true); if ($account) { // Account exists with change email $error = $error_myaccount_exists; } } elseif (strlen($_POST['password']) > 20 || strlen($_POST['password']) < 5) { // Password must be between 5 and 20 characters long. $error = $error_account_password_rules; } elseif (!$error){ //UPDATE DATA $payload = json_encode(array( "email" => $_POST['email'], "first_name" => $first_name, "last_name" => $last_name, "address_street" => $address_street, "address_city" => $address_city, "address_state" => $address_state, "address_zip" => $address_zip, "address_country" => $address_country, "address_phone" => $address_phone, "password" => $_POST['password'], "language" => $_SESSION['country_code'], "userkey" => $_SESSION['account_id']), JSON_UNESCAPED_UNICODE); $update_identity = ioAPIv2('/v2/identity/',$payload,$clientsecret); $update_identity = json_decode($update_identity,true); // Redirect to settings page header('Location: ' . url('index.php?page=myaccount&tab=settings')); exit; } } } $view = template_header($myaccount_text,''); $view .= ' '; if(!isset($_SESSION['account_loggedin'])){ $view .= '
'.$error.'
'; } $view .= ''.$register_error.'
'; } $view .= ''.$myorders_message.'
'; } foreach($orders as $order){ //Translate status INT to STR $payment_status = 'payment_status_'.$order['header']['payment_status']; $view .= '| ';
if(!empty($transaction_item['full_path'])){
$view .= ' |
'.$transaction_item['item_quantity'].' x '.(${$transaction_item['item_name']} ?? $transaction_item['item_name']).' | '.currency_code.''.number_format($transaction_item['item_price'] * $transaction_item['item_quantity'],2).' |