Example #1
0
 public function displayAccountsPage()
 {
     // handle actions and show notes
     $this->handleActions();
     if ($this->requestAction() == 'save_account') {
         $this->saveAccount();
     }
     if ($this->requestAction() == 'edit_account') {
         return $this->displayEditAccountsPage();
     }
     if ($default_account_id = get_option('wplister_default_account_id')) {
         $default_account = WPLE_eBayAccount::getAccount($default_account_id);
         if (!$default_account) {
             $this->showMessage(__('Your default account does not exist anymore. Please select a new default account.', 'wplister'), 1);
         } else {
             // make sure the eBay token stored in wp_options matches the default account
             $ebay_token_v1 = get_option('wplister_ebay_token');
             if ($ebay_token_v1 != $default_account->token) {
                 // update_option( 'wplister_ebay_token', $default_account->token );
                 $this->makeDefaultAccount($default_account->id);
                 // update everything, including expiration time
                 $this->showMessage(__('A new eBay token was found and your default account has been updated accordingly.', 'wplister'), 2);
             }
         }
     }
     // refresh enabled sites automatically for now
     $this->fixEnabledSites();
     // check for data linked to deleted accounts
     WPL_Setup::checkDbForInvalidAccounts();
     // create table and fetch items to show
     $this->accountsTable = new WPLE_AccountsTable();
     $this->accountsTable->prepare_items();
     $form_action = 'admin.php?page=' . self::ParentMenuId . '-settings' . '&tab=accounts';
     if (@$_REQUEST['page'] == 'wplister-settings-accounts') {
         $form_action = 'admin.php?page=wplister-settings-accounts';
     }
     $active_tab = 'accounts';
     $aData = array('plugin_url' => self::$PLUGIN_URL, 'message' => $this->message, 'accountsTable' => $this->accountsTable, 'ebay_accounts' => WPLE_eBayAccount::getAll(true), 'ebay_sites' => EbayController::getEbaySites(), 'active_ebay_sites' => WPLE_eBaySite::getAll(), 'default_account' => get_option('wplister_default_account_id'), 'settings_url' => 'admin.php?page=' . self::ParentMenuId . '-settings', 'auth_url' => $form_action . '&action=wplRedirectToAuthURL', 'form_action' => $form_action);
     $this->display('settings_accounts', $aData);
 }
Example #2
0
 function checkPermissions()
 {
     $role = get_role('administrator');
     // check if admin has manage_ebay_options capability
     if (!isset($role->capabilities['manage_ebay_options'])) {
         $Setup = new WPL_Setup();
         $Setup->updatePermissions();
     }
 }
Example #3
0
	
							<label for="wpl-paypal_email" class="text_label">
								<?php 
echo __('PayPal Account', 'wplister');
?>
                                <?php 
wplister_tooltip('To use PayPal you need to enter your PayPal address.');
?>
							</label>
							<input type="text" name="wplister_paypal_email" id="wpl-paypal_email" value="<?php 
echo $wpl_account->paypal_email;
?>
" class="text_input" />
	
			                <?php 
if (WPL_Setup::isV2()) {
    ?>
							<label for="wpl-oosc_mode" class="text_label">
								<?php 
    echo __('Out Of Stock Control', 'wplister');
    ?>
                                <?php 
    wplister_tooltip('This option has to be enabled in your eBay account preferences on eBay directly. Please refresh your account details in WP-Lister when you have changed the setting on eBay.');
    ?>
							</label>
							<select id="wpl-oosc_mode" name="wplister_oosc_mode" class=" required-entry select" disabled >
								<option value="1" <?php 
    if ($wpl_account->oosc_mode == 1) {
        echo 'selected';
    }
    ?>
Example #4
0
 function check_wplister_setup($page = false)
 {
     $Setup = new WPL_Setup();
     $Setup->checkSetup($page);
 }
Example #5
0
 public function handleActions()
 {
     // check action
     if (isset($_REQUEST['action'])) {
         // check_ebay_connection
         if ($_REQUEST['action'] == 'check_ebay_connection') {
             $msg = $this->checkEbayConnection();
             // $this->showMessage( $msg );
             return;
         }
         // custom debug code
         if ($_REQUEST['action'] == 'wple_debug_1') {
             global $wpdb;
             $post_title = 'this string is 256 characters long - which is 1 too many........................................................................................................................................................................................................';
             // $post_title = 'TEST';
             $data = array();
             $data['auction_title'] = $post_title;
             $data['status'] = 'TEST';
             $table = $wpdb->prefix . 'ebay_auctions';
             $result = $wpdb->insert($table, $data);
             echo "<pre>result: ";
             print_r($result);
             echo "</pre>";
             #die();
             echo "<pre>length: ";
             print_r(strlen($post_title));
             echo "</pre>";
             #die();
             echo "<pre>insert_id: ";
             print_r($wpdb->insert_id);
             echo "</pre>";
             #die();
             echo "<pre>last query: ";
             print_r($wpdb->last_query);
             echo "</pre>";
             #die();
             return;
         }
         // check nonce
         if (check_admin_referer('e2e_tools_page')) {
             // check_ebay_time_offset
             if ($_REQUEST['action'] == 'check_ebay_time_offset') {
                 $this->checkEbayTimeOffset();
             }
             // view_logfile
             if ($_REQUEST['action'] == 'view_logfile') {
                 $this->viewLogfile();
             }
             // wplister_clear_log
             if ($_REQUEST['action'] == 'wplister_clear_log') {
                 $this->clearLogfile();
                 $this->showMessage('Log file was cleared.');
             }
             // check_wc_out_of_sync
             if ($_REQUEST['action'] == 'check_wc_out_of_sync') {
                 require_once WPLISTER_PATH . '/classes/core/WPL_InventoryCheck.php';
                 $ic = new WPL_InventoryCheck();
                 $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 'published';
                 $prices = isset($_REQUEST['prices']) ? $_REQUEST['prices'] : false;
                 $mark_as_changed = isset($_REQUEST['mark_as_changed']) ? $_REQUEST['mark_as_changed'] : false;
                 $step = isset($_REQUEST['step']) ? $_REQUEST['step'] : 0;
                 $batch_size = get_option('wplister_inventory_check_batch_size', 200);
                 // check new batch of items
                 $new_items_were_processed = $ic->checkProductInventory($mode, $prices, $step);
                 if ($new_items_were_processed) {
                     // continue with step+1
                     $msg = 'Checking inventory, please wait... ';
                     if ($mark_as_changed == 'yes') {
                         $msg = 'Updating listing status, please wait... ';
                     }
                     $msg .= '<img src="' . WPLISTER_URL . '/img/ajax-loader.gif" style="float:left; margin-right:1em; margin-top:0.3em;"/>';
                     $step++;
                     $msg .= '<br><small>Step ' . $step . ' / ' . $step * $batch_size . ' items checked </small>';
                     // build button, which is triggered by js automatically
                     $url = 'admin.php?page=wplister-tools&action=check_wc_out_of_sync&mode=' . $mode . '&prices=' . $prices . '&mark_as_changed=' . $mark_as_changed . '&step=' . $step . '&_wpnonce=' . wp_create_nonce('e2e_tools_page');
                     $msg .= '<a href="' . $url . '" id="wple_auto_next_step" class="button" style="display:none">Next</a>';
                     wple_show_message($msg);
                 } else {
                     // show results
                     $ic->showProductInventoryCheckResult($mode);
                     // clear tmp data
                     update_option('wple_inventory_check_queue_data', '', 'no');
                 }
             }
             // check_wc_out_of_sync
             // check_wc_out_of_stock
             if ($_REQUEST['action'] == 'check_wc_out_of_stock') {
                 require_once WPLISTER_PATH . '/classes/core/WPL_InventoryCheck.php';
                 $ic = new WPL_InventoryCheck();
                 $mark_as_changed = isset($_REQUEST['mark_as_changed']) ? $_REQUEST['mark_as_changed'] : false;
                 $step = isset($_REQUEST['step']) ? $_REQUEST['step'] : 0;
                 $batch_size = get_option('wplister_inventory_check_batch_size', 200);
                 // check new batch of items
                 $new_items_were_processed = $ic->checkProductStock($step);
                 if ($new_items_were_processed) {
                     // continue with step+1
                     $msg = 'Checking for out of stock products, please wait... ';
                     if ($mark_as_changed == 'yes') {
                         $msg = 'Updating listing status, please wait... ';
                     }
                     $msg .= '<img src="' . WPLISTER_URL . '/img/ajax-loader.gif" style="float:left; margin-right:1em; margin-top:0.3em;"/>';
                     $step++;
                     $msg .= '<br><small>Step ' . $step . ' / ' . $step * $batch_size . ' items checked </small>';
                     // build button, which is triggered by js automatically
                     $url = 'admin.php?page=wplister-tools&action=check_wc_out_of_stock&mark_as_changed=' . $mark_as_changed . '&step=' . $step . '&_wpnonce=' . wp_create_nonce('e2e_tools_page');
                     $msg .= '<a href="' . $url . '" id="wple_auto_next_step" class="button" style="display:none">Next</a>';
                     wple_show_message($msg);
                 } else {
                     // show results
                     $ic->showProductStockCheckResult();
                     // clear tmp data
                     update_option('wple_inventory_check_queue_data', '', 'no');
                 }
             }
             // check_wc_out_of_stock
             // check_wc_sold_stock
             if ($_REQUEST['action'] == 'check_wc_sold_stock') {
                 require_once WPLISTER_PATH . '/classes/core/WPL_InventoryCheck.php';
                 $ic = new WPL_InventoryCheck();
                 $ic->checkSoldStock();
             }
             // check_ebay_image_requirements
             if ($_REQUEST['action'] == 'check_ebay_image_requirements') {
                 $this->checkProductImages();
             }
             // check_missing_ebay_transactions
             if ($_REQUEST['action'] == 'check_missing_ebay_transactions') {
                 $this->checkTransactions(true);
             }
             // fix_cog_on_imported_orders
             if ($_REQUEST['action'] == 'fix_cog_on_imported_orders') {
                 $this->fixCostOfGoods();
             }
             // lock_all_listings
             if ($_REQUEST['action'] == 'lock_all_listings') {
                 $count = WPLE_ListingQueryHelper::lockAll(1);
                 $this->showMessage($count . ' ' . 'items were locked.');
             }
             // unlock_all_listings
             if ($_REQUEST['action'] == 'unlock_all_listings') {
                 $count = WPLE_ListingQueryHelper::lockAll(0);
                 $this->showMessage($count . ' ' . 'items were unlocked.');
             }
             // import_wpla_product_ids
             if ($_REQUEST['action'] == 'import_wpla_product_ids') {
                 $count = self::importWplaProductIds();
             }
             // assign_all_data_to_default_account
             if ($_REQUEST['action'] == 'assign_all_data_to_default_account') {
                 WPL_Setup::assignAllDataToDefaultAccount();
                 $this->showMessage(sprintf('All listings, orders and profiles have been assigned to your default account %s.', get_option('wplister_default_account_id')));
             }
             // GetTokenStatus
             if ($_REQUEST['action'] == 'GetTokenStatus') {
                 $this->initEC();
                 $expdate = $this->EC->GetTokenStatus();
                 $this->EC->closeEbay();
                 $msg = __('Your token will expire on', 'wplister') . ' ' . $expdate;
                 $msg .= ' (' . human_time_diff(strtotime($expdate)) . ' from now)';
                 $this->showMessage($msg);
             }
             // GetUser
             if ($_REQUEST['action'] == 'GetUser') {
                 $this->initEC();
                 $UserID = $this->EC->GetUser();
                 $this->EC->GetUserPreferences();
                 $this->EC->closeEbay();
                 $this->showMessage(__('Your UserID is', 'wplister') . ' ' . $UserID);
             }
             // GetNotificationPreferences
             if ($_REQUEST['action'] == 'GetNotificationPreferences') {
                 $this->initEC();
                 $debug = $this->EC->GetNotificationPreferences();
                 $this->EC->closeEbay();
                 wple_show_message('<pre>' . print_r($debug, 1) . '</pre>');
             }
             // EnableUserNotificationPreferences
             if ($_REQUEST['action'] == 'EnableUserNotificationPreferences') {
                 $this->initEC();
                 $debug = $this->EC->SetUserNotificationPreferences('Enable');
                 $this->EC->closeEbay();
                 wple_show_message('<pre>' . print_r($debug, 1) . '</pre>');
             }
             // DisableUserNotificationPreferences
             if ($_REQUEST['action'] == 'DisableUserNotificationPreferences') {
                 $this->initEC();
                 $debug = $this->EC->SetUserNotificationPreferences('Disable');
                 $this->EC->closeEbay();
                 wple_show_message('<pre>' . print_r($debug, 1) . '</pre>');
             }
             // ResetNotificationPreferences
             if ($_REQUEST['action'] == 'ResetNotificationPreferences') {
                 $this->initEC();
                 $debug = $this->EC->ResetNotificationPreferences();
                 $this->EC->closeEbay();
                 wple_show_message('<pre>' . print_r($debug, 1) . '</pre>');
             }
             // GetNotificationsUsage
             if ($_REQUEST['action'] == 'GetNotificationsUsage') {
                 $this->initEC();
                 $debug = $this->EC->GetNotificationsUsage();
                 $this->EC->closeEbay();
                 wple_show_message('<pre>' . print_r($debug, 1) . '</pre>');
             }
             // update_ebay_transactions
             if ($_REQUEST['action'] == 'update_ebay_transactions_30') {
                 $this->initEC();
                 $tm = $this->EC->loadTransactions(30);
                 $this->EC->updateListings();
                 $this->EC->closeEbay();
                 // show transaction report
                 $msg = $tm->count_total . ' ' . __('Transactions were loaded from eBay.', 'wplister') . '<br>';
                 $msg .= __('Timespan', 'wplister') . ': ' . $tm->getHtmlTimespan();
                 $msg .= '&nbsp;&nbsp;';
                 $msg .= '<a href="#" onclick="jQuery(\'#transaction_report\').toggle();return false;">' . __('show details', 'wplister') . '</a>';
                 $msg .= $tm->getHtmlReport();
                 $this->showMessage($msg);
             }
             // update_ebay_orders
             if ($_REQUEST['action'] == 'update_ebay_orders_30') {
                 $this->initEC();
                 $om = $this->EC->loadEbayOrders(30);
                 $this->EC->updateListings();
                 $this->EC->closeEbay();
                 // show report
                 $msg = $om->count_total . ' ' . __('Orders were loaded from eBay.', 'wplister') . '<br>';
                 $msg .= __('Timespan', 'wplister') . ': ' . $om->getHtmlTimespan();
                 $msg .= '&nbsp;&nbsp;';
                 $msg .= '<a href="#" onclick="jQuery(\'.ebay_order_report\').toggle();return false;">' . __('show details', 'wplister') . '</a>';
                 $msg .= $om->getHtmlReport();
                 $this->showMessage($msg);
             }
             // wple_upgrade_tables_to_utf8mb4
             if ($_REQUEST['action'] == 'wple_upgrade_tables_to_utf8mb4') {
                 $this->upgradeTablesUTF8MB4();
             }
             // wple_run_daily_schedule
             if ($_REQUEST['action'] == 'wple_run_daily_schedule') {
                 do_action('wple_daily_schedule');
             }
             // wple_run_update_schedule
             if ($_REQUEST['action'] == 'wple_run_update_schedule') {
                 do_action('wplister_update_auctions');
             }
         } else {
             die('not allowed');
         }
     }
     // if $_REQUEST['action']
 }
Example #6
0
						<h3 class="hndle"><span><?php 
    echo __('Accounts', 'wplister');
    ?>
</span></h3>
						<div class="inside">

						</div>
					</div>

				<?php 
}
// $wpl_ebay_accounts
?>

				<?php 
if (WPL_Setup::isV2() || sizeof($wpl_ebay_accounts) == 0) {
    ?>
					<?php 
    $max_accounts = apply_filters('wple_max_number_of_accounts', 12);
    if (sizeof($wpl_ebay_accounts) < $max_accounts) {
        require_once 'account/settings_add_account.php';
    }
    ?>
				<?php 
}
?>

				</div> <!-- .meta-box-sortables -->
			</div> <!-- #postbox-container-1 -->

Example #7
0
 public static function upgradeDB()
 {
     global $wpdb;
     $db_version = get_option('wplister_db_version', 0);
     $hide_message = $db_version == 0 ? true : false;
     $msg = false;
     // initialize db with version 4
     if (4 > $db_version) {
         $new_db_version = 4;
         // create table: ebay_auctions
         $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ebay_auctions` (\n\t\t\t  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t  `ebay_id` bigint(255) DEFAULT NULL,\n\t\t\t  `auction_title` varchar(255) DEFAULT NULL,\n\t\t\t  `auction_type` varchar(255) DEFAULT NULL,\n\t\t\t  `listing_duration` varchar(255) DEFAULT NULL,\n\t\t\t  `date_created` datetime DEFAULT NULL,\n\t\t\t  `date_published` datetime DEFAULT NULL,\n\t\t\t  `date_finished` datetime DEFAULT NULL,\n\t\t\t  `end_date` datetime DEFAULT NULL,\n\t\t\t  `price` float DEFAULT NULL,\n\t\t\t  `quantity` int(11) DEFAULT NULL,\n\t\t\t  `quantity_sold` int(11) DEFAULT NULL,\n\t\t\t  `status` varchar(50) DEFAULT NULL,\n\t\t\t  `details` text,\n\t\t\t  `ViewItemURL` varchar(255) DEFAULT NULL,\n\t\t\t  `GalleryURL` varchar(255) DEFAULT NULL,\n\t\t\t  `post_content` text,\n\t\t\t  `post_id` int(11) DEFAULT NULL,\n\t\t\t  `profile_id` int(11) DEFAULT NULL,\n\t\t\t  `profile_data` text,\n\t\t\t  `template` varchar(255) DEFAULT '',\n\t\t\t  `fees` float DEFAULT NULL,\n\t\t\t  PRIMARY KEY  (`id`)\n\t\t\t);";
         #dbDelta($sql);
         $wpdb->query($sql);
         echo $wpdb->last_error;
         // create table: ebay_categories
         $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ebay_categories` (\n\t\t\t  `cat_id` bigint(16) DEFAULT NULL,\n\t\t\t  `parent_cat_id` bigint(11) DEFAULT NULL,\n\t\t\t  `level` int(11) DEFAULT NULL,\n\t\t\t  `leaf` tinyint(4) DEFAULT NULL,\n\t\t\t  `version` int(11) DEFAULT NULL,\n\t\t\t  `cat_name` varchar(255) DEFAULT NULL,\n\t\t\t  `wp_term_id` int(11) DEFAULT NULL,\n\t\t\t  KEY `cat_id` (`cat_id`),\n\t\t\t  KEY `parent_cat_id` (`parent_cat_id`)\t\t\n\t\t\t);";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         // create table: ebay_store_categories
         $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ebay_store_categories` (\n\t\t\t  `cat_id` bigint(20) DEFAULT NULL,\n\t\t\t  `parent_cat_id` bigint(20) DEFAULT NULL,\n\t\t\t  `level` int(11) DEFAULT NULL,\n\t\t\t  `leaf` tinyint(4) DEFAULT NULL,\n\t\t\t  `version` int(11) DEFAULT NULL,\n\t\t\t  `cat_name` varchar(255) DEFAULT NULL,\n\t\t\t  `order` int(11) DEFAULT NULL,\n\t\t\t  `wp_term_id` int(11) DEFAULT NULL,\n\t\t\t  KEY `cat_id` (`cat_id`),\n\t\t\t  KEY `parent_cat_id` (`parent_cat_id`)\t\t\n\t\t\t);";
         $wpdb->query($sql);
         // create table: ebay_payment
         $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ebay_payment` (\n\t\t\t  `payment_name` varchar(255) DEFAULT NULL,\n\t\t\t  `payment_description` varchar(255) DEFAULT NULL,\n\t\t\t  `version` int(11) DEFAULT NULL\t\n\t\t\t);";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         // create table: ebay_profiles
         $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ebay_profiles` (\n\t\t\t  `profile_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t  `profile_name` varchar(255) DEFAULT NULL,\n\t\t\t  `profile_description` varchar(255) DEFAULT NULL,\n\t\t\t  `listing_duration` varchar(255) DEFAULT NULL,\n\t\t\t  `type` varchar(255) DEFAULT NULL,\n\t\t\t  `details` text,\n\t\t\t  `conditions` text,\n\t\t\t  PRIMARY KEY  (`profile_id`)\t\n\t\t\t);";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         // create table: ebay_shipping
         $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ebay_shipping` (\n\t\t\t  `service_id` int(11) DEFAULT NULL,\n\t\t\t  `service_name` varchar(255) DEFAULT NULL,\n\t\t\t  `service_description` varchar(255) DEFAULT NULL,\n\t\t\t  `carrier` varchar(255) DEFAULT NULL,\n\t\t\t  `international` tinyint(4) DEFAULT NULL,\n\t\t\t  `version` int(11) DEFAULT NULL\t\n\t\t\t);";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         // create table: ebay_transactions
         $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ebay_transactions` (\n\t\t\t  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t  `item_id` bigint(255) DEFAULT NULL,\n\t\t\t  `transaction_id` bigint(255) DEFAULT NULL,\n\t\t\t  `date_created` datetime DEFAULT NULL,\n\t\t\t  `item_title` varchar(255) DEFAULT NULL,\n\t\t\t  `price` float DEFAULT NULL,\n\t\t\t  `quantity` int(11) DEFAULT NULL,\n\t\t\t  `status` varchar(50) DEFAULT NULL,\n\t\t\t  `details` text,\n\t\t\t  `post_id` int(11) DEFAULT NULL,\n\t\t\t  `buyer_userid` varchar(255) DEFAULT NULL,\n\t\t\t  `buyer_name` varchar(255) DEFAULT NULL,\n\t\t\t  `buyer_email` varchar(255) DEFAULT NULL,\n\t\t\t  `eBayPaymentStatus` varchar(50) DEFAULT NULL,\n\t\t\t  `CheckoutStatus` varchar(50) DEFAULT NULL,\n\t\t\t  `ShippingService` varchar(50) DEFAULT NULL,\n\t\t\t  `PaymentMethod` varchar(50) DEFAULT NULL,\n\t\t\t  `ShippingAddress_City` varchar(50) DEFAULT NULL,\n\t\t\t  `CompleteStatus` varchar(50) DEFAULT NULL,\n\t\t\t  `LastTimeModified` datetime DEFAULT NULL,\n\t\t\t  PRIMARY KEY (`id`)\n\t  \t\t);";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         // create table: ebay_log
         $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ebay_log` (\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t  `timestamp` datetime DEFAULT NULL,\n\t\t\t  `request_url` text DEFAULT NULL,\n\t\t\t  `request` text DEFAULT NULL,\n\t\t\t  `response` text DEFAULT NULL,\n\t\t\t  `callname` varchar(64) DEFAULT NULL,\n\t\t\t  `success` varchar(16) DEFAULT NULL,\n\t\t\t  `ebay_id` bigint(255) DEFAULT NULL,\n\t\t\t  `user_id` int(11) DEFAULT NULL,\t\n\t\t\t  PRIMARY KEY (`id`)\t\n\t\t\t);";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         // $db_version = $new_db_version;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     /*
     // upgrade to version 2
     if ( 2 > $db_version ) {
     	$new_db_version = 2;
     
     	// create table: ebay_log
     	$sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ebay_log` (
     	  `id` int(11) NOT NULL AUTO_INCREMENT,
     	  `timestamp` datetime DEFAULT NULL,
     	  `request_url` text DEFAULT NULL,
     	  `request` text DEFAULT NULL,
     	  `response` text DEFAULT NULL,
     	  `callname` varchar(64) DEFAULT NULL,
     	  `success` varchar(16) DEFAULT NULL,
     	  `ebay_id` bigint(255) DEFAULT NULL,
     	  `user_id` int(11) DEFAULT NULL,	
     	  PRIMARY KEY (`id`)	
     	);";
     	$wpdb->query($sql);	echo $wpdb->last_error;
     
     	update_option('wplister_db_version', $new_db_version);
     	$msg  = __('Database was upgraded to version', 'wplister') .' '. $new_db_version . '.';
     }
     
     // upgrade to version 3
     if ( 3 > $db_version ) {
     	$new_db_version = 3;
     
     	// rename column in table: ebay_categories
     	$sql = "ALTER TABLE `{$wpdb->prefix}ebay_categories`
     	        CHANGE wpsc_category_id wp_term_id INTEGER ";
     	$wpdb->query($sql);	echo $wpdb->last_error;
     
     	// rename column in table: ebay_store_categories
     	$sql = "ALTER TABLE `{$wpdb->prefix}ebay_store_categories`
     	        CHANGE wpsc_category_id wp_term_id INTEGER ";
     	$wpdb->query($sql);	echo $wpdb->last_error;
     	
     	update_option('wplister_db_version', $new_db_version);
     	$msg  = __('Database was upgraded to version', 'wplister') .' '. $new_db_version . '.';
     }
     
     // upgrade to version 4
     if ( 4 > $db_version ) {
     	$new_db_version = 4;
     
     	// set column type to bigint in table: ebay_store_categories
     	$sql = "ALTER TABLE `{$wpdb->prefix}ebay_store_categories`
     	        CHANGE cat_id cat_id BIGINT ";
     	$wpdb->query($sql);	echo $wpdb->last_error;
     	
     	// set column type to bigint in table: ebay_store_categories
     	$sql = "ALTER TABLE `{$wpdb->prefix}ebay_store_categories`
     	        CHANGE parent_cat_id parent_cat_id BIGINT ";
     	$wpdb->query($sql);	echo $wpdb->last_error;
     	
     	update_option('wplister_db_version', $new_db_version);
     	$msg  = __('Database was upgraded to version', 'wplister') .' '. $new_db_version . '.';
     }
     */
     // TODO: include upgrade 5-9 in WPLister_Install class
     // upgrade to version 5
     if (5 > $db_version) {
         $new_db_version = 5;
         // create table: ebay_log
         $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ebay_jobs` (\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t  `job_key` varchar(64) DEFAULT NULL,\n\t\t\t  `job_name` varchar(64) DEFAULT NULL,\n\t\t\t  `tasklist` text DEFAULT NULL,\n\t\t\t  `results` text DEFAULT NULL,\n\t\t\t  `success` varchar(16) DEFAULT NULL,\n\t\t\t  `date_created` datetime DEFAULT NULL,\n\t\t\t  `date_finished` datetime DEFAULT NULL,\n\t\t\t  `user_id` int(11) DEFAULT NULL,\t\n\t\t\t  PRIMARY KEY (`id`)\t\n\t\t\t);";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 6
     if (6 > $db_version) {
         $new_db_version = 6;
         // add columns to ebay_shipping table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_shipping`\n\t\t\t        ADD COLUMN `ShippingCategory` varchar(64) DEFAULT NULL AFTER `carrier`, \n\t\t\t        ADD COLUMN `WeightRequired` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `international`, \n\t\t\t        ADD COLUMN `DimensionsRequired` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `international`, \n\t\t\t        ADD COLUMN `isCalculated` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `international`, \n\t\t\t        ADD COLUMN `isFlat` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `international`;\n\t\t\t";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 7  (0.9.7.9)
     if (7 > $db_version) {
         $new_db_version = 7;
         // set admin_email as default license_email
         update_option('wplister_license_email', get_bloginfo('admin_email'));
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 8
     if (8 > $db_version) {
         $new_db_version = 8;
         // add columns to ebay_shipping table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_profiles`\n\t\t\t        ADD COLUMN `category_specifics` text DEFAULT NULL;\n\t\t\t";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 9  (1.0)
     if (9 > $db_version) {
         $new_db_version = 9;
         // add update channel option
         update_option('wplister_update_channel', 'stable');
         update_option('wple_update_channel', 'stable');
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 10  (1.0.7)
     if (10 > $db_version) {
         $new_db_version = 10;
         // add column to ebay_transactions table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_transactions`\n\t\t\t        ADD COLUMN `wp_order_id` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `post_id`\n\t\t\t";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 11  (1.0.8.8)
     if (11 > $db_version) {
         $new_db_version = 11;
         // fetch available dispatch times - disabled in 2.0.3
         // if ( get_option('wplister_ebay_token') != '' ) {
         // 	$this->initEC();
         // 	$result = $this->EC->loadDispatchTimes();
         // 	$this->EC->closeEbay();
         // }
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 12  (1.0.9.8)
     if (12 > $db_version) {
         $new_db_version = 12;
         // fetch all transactions
         $sql = "SELECT id FROM `{$wpdb->prefix}ebay_transactions` ";
         $items = $wpdb->get_results($sql);
         echo $wpdb->last_error;
         // find and assign orders
         $tm = new TransactionsModel();
         foreach ($items as $transaction) {
             // fetch item details
             $item = $tm->getItem($transaction->id);
             $details = $item['details'];
             // build order title (WooCommerce only)
             $post_title = 'Order &ndash; ' . date('F j, Y @ h:i A', strtotime($details->CreatedDate));
             // find created order
             $sql = "\n\t\t\t\t\tSELECT ID FROM `{$wpdb->prefix}posts`\n\t\t\t\t\tWHERE post_title = '{$post_title}'\n\t\t\t\t\t  AND post_status = 'publish'\n\t\t\t\t";
             $post_id = $wpdb->get_var($sql);
             echo $wpdb->last_error;
             // set order_id for transaction
             $tm->updateWpOrderID($transaction->id, $post_id);
             // Update post data
             update_post_meta($post_id, '_transaction_id', $transaction->id);
             update_post_meta($post_id, '_ebay_item_id', $item['item_id']);
             update_post_meta($post_id, '_ebay_transaction_id', $item['transaction_id']);
         }
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 13  (1.1.0.2)
     if (13 > $db_version) {
         $new_db_version = 13;
         // add column to ebay_transactions table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_transactions`\n\t\t\t        ADD COLUMN `OrderLineItemID` varchar(64) DEFAULT NULL AFTER `transaction_id`\n\t\t\t";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 14  (1.1.0.4)
     if (14 > $db_version) {
         $new_db_version = 14;
         // remove invalid transactions - update on next cron schedule
         $sql = "DELETE FROM `{$wpdb->prefix}ebay_transactions`\n\t\t\t        WHERE transaction_id = 0\n\t\t\t";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 15  (1.1.5.4)
     if (15 > $db_version) {
         $new_db_version = 15;
         // add column to ebay_categories table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_categories`\n\t\t\t        ADD COLUMN `site_id` int(10) UNSIGNED DEFAULT NULL AFTER `wp_term_id`\n\t\t\t";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 16  (1.1.6.3)
     if (16 > $db_version) {
         $new_db_version = 16;
         // add column to ebay_auctions table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_auctions`\n\t\t\t        ADD COLUMN `history` TEXT AFTER `fees`\n\t\t\t";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 17  (1.2.0.12)
     if (17 > $db_version) {
         $new_db_version = 17;
         // fetch available shipping packages - disabled in 2.0.3
         // if ( get_option('wplister_ebay_token') != '' ) {
         // 	$this->initEC();
         // 	$result = $this->EC->loadShippingPackages();
         // 	$this->EC->closeEbay();
         // }
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 18 (1.2.0.18)
     if (18 > $db_version) {
         $new_db_version = 18;
         // set column type to bigint in table: ebay_auctions
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_auctions`\n\t\t\t        CHANGE post_id post_id BIGINT ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         // set column type to bigint in table: ebay_transactions
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_transactions`\n\t\t\t        CHANGE post_id post_id BIGINT ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         // set column type to bigint in table: ebay_transactions
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_transactions`\n\t\t\t        CHANGE wp_order_id wp_order_id BIGINT ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 19  (1.2.1.5)
     if (19 > $db_version) {
         $new_db_version = 19;
         // add column to ebay_auctions table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_auctions`\n\t\t\t        ADD COLUMN `eps` TEXT AFTER `history`\n\t\t\t";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 20  (1.2.2.16)
     if (20 > $db_version) {
         $new_db_version = 20;
         // add column to ebay_transactions table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_transactions`\n\t\t\t        ADD COLUMN `history` TEXT AFTER `details`\n\t\t\t";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 21  (1.2.2.16)
     if (21 > $db_version) {
         $new_db_version = 21;
         // create table: ebay_orders
         $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ebay_orders` (\n\t\t\t  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t  `order_id` varchar(128) DEFAULT NULL,\n\t\t\t  `date_created` datetime DEFAULT NULL,\n\t\t\t  `total` float DEFAULT NULL,\n\t\t\t  `status` varchar(50) DEFAULT NULL,\n\t\t\t  `post_id` int(11) DEFAULT NULL,\n\t\t\t  `items` text,\n\t\t\t  `details` text,\n\t\t\t  `history` text,\n\t\t\t  `buyer_userid` varchar(255) DEFAULT NULL,\n\t\t\t  `buyer_name` varchar(255) DEFAULT NULL,\n\t\t\t  `buyer_email` varchar(255) DEFAULT NULL,\n\t\t\t  `eBayPaymentStatus` varchar(50) DEFAULT NULL,\n\t\t\t  `CheckoutStatus` varchar(50) DEFAULT NULL,\n\t\t\t  `ShippingService` varchar(50) DEFAULT NULL,\n\t\t\t  `PaymentMethod` varchar(50) DEFAULT NULL,\n\t\t\t  `ShippingAddress_City` varchar(50) DEFAULT NULL,\n\t\t\t  `CompleteStatus` varchar(50) DEFAULT NULL,\n\t\t\t  `LastTimeModified` datetime DEFAULT NULL,\n\t\t\t  PRIMARY KEY (`id`)\n\t  \t\t);";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 22  (1.2.4.7)
     if (22 > $db_version) {
         $new_db_version = 22;
         // add column to ebay_profiles table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_profiles`\n\t\t\t        ADD COLUMN `sort_order` int(11) NOT NULL AFTER `type`\n\t\t\t";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 23  (1.2.7.3)
     if (23 > $db_version) {
         $new_db_version = 23;
         // fetch user defined shipping discount profiles - disabled in 2.0.3
         // if ( get_option('wplister_ebay_token') != '' ) {
         // 	$this->initEC();
         // 	$result = $this->EC->loadShippingDiscountProfiles();
         // 	$this->EC->closeEbay();
         // }
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 24  (1.3.0.12)
     if (24 > $db_version) {
         $new_db_version = 24;
         // add column to ebay_profiles table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_auctions`\n\t\t\t        ADD COLUMN `locked` int(11) NOT NULL DEFAULT 0 AFTER `status`\n\t\t\t";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 25  (1.3.0.12)
     if (25 > $db_version) {
         $new_db_version = 25;
         $batch_size = 1000;
         // fetch all imported items
         $sql = "SELECT post_id FROM `{$wpdb->prefix}postmeta` WHERE meta_key = '_ebay_item_source' AND meta_value = 'imported' ";
         $imported_products = $wpdb->get_col($sql);
         echo $wpdb->last_error;
         $total_number_of_products = sizeof($imported_products);
         if ($total_number_of_products > $batch_size) {
             // legacy code removed in 2.0.3
         } else {
             // normal mode - lock all at once
             // lock all imported imported_products
             $where_sql = " 1 = 0 ";
             foreach ($imported_products as $post_id) {
                 $where_sql .= " OR post_id = '{$post_id}' ";
             }
             $sql = "UPDATE `{$wpdb->prefix}ebay_auctions` SET locked = '1' WHERE ( {$where_sql} ) AND status = 'published' ";
             $wpdb->query($sql);
             echo $wpdb->last_error;
             update_option('wplister_db_version', $new_db_version);
             $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
         }
     }
     // upgrade to version 26 (1.3.0.12)
     if (26 > $db_version) {
         $new_db_version = 26;
         // set column type to mediumtext in table: ebay_auctions
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_auctions`\n\t\t\t        CHANGE history history MEDIUMTEXT ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         // set column type to mediumtext in table: ebay_orders
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_orders`\n\t\t\t        CHANGE history history MEDIUMTEXT ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         // set column type to mediumtext in table: ebay_transactions
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_transactions`\n\t\t\t        CHANGE history history MEDIUMTEXT ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 27  (1.3.2.5)
     if (27 > $db_version) {
         $new_db_version = 27;
         // add columns to ebay_categories table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_categories`\n\t\t\t        ADD COLUMN `specifics` text AFTER `cat_name`,\n\t\t\t        ADD COLUMN `conditions` text AFTER `cat_name`\n\t\t\t";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         // add columns to ebay_auctions table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_auctions`\n\t\t\t        ADD COLUMN `parent_id` bigint(20) NOT NULL AFTER `post_id`,\n\t\t\t        ADD COLUMN `variations` text AFTER `details`\n\t\t\t";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 28  (1.3.2.10)
     if (28 > $db_version) {
         $new_db_version = 28;
         // create table: ebay_messages
         $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ebay_messages` (\n\t\t\t  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t  `message_id` varchar(128) DEFAULT NULL,\n\t\t\t  `received_date` datetime DEFAULT NULL,\n\t\t\t  `subject` varchar(255) DEFAULT NULL,\n\t\t\t  `sender` varchar(255) DEFAULT NULL,\n\t\t\t  `flag_read` varchar(1) DEFAULT NULL,\n\t\t\t  `flag_replied` varchar(1) DEFAULT NULL,\n\t\t\t  `flag_flagged` varchar(1) DEFAULT NULL,\n\t\t\t  `item_title` varchar(255) DEFAULT NULL,\n\t\t\t  `item_id` bigint(255) DEFAULT NULL,\n\t\t\t  `folder_id` bigint(255) DEFAULT NULL,\n\t\t\t  `msg_text` text,\n\t\t\t  `msg_content` text,\n\t\t\t  `details` text,\n\t\t\t  `expiration_date` datetime DEFAULT NULL,\n\t\t\t  `response_url` varchar(255) DEFAULT NULL,\n\t\t\t  `status` varchar(50) DEFAULT NULL,\n\t\t\t  PRIMARY KEY (`id`)\n\t  \t\t);";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 29  (1.3.2.12)
     if (29 > $db_version) {
         $new_db_version = 29;
         // add columns to ebay_auctions table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_auctions`\n\t\t\t        ADD COLUMN `relist_date` datetime DEFAULT NULL AFTER `end_date`\n\t\t\t";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 30  (1.3.4.5)
     if (30 > $db_version) {
         // automatically switch old sites from transaction to order mode
         update_option('wplister_ebay_update_mode', 'order');
         update_option('wplister_db_version', 30);
     }
     // upgrade to version 31  (1.3.5.4)
     if (31 > $db_version) {
         $new_db_version = 31;
         // add indices to ebay_log table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_log` ADD INDEX `timestamp` (`timestamp`) ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_log` ADD INDEX `callname` (`callname`) ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_log` ADD INDEX `success` (`success`) ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 32  (1.3.5.5)
     if (32 > $db_version) {
         $new_db_version = 32;
         // add column to ebay_transactions table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_transactions`\n\t\t\t        ADD COLUMN `order_id` varchar(64) DEFAULT NULL AFTER `transaction_id`\n\t\t\t";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         // add indices to ebay_transactions table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_transactions` ADD INDEX `item_id` (`item_id`) ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_transactions` ADD INDEX `transaction_id` (`transaction_id`) ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_transactions` ADD INDEX `order_id` (`order_id`) ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         // add index to ebay_orders table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_orders` ADD INDEX `order_id` (`order_id`) ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 33  (1.3.5.6)
     if (33 > $db_version) {
         $new_db_version = 33;
         if (WPL_Setup::isV2()) {
             // disable transaction conversion when updating from an ancient version (1.3.5)
             $more_orders_to_process = false;
         } else {
             $more_orders_to_process = isset(WPLE()->pages['tools']) ? WPLE()->pages['tools']->checkTransactions() : false;
         }
         // check if database upgrade is finished yet
         if ($more_orders_to_process) {
             $msg = __('Database upgrade is in progress', 'wplister') . '...';
             if ($msg && !$hide_message) {
                 wple_show_message($msg, 'info');
             }
             return;
         } else {
             update_option('wplister_db_version', $new_db_version);
             $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
         }
     }
     // upgrade to version 34  (1.3.5.7)
     if (34 > $db_version) {
         $new_db_version = 34;
         // fetch exclude shipping locations - disabled in 2.0.3
         // if ( get_option('wplister_ebay_token') != '' ) {
         // 	$this->initEC();
         //	$sm = new EbayShippingModel();
         //	$result = $sm->downloadExcludeShippingLocations( $this->EC->session );
         // 	$this->EC->closeEbay();
         // }
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 35  (1.5.0)
     if (35 > $db_version) {
         $new_db_version = 35;
         // change price column type to DECIMAL(13,2)
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_auctions`\n\t\t\t        CHANGE price price DECIMAL(13,2) ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_orders`\n\t\t\t        CHANGE total total DECIMAL(13,2) ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 36  (1.5.0)
     if (36 > $db_version) {
         $new_db_version = 36;
         // add indices to ebay_auctions table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_auctions` ADD INDEX `ebay_id` (`ebay_id`) ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_auctions` ADD INDEX `status` (`status`) ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_auctions` ADD INDEX `post_id` (`post_id`) ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_auctions` ADD INDEX `profile_id` (`profile_id`) ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_auctions` ADD INDEX `locked` (`locked`) ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_auctions` ADD INDEX `relist_date` (`relist_date`) ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 37  (1.5.2)
     if (37 > $db_version) {
         $new_db_version = 37;
         // create table: ebay_accounts
         $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ebay_accounts` (\n\t\t\t  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t  `title` varchar(128) NOT NULL,\n\t\t\t  `site_id` int(11) DEFAULT NULL,\n\t\t\t  `site_code` varchar(16) DEFAULT NULL,\n\t\t\t  `sandbox_mode` varchar(16) DEFAULT NULL,\n\t\t\t  `user_name` varchar(32) DEFAULT NULL,\n\t\t\t  `user_details` text NOT NULL,\n\t\t\t  `active` int(11) DEFAULT NULL,\n\t\t\t  `token` text NOT NULL,\n\t\t\t  `valid_until` datetime DEFAULT NULL,\n\t\t\t  `ebay_motors` int(11) DEFAULT NULL,\n\t\t\t  `seller_profiles` int(11) DEFAULT NULL,\n\t\t\t  `shipping_profiles` text NOT NULL,\n\t\t\t  `payment_profiles` text NOT NULL,\n\t\t\t  `return_profiles` text NOT NULL,\n\t\t\t  `categories_map_ebay` text NOT NULL,\n\t\t\t  `categories_map_store` text NOT NULL,\n\t\t\t  `default_ebay_category_id` bigint(20) DEFAULT NULL,\n\t\t\t  `paypal_email` varchar(64) DEFAULT NULL,\n\t\t\t  `sync_orders` int(11) DEFAULT NULL,\n\t\t\t  `sync_products` int(11) DEFAULT NULL,\n\t\t\t  `last_orders_sync` datetime DEFAULT NULL,\n\t\t\t  PRIMARY KEY  (`id`)\n\t\t\t) DEFAULT CHARSET=utf8 ;";
         $wpdb->query($sql);
         // add column to ebay_auctions table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_auctions`\n\t\t\t        ADD COLUMN `site_id` int(11) DEFAULT NULL AFTER `eps`,\n\t\t\t        ADD COLUMN `account_id` int(11) DEFAULT NULL AFTER `eps`\n\t\t\t";
         $wpdb->query($sql);
         // add column to ebay_log table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_log`\n\t\t\t        ADD COLUMN `site_id` int(11) DEFAULT NULL AFTER `user_id`,\n\t\t\t        ADD COLUMN `account_id` int(11) DEFAULT NULL AFTER `user_id`\n\t\t\t";
         $wpdb->query($sql);
         // add column to ebay_messages table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_messages`\n\t\t\t        ADD COLUMN `site_id` int(11) DEFAULT NULL AFTER `status`,\n\t\t\t        ADD COLUMN `account_id` int(11) DEFAULT NULL AFTER `status`\n\t\t\t";
         $wpdb->query($sql);
         // add column to ebay_orders table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_orders`\n\t\t\t        ADD COLUMN `site_id` int(11) DEFAULT NULL AFTER `LastTimeModified`,\n\t\t\t        ADD COLUMN `account_id` int(11) DEFAULT NULL AFTER `LastTimeModified`\n\t\t\t";
         $wpdb->query($sql);
         // add column to ebay_transactions table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_transactions`\n\t\t\t        ADD COLUMN `site_id` int(11) DEFAULT NULL AFTER `LastTimeModified`,\n\t\t\t        ADD COLUMN `account_id` int(11) DEFAULT NULL AFTER `LastTimeModified`\n\t\t\t";
         $wpdb->query($sql);
         // add column to ebay_payment table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_payment`\n\t\t\t        ADD COLUMN `site_id` int(11) DEFAULT NULL AFTER `version`\n\t\t\t";
         $wpdb->query($sql);
         // add column to ebay_shipping table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_shipping`\n\t\t\t        ADD COLUMN `site_id` int(11) DEFAULT NULL AFTER `version`\n\t\t\t";
         $wpdb->query($sql);
         // add column to ebay_profiles table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_profiles`\n\t\t\t        ADD COLUMN `site_id` int(11) DEFAULT NULL AFTER `category_specifics`,\n\t\t\t        ADD COLUMN `account_id` int(11) DEFAULT NULL AFTER `category_specifics`\n\t\t\t";
         $wpdb->query($sql);
         // add column to ebay_store_categories table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_store_categories`\n\t\t\t        ADD COLUMN `site_id` int(11) DEFAULT NULL AFTER `wp_term_id`,\n\t\t\t        ADD COLUMN `account_id` int(11) DEFAULT NULL AFTER `wp_term_id`\n\t\t\t";
         $wpdb->query($sql);
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 38  (1.5.2)
     if (38 > $db_version) {
         $new_db_version = 38;
         $token = get_option('wplister_ebay_token');
         $site_id = get_option('wplister_ebay_site_id');
         $accounts = WPLE_eBayAccount::getAll(true);
         $sites = EbayController::getEbaySites();
         // if there is a token but no accounts in table...
         if ($token && sizeof($accounts) == 0) {
             // migrate current account to new default account
             $default_account = new WPLE_eBayAccount();
             $default_account->title = 'Default';
             $default_account->active = '1';
             $default_account->site_id = $site_id;
             $default_account->site_code = $sites[$site_id];
             $default_account->token = $token;
             $default_account->user_name = get_option('wplister_ebay_token_userid');
             $default_account->sandbox_mode = get_option('wplister_sandbox_enabled');
             $default_account->valid_until = get_option('wplister_ebay_token_expirationtime');
             $default_account->ebay_motors = get_option('wplister_enable_ebay_motors');
             // deprecated
             $default_account->seller_profiles = get_option('wplister_ebay_seller_profiles_enabled') == 'yes' ? 1 : 0;
             $default_account->default_ebay_category_id = get_option('wplister_default_ebay_category_id');
             $default_account->paypal_email = get_option('wplister_paypal_email');
             $default_account->user_details = serialize(maybe_unserialize(get_option('wplister_ebay_user')));
             $default_account->categories_map_ebay = serialize(maybe_unserialize(get_option('wplister_categories_map_ebay')));
             $default_account->categories_map_store = serialize(maybe_unserialize(get_option('wplister_categories_map_store')));
             $default_account->add();
             // echo "<pre>";print_r($default_account);echo"</pre>";#die();
             // apply new account_id all over the site
             $default_account_id = $default_account->id;
             // update ebay_auctions table
             $sql = "UPDATE `{$wpdb->prefix}ebay_auctions` SET\n\t\t\t\t        `site_id`    = '{$site_id}',\n\t\t\t\t        `account_id` = '{$default_account_id}'  ";
             $wpdb->query($sql);
             // update ebay_log table
             $sql = "UPDATE `{$wpdb->prefix}ebay_log` SET\n\t\t\t\t        `site_id`    = '{$site_id}',\n\t\t\t\t        `account_id` = '{$default_account_id}'  ";
             $wpdb->query($sql);
             // update ebay_messages table
             $sql = "UPDATE `{$wpdb->prefix}ebay_messages` SET\n\t\t\t\t        `site_id`    = '{$site_id}',\n\t\t\t\t        `account_id` = '{$default_account_id}'  ";
             $wpdb->query($sql);
             // update ebay_orders table
             $sql = "UPDATE `{$wpdb->prefix}ebay_orders` SET\n\t\t\t\t        `site_id`    = '{$site_id}',\n\t\t\t\t        `account_id` = '{$default_account_id}'  ";
             $wpdb->query($sql);
             // update ebay_transactions table
             $sql = "UPDATE `{$wpdb->prefix}ebay_transactions` SET\n\t\t\t\t        `site_id`    = '{$site_id}',\n\t\t\t\t        `account_id` = '{$default_account_id}'  ";
             $wpdb->query($sql);
             // update ebay_profiles table
             $sql = "UPDATE `{$wpdb->prefix}ebay_profiles` SET\n\t\t\t\t        `site_id`    = '{$site_id}',\n\t\t\t\t        `account_id` = '{$default_account_id}'  ";
             $wpdb->query($sql);
             // update ebay_store_categories table
             $sql = "UPDATE `{$wpdb->prefix}ebay_store_categories` SET\n\t\t\t\t        `site_id`    = '{$site_id}',\n\t\t\t\t        `account_id` = '{$default_account_id}'  ";
             $wpdb->query($sql);
             // update ebay_payment table
             $sql = "UPDATE `{$wpdb->prefix}ebay_payment` SET\n\t\t\t\t        `site_id`    = '{$site_id}'  ";
             $wpdb->query($sql);
             // update ebay_shipping table
             $sql = "UPDATE `{$wpdb->prefix}ebay_shipping` SET\n\t\t\t\t        `site_id`    = '{$site_id}'  ";
             $wpdb->query($sql);
             update_option('wplister_default_account_id', $default_account_id);
             // make sure to reload accounts - which requires db version 38
             update_option('wplister_db_version', $new_db_version);
             WPLE()->loadAccounts();
         }
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 39  (1.6.0.6)
     if (39 > $db_version) {
         $new_db_version = 39;
         // add column to ebay_auctions table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_auctions`\n\t\t\t        ADD COLUMN `last_errors` TEXT AFTER `history`\n\t\t\t";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 40  (1.6.0.7)
     if (40 > $db_version) {
         $new_db_version = 40;
         // add column to ebay_orders table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_orders`\n\t\t\t        ADD COLUMN `currency` varchar(16) AFTER `total`\n\t\t\t";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 41  (1.6.0.10)
     if (41 > $db_version) {
         $new_db_version = 41;
         // create table: ebay_sites
         $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ebay_sites` (\n\t\t\t  `id` int(11) DEFAULT NULL,\n\t\t\t  `title` varchar(128) NOT NULL,\n\t\t\t  `code` varchar(16) DEFAULT NULL,\n\t\t\t  `url` varchar(64) DEFAULT NULL,\n\t\t\t  `enabled` int(11) DEFAULT NULL,\n\t\t\t  `sort_order` int(11) DEFAULT NULL,\n\t\t\t  `last_refresh` datetime DEFAULT NULL,\n\t\t\t  `categories_map_ebay` text NOT NULL,\n\t\t\t  `DispatchTimeMaxDetails` text NOT NULL,\n\t\t\t  `MinListingStartPrices` text NOT NULL,\n\t\t\t  `ReturnsWithinOptions` text NOT NULL,\n\t\t\t  `CountryDetails` text NOT NULL,\t\t  \n\t\t\t  `ShippingPackageDetails` text NOT NULL,\n\t\t\t  `ShippingCostPaidByOptions` text NOT NULL,\n\t\t\t  `ShippingLocationDetails` text NOT NULL,\n\t\t\t  `ExcludeShippingLocationDetails` text NOT NULL,\n\t\t\t  PRIMARY KEY  (`id`)\n\t\t\t) DEFAULT CHARSET=utf8 ;";
         $wpdb->query($sql);
         // build sites data
         $ebay_sites = EbayController::getEbaySites();
         $sort_order = 1;
         foreach ($ebay_sites as $site_id => $site_title) {
             $data = array('id' => $site_id, 'title' => $site_title, 'url' => EbayController::getDomainnameBySiteId($site_id), 'sort_order' => $sort_order);
             $wpdb->insert($wpdb->prefix . 'ebay_sites', $data);
             $sort_order++;
         }
         // enable site for each account
         foreach (WPLE()->accounts as $account) {
             $wpdb->update($wpdb->prefix . 'ebay_sites', array('enabled' => 1), array('id' => $account->site_id));
         }
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 42  (1.6.0.12 / 2.0.1)
     if (42 > $db_version) {
         $new_db_version = 42;
         // add columns to ebay_accounts table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_accounts`\n\t\t\t        ADD COLUMN `oosc_mode` int(11) AFTER `ebay_motors`,\n\t\t\t        ADD COLUMN `shipping_discount_profiles` text NOT NULL AFTER `return_profiles`\n\t\t\t";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         // refresh accounts
         WPLE()->loadAccounts();
         // if there is a valid default account, copy site specific data from wp_options to wp_ebay_sites
         $accounts = WPLE()->accounts;
         $default_account_id = get_option('wplister_default_account_id');
         $default_account = isset($accounts[$default_account_id]) ? $accounts[$default_account_id] : false;
         if ($default_account) {
             $data = array('categories_map_ebay' => serialize(maybe_unserialize(get_option('wplister_categories_map_ebay'))), 'DispatchTimeMaxDetails' => serialize(maybe_unserialize(get_option('wplister_DispatchTimeMaxDetails'))), 'MinListingStartPrices' => serialize(maybe_unserialize(get_option('wplister_MinListingStartPrices'))), 'ReturnsWithinOptions' => serialize(maybe_unserialize(get_option('wplister_ReturnsWithinOptions'))), 'CountryDetails' => serialize(maybe_unserialize(get_option('wplister_CountryDetails'))), 'ShippingPackageDetails' => serialize(maybe_unserialize(get_option('wplister_ShippingPackageDetails'))), 'ShippingCostPaidByOptions' => serialize(maybe_unserialize(get_option('wplister_ShippingCostPaidByOptions'))), 'ShippingLocationDetails' => serialize(maybe_unserialize(get_option('wplister_ShippingLocationDetails'))), 'ExcludeShippingLocationDetails' => serialize(maybe_unserialize(get_option('wplister_ExcludeShippingLocationDetails'))));
             $wpdb->update($wpdb->prefix . 'ebay_sites', $data, array('id' => $default_account->site_id));
         }
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 43  (2.0.8)
     if (43 > $db_version) {
         $new_db_version = 43;
         // add indices to ebay_auctions table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_auctions` ADD INDEX `parent_id` (`parent_id`) ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_auctions` ADD INDEX `site_id` (`site_id`) ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_auctions` ADD INDEX `account_id` (`account_id`) ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 44 (2.0.8.7)
     if (44 > $db_version) {
         $new_db_version = 44;
         // set column type to mediumtext in table: ebay_accounts
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_accounts`  CHANGE shipping_profiles shipping_profiles MEDIUMTEXT ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_accounts`  CHANGE payment_profiles  payment_profiles  MEDIUMTEXT ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_accounts`  CHANGE return_profiles   return_profiles   MEDIUMTEXT ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_accounts`  CHANGE shipping_discount_profiles shipping_discount_profiles MEDIUMTEXT ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_accounts`  CHANGE categories_map_ebay  categories_map_ebay  MEDIUMTEXT ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_accounts`  CHANGE categories_map_store categories_map_store MEDIUMTEXT ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 45  (2.0.9.5)
     if (45 > $db_version) {
         $new_db_version = 45;
         // add column to ebay_sites table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_sites`\n\t\t\t        ADD COLUMN `DoesNotApplyText` varchar(128) NOT NULL AFTER `ExcludeShippingLocationDetails`\n\t\t\t";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 46 (2.0.9.8.2)
     if (46 > $db_version) {
         $new_db_version = 46;
         // set column type to mediumtext in table: ebay_auctions
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_auctions`\n\t\t\t        CHANGE details details MEDIUMTEXT ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         // set column type to mediumtext in table: ebay_orders
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_orders`\n\t\t\t        CHANGE details details MEDIUMTEXT ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         // set column type to mediumtext in table: ebay_transactions
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_transactions`\n\t\t\t        CHANGE details details MEDIUMTEXT ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 47 (2.0.9.8.2)
     if (47 > $db_version) {
         $new_db_version = 47;
         // restructure categories table
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_categories`\n\t\t\t        CHANGE conditions features MEDIUMTEXT ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_categories`\n\t\t\t        CHANGE specifics specifics MEDIUMTEXT ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         $sql = "ALTER TABLE `{$wpdb->prefix}ebay_categories`\n\t\t\t        CHANGE wp_term_id last_updated datetime ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // upgrade to version 48 (2.0.9.8.2)
     if (48 > $db_version) {
         $new_db_version = 48;
         // remove legacy data
         $sql = "DELETE FROM `{$wpdb->prefix}postmeta` WHERE meta_key    =    '_ebay_category_specifics' ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         $sql = "DELETE FROM `{$wpdb->prefix}options`  WHERE option_name LIKE '_transient_wplister_ebay_item_conditions_%' ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         $sql = "DELETE FROM `{$wpdb->prefix}options`  WHERE option_name LIKE '_transient_timeout_wplister_ebay_item_conditions_%' ";
         $wpdb->query($sql);
         echo $wpdb->last_error;
         update_option('wplister_db_version', $new_db_version);
         $msg = __('Database was upgraded to version', 'wplister') . ' ' . $new_db_version . '.';
     }
     // show update message
     if ($msg && !$hide_message) {
         wple_show_message($msg, 'info');
     }
     #debug: update_option('wplister_db_version', 0);
 }