public function onDisplayEbayMessagesPage() { $this->check_wplister_setup(); // handle update ALL from eBay action if ($this->requestAction() == 'update_messages') { $accounts = WPLE_eBayAccount::getAll(); $msg = ''; // loop each active account foreach ($accounts as $account) { $this->initEC($account->id); $mm = $this->EC->updateEbayMessages(); $this->EC->closeEbay(); // show ebay_message report $msg .= sprintf(__('%s message(s) found on eBay for account %s.', 'wplister'), $mm->count_total, $account->title) . '<br>'; $msg .= __('Timespan', 'wplister') . ': ' . $mm->getHtmlTimespan() . ' '; $msg .= '<a href="#" onclick="jQuery(\'#ebay_message_report\').toggle();return false;">' . __('show details', 'wplister') . '</a>'; $msg .= $mm->getHtmlReport(); $msg .= '<hr>'; } $this->showMessage($msg); } // handle update from eBay bulk action if ($this->requestAction() == 'update') { if (isset($_REQUEST['ebay_message'])) { // use account_id of first item (todo: group items by account) $mm = new EbayMessagesModel(); $message = $mm->getItem($_REQUEST['ebay_message'][0]); $account_id = $message['account_id']; $this->initEC($account_id); $mm = $this->EC->updateEbayMessages(false, $_REQUEST['ebay_message']); $this->EC->closeEbay(); // $this->showMessage( __('Selected messages were updated from eBay.','wplister') ); // show ebay_message report $msg = $mm->count_total . ' ' . __('messages were updated from eBay.', 'wplister') . '<!br>' . ' '; $msg .= '<a href="#" onclick="jQuery(\'#ebay_message_report\').toggle();return false;">' . __('show details', 'wplister') . '</a>'; $msg .= $mm->getHtmlReport(); $this->showMessage($msg); } else { $this->showMessage(__('You need to select at least one item from the list below in message to use bulk actions.', 'wplister'), 1); } } // handle delete action if ($this->requestAction() == 'delete') { if (isset($_REQUEST['ebay_message'])) { $mm = new EbayMessagesModel(); foreach ($_REQUEST['ebay_message'] as $id) { $mm->deleteItem($id); } $this->showMessage(__('Selected items were removed.', 'wplister')); } else { $this->showMessage(__('You need to select at least one item from the list below in message to use bulk actions.', 'wplister'), 1); } } //Create an instance of our package class... $messagesTable = new EbayMessagesTable(); //Fetch, prepare, sort, and filter our data... $messagesTable->prepare_items(); $aData = array('plugin_url' => self::$PLUGIN_URL, 'message' => $this->message, 'messagesTable' => $messagesTable, 'form_action' => 'admin.php?page=' . self::ParentMenuId . '-messages'); $this->display('messages_page', $aData); }
public function cron_update_auctions() { WPLE()->logger->info("WP-CRON: cron_update_auctions()"); // log cron run to db if (get_option('wplister_log_to_db') == '1') { $dblogger = new WPL_EbatNs_Logger(); $dblogger->updateLog(array('callname' => 'cron_job_triggered', 'request_url' => 'internal action hook', 'request' => maybe_serialize($_REQUEST), 'response' => 'last run: ' . human_time_diff(get_option('wplister_cron_last_run')), 'success' => 'Success')); } // check if this is a staging site if ($this->isStagingSite()) { WPLE()->logger->info("WP-CRON: staging site detected! terminating execution..."); self::updateOption('cron_auctions', ''); self::updateOption('create_orders', ''); return; } // check if update is already running if (!$this->checkLock()) { WPLE()->logger->error("WP-CRON: already running! terminating execution..."); return; } // get accounts $accounts = WPLE_eBayAccount::getAll(false, true); // sort by id if (!empty($accounts)) { // loop each active account $processed_accounts = array(); foreach ($accounts as $account) { // make sure we don't process the same account twice if (in_array($account->user_name, $processed_accounts)) { WPLE()->logger->info("skipping account {$account->id} - user name {$account->user_name} was already processed"); continue; } $this->initEC($account->id); $this->EC->updateEbayOrders(); $this->EC->updateListings(); // TODO: specify account $this->EC->updateEbayMessages(); $this->EC->closeEbay(); $processed_accounts[] = $account->user_name; } } else { // fallback to pre 1.5.2 behaviour $this->initEC(); $this->EC->updateEbayOrders(); // force new mode in 1.5.2 // decide if the old transactions update or the new orders update mode is to be used // $mode = get_option( 'wplister_ebay_update_mode', 'order' ); // if ( $mode == 'order' ) { // $this->EC->updateEbayOrders(); // new // } else { // $this->EC->loadTransactions(); // old // } // update ended items and process relist schedule $this->EC->updateListings(); $this->EC->closeEbay(); } // clean up $this->removeLock(); // store timestamp self::updateOption('cron_last_run', time()); WPLE()->logger->info("WP-CRON: cron_update_auctions() finished"); }
public function initEC($account_id = null, $site_id = null) { // make sure the database is up to date WPLE_UpgradeHelper::maybe_upgrade_db(); // init controller $this->EC = new EbayController(); // use current default account by default (WPL1) $ebay_site_id = self::getOption('ebay_site_id'); $sandbox_enabled = self::getOption('sandbox_enabled'); $ebay_token = self::getOption('ebay_token'); // set site_id dynamically during authentication // if ( isset( $_REQUEST['site_id'] ) && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'wplRedirectToAuthURL' ) { if (isset($_REQUEST['site_id']) && isset($_REQUEST['sandbox'])) { $ebay_site_id = $_REQUEST['site_id']; $sandbox_enabled = $_REQUEST['sandbox']; $ebay_token = ''; } // use specific account if provided in request or parameter if (!$account_id && isset($_REQUEST['account_id'])) { $account_id = $_REQUEST['account_id']; } if ($account_id) { // $account = new WPLE_eBayAccount( $account_id ); // not suitable to check if an account exists $account = WPLE_eBayAccount::getAccount($account_id); if ($account) { $ebay_site_id = $account->site_id; $sandbox_enabled = $account->sandbox_mode; $ebay_token = $account->token; } else { $msg = sprintf('<b>Warning: You are trying to use an account which does not exist in WP-Lister</b> (ID %s).', $account_id) . '<br>'; $msg .= 'This can happen when you delete an account from WP-Lister without removing all listings, profiles and orders first.' . '<br><br>'; $msg .= 'In order to solve this issue, please visit your account settings and follow the instructions to assign all listings, orders and profiles to your default account.'; wple_show_message($msg, 'warn'); } } else { $account_id = get_option('wplister_default_account_id'); } if ($site_id) { $ebay_site_id = $site_id; } $this->EC->initEbay($ebay_site_id, $sandbox_enabled, $ebay_token, $account_id); }
public function jobs_load_tasks() { // quit if no job name provided if (!isset($_REQUEST['job'])) { return false; } $jobname = $_REQUEST['job']; // check if an array of listing IDs was provided $listing_ids = isset($_REQUEST['listing_ids']) && is_array($_REQUEST['listing_ids']) ? $_REQUEST['listing_ids'] : false; if ($listing_ids) { $items = WPLE_ListingQueryHelper::getItemsByIdArray($listing_ids); } // handle job name switch ($jobname) { case 'updateEbayData': // call EbayController $site_id = isset($_REQUEST['site_id']) ? $_REQUEST['site_id'] : get_option('wplister_ebay_site_id'); $account_id = isset($_REQUEST['account_id']) ? $_REQUEST['account_id'] : get_option('wplister_default_account_id'); $this->initEC($account_id); $tasks = $this->EC->initCategoriesUpdate($site_id); $this->EC->closeEbay(); // update store categories for each account using this site_id $accounts = WPLE_eBayAccount::getAll(); foreach ($accounts as $account) { if ($site_id != $account->site_id) { continue; } // add task - load user specific details $tasks[] = array('task' => 'loadUserAccountDetails', 'displayName' => 'update eBay account details for ' . $account->title, 'account_id' => $account->id); // add task - load store categories $tasks[] = array('task' => 'loadStoreCategories', 'displayName' => 'update custom store categories for ' . $account->title, 'account_id' => $account->id); } // for each account // build response $response = new stdClass(); $response->tasklist = $tasks; $response->total_tasks = count($tasks); $response->error = ''; $response->success = true; // create new job $newJob = new stdClass(); $newJob->jobname = $jobname; $newJob->tasklist = $tasks; $job = new JobsModel($newJob); $response->job_key = $job->key; $this->returnJSON($response); exit; case 'verifyItems': $response = $this->_create_bulk_listing_job('verifyItem', $items, $jobname); $this->returnJSON($response); exit; case 'publishItems': $response = $this->_create_bulk_listing_job('publishItem', $items, $jobname); $this->returnJSON($response); exit; case 'reviseItems': $response = $this->_create_bulk_listing_job('reviseItem', $items, $jobname); $this->returnJSON($response); exit; case 'updateItems': $response = $this->_create_bulk_listing_job('updateItem', $items, $jobname); $this->returnJSON($response); exit; case 'endItems': $response = $this->_create_bulk_listing_job('endItem', $items, $jobname); $this->returnJSON($response); exit; case 'relistItems': $response = $this->_create_bulk_listing_job('relistItem', $items, $jobname); $this->returnJSON($response); exit; case 'verifyAllPreparedItems': // get prepared items $items = WPLE_ListingQueryHelper::getAllPrepared(); // create job from items and send response $response = $this->_create_bulk_listing_job('verifyItem', $items, $jobname); $this->returnJSON($response); exit; case 'publishAllVerifiedItems': // get verified items $items = WPLE_ListingQueryHelper::getAllVerified(); // create job from items and send response $response = $this->_create_bulk_listing_job('publishItem', $items, $jobname); $this->returnJSON($response); exit; case 'publishAllPreparedItems': // get prepared items $items = WPLE_ListingQueryHelper::getAllPrepared(); // create job from items and send response $response = $this->_create_bulk_listing_job('publishItem', $items, $jobname); $this->returnJSON($response); exit; case 'reviseAllChangedItems': // get changed items $items = WPLE_ListingQueryHelper::getAllChangedItemsToRevise(); // create job from items and send response $response = $this->_create_bulk_listing_job('reviseItem', $items, $jobname); $this->returnJSON($response); exit; case 'relistAllRestockedItems': // get restocked items $items = WPLE_ListingQueryHelper::getAllEndedItemsToRelist(); // create job from items and send response $response = $this->_create_bulk_listing_job('relistItem', $items, $jobname); $this->returnJSON($response); exit; case 'updateAllPublishedItems': // get published items $items = WPLE_ListingQueryHelper::getAllPublished(); // create job from items and send response $response = $this->_create_bulk_listing_job('updateItem', $items, $jobname); $this->returnJSON($response); exit; case 'updateAllRelistedItems': // get published items $items = WPLE_ListingQueryHelper::getAllRelisted(); // create job from items and send response $response = $this->_create_bulk_listing_job('updateItem', $items, $jobname); $this->returnJSON($response); exit; case 'runDelayedProfileApplication': // get items using given profile $profile_id = get_option('wple_job_reapply_profile_id'); if (!$profile_id) { return; } $items1 = WPLE_ListingQueryHelper::getAllPreparedWithProfile($profile_id); $items2 = WPLE_ListingQueryHelper::getAllVerifiedWithProfile($profile_id); $items3 = WPLE_ListingQueryHelper::getAllPublishedWithProfile($profile_id); $items = array_merge($items1, $items2, $items3); $total_items = sizeof($items); $batch_size = get_option('wplister_apply_profile_batch_size', 1000); $tasks = array(); // echo "<pre>profile_id: ";echo $profile_id;echo"</pre>"; // echo "<pre>total: ";echo $total_items;echo"</pre>";die(); for ($page = 0; $page < $total_items / $batch_size; $page++) { $from = $page * $batch_size + 1; $to = $page * $batch_size + $batch_size; $to = min($to, $total_items); // add task - load user specific details $tasks[] = array('task' => 'applyProfileDelayed', 'displayName' => 'Apply profile to items ' . $from . ' to ' . $to, 'profile_id' => $profile_id, 'offset' => $page * $batch_size, 'limit' => $batch_size); } // build response $response = new stdClass(); $response->tasklist = $tasks; $response->total_tasks = count($tasks); $response->error = ''; $response->success = true; // create new job $newJob = new stdClass(); $newJob->jobname = $jobname; $newJob->tasklist = $tasks; $job = new JobsModel($newJob); $response->job_key = $job->key; $this->returnJSON($response); exit; default: // echo "unknown job"; // break; } // exit(); }
protected function saveCategoriesSettings() { self::check_max_post_vars(); // TODO: check nonce if (isset($_POST['wpl_e2e_ebay_category_id']) && isset($_POST['submit'])) { $account_id = isset($_REQUEST['account_id']) ? $_REQUEST['account_id'] : get_option('wplister_default_account_id'); $site_id = WPLE()->accounts[$account_id]->site_id; if ($account_id) { $account = new WPLE_eBayAccount($account_id); $account->default_ebay_category_id = $this->getValueFromPost('default_ebay_category_id'); $account->categories_map_ebay = maybe_serialize($this->getValueFromPost('ebay_category_id')); $account->categories_map_store = maybe_serialize($this->getValueFromPost('store_category_id')); $account->update(); WPLE()->loadAccounts(); } // update current default account (legacy) if ($account_id == get_option('wplister_default_account_id')) { // save ebay categories mapping self::updateOption('categories_map_ebay', $this->getValueFromPost('ebay_category_id')); // save store categories mapping self::updateOption('categories_map_store', $this->getValueFromPost('store_category_id')); // save default ebay category self::updateOption('default_ebay_category_id', $this->getValueFromPost('default_ebay_category_id')); } $this->showMessage(__('Categories mapping updated.', 'wplister')); } }
protected function newAccount() { // call FetchToken $this->initEC(); $ebay_token = $this->EC->doFetchToken(false); $this->EC->closeEbay(); // check if we have a token if ($ebay_token) { // create new account $account = new WPLE_eBayAccount(); // $account->title = stripslashes( $_POST['wplister_account_title'] ); $account->title = 'My Account'; $account->site_id = $_REQUEST['site_id']; $account->site_code = EbayController::getEbaySiteCode($_REQUEST['site_id']); $account->sandbox_mode = $_REQUEST['sandbox']; $account->token = $ebay_token; $account->active = 1; $account->add(); // set enabled flag for site $site = WPLE_eBaySite::getSiteObj($account->site_id); $site->enabled = 1; $site->update(); // update user details $account->updateUserDetails(); // set default account automatically if (!get_option('wplister_default_account_id')) { update_option('wplister_default_account_id', $account->id); $this->makeDefaultAccount($account->id); } $this->check_wplister_setup('settings'); $this->showMessage(__('New account was added.', 'wplister') . ' ' . __('Please refresh account and site specific details now.', 'wplister')); } else { $this->showMessage("There was a problem fetching your token. Make sure you follow the instructions.", 1); } }
public function onDisplayEbayOrdersPage() { $this->check_wplister_setup(); // handle update ALL from eBay action if ($this->requestAction() == 'update_orders') { // regard update options $days = is_numeric($_REQUEST['wpl_number_of_days']) ? $_REQUEST['wpl_number_of_days'] : false; $accounts = WPLE_eBayAccount::getAll(false, true); // sort by id $msg = ''; // loop each active account $processed_accounts = array(); foreach ($accounts as $account) { // make sure we don't process the same account twice if (in_array($account->user_name, $processed_accounts)) { WPLE()->logger->info("skipping account {$account->id} - user name {$account->user_name} was already processed"); continue; } $this->initEC($account->id); $tm = $this->EC->updateEbayOrders($days); $this->EC->updateListings(); $this->EC->closeEbay(); $processed_accounts[] = $account->user_name; // show ebay_order report $msg .= sprintf(__('%s order(s) found on eBay for account %s.', 'wplister'), $tm->count_total, $account->title) . '<br>'; $msg .= __('Timespan', 'wplister') . ': ' . $tm->getHtmlTimespan() . ' '; $msg .= '<a href="#" onclick="jQuery(\'.ebay_order_report\').toggle();return false;">' . __('show details', 'wplister') . '</a>'; $msg .= $tm->getHtmlReport(); $msg .= '<hr>'; } $this->showMessage($msg); } // handle update from eBay action if ($this->requestAction() == 'update') { if (isset($_REQUEST['ebay_order'])) { // use account_id of first item (todo: group items by account) $om = new EbayOrdersModel(); $order = $om->getItem($_REQUEST['ebay_order'][0]); $account_id = $order['account_id']; $this->initEC($account_id); $tm = $this->EC->updateEbayOrders(false, $_REQUEST['ebay_order']); $this->EC->updateListings(); $this->EC->closeEbay(); // $this->showMessage( __('Selected orders were updated from eBay.','wplister') ); // show ebay_order report $msg = $tm->count_total . ' ' . __('orders were updated from eBay.', 'wplister') . '<!br>' . ' '; $msg .= '<a href="#" onclick="jQuery(\'.ebay_order_report\').toggle();return false;">' . __('show details', 'wplister') . '</a>'; $msg .= $tm->getHtmlReport(); $this->showMessage($msg); } else { $this->showMessage(__('You need to select at least one item from the list below in order to use bulk actions.', 'wplister'), 1); } } // handle wpl_delete_order action if ($this->requestAction() == 'wpl_delete_order') { if (isset($_REQUEST['ebay_order'])) { $tm = new EbayOrdersModel(); $ebay_orders = is_array($_REQUEST['ebay_order']) ? $_REQUEST['ebay_order'] : array($_REQUEST['ebay_order']); foreach ($ebay_orders as $id) { $tm->deleteItem($id); } $this->showMessage(__('Selected items were removed.', 'wplister')); } else { $this->showMessage(__('You need to select at least one item from the list below in order to use bulk actions.', 'wplister'), 1); } } // show warning if duplicate orders found $this->checkForDuplicates(); //Create an instance of our package class... $ordersTable = new EbayOrdersTable(); //Fetch, prepare, sort, and filter our data... $ordersTable->prepare_items(); // load eBay classes to decode details in table EbayController::loadEbayClasses(); $aData = array('plugin_url' => self::$PLUGIN_URL, 'message' => $this->message, 'ordersTable' => $ordersTable, 'preview_html' => isset($preview_html) ? $preview_html : '', 'form_action' => 'admin.php?page=' . self::ParentMenuId . '-orders'); $this->display('orders_page', $aData); }
public function previewListing($id) { // init model $ibm = new ItemBuilderModel(); $account_id = WPLE_ListingQueryHelper::getAccountID($id); $account = WPLE_eBayAccount::getAccount($account_id); $this->initEC($account_id); $item = $ibm->buildItem($id, $this->EC->session, false, true); // if ( ! $ibm->checkItem($item) ) return $ibm->result; $ibm->checkItem($item); // $preview_html = $ibm->getFinalHTML( $id, $item, true ); $preview_html = $item->Description; // echo $preview_html; // set condition name $item->ConditionName = $this->getConditionDisplayName($item->getConditionID()); $aData = array('item' => $item, 'site_id' => $account ? $account->site_id : false, 'check_result' => $ibm->result, 'preview_html' => $preview_html); header('Content-Type: text/html; charset=utf-8'); $this->display('listings_preview', $aData); exit; }
/** ************************************************************************ * REQUIRED! This is where you prepare your data for display. This method will * usually be used to query the database, sort and filter the data, and generally * get it ready to be displayed. At a minimum, we should set $this->items and * $this->set_pagination_args(), although the following properties and methods * are frequently interacted with here... * * @uses $this->_column_headers * @uses $this->items * @uses $this->get_columns() * @uses $this->get_sortable_columns() * @uses $this->get_pagenum() * @uses $this->set_pagination_args() **************************************************************************/ function prepare_items() { // process bulk actions $this->process_bulk_action(); // get pagination state $current_page = $this->get_pagenum(); $per_page = $this->get_items_per_page('accounts_per_page', 20); // define columns $this->_column_headers = $this->get_column_info(); // fetch accounts from model $accountsModel = new WPLE_eBayAccount(); $this->items = $accountsModel->getPageItems($current_page, $per_page); $total_items = $accountsModel->total_items; // register our pagination options & calculations. $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page))); }
echo __('WP-Lister is not linked to your eBay account yet.', 'wplister'); ?> </p> <?php } elseif (!$wpl_default_account) { ?> <p><?php echo __('You need to select a default account.', 'wplister'); ?> </p> <?php } else { ?> <p> <?php echo sprintf(__('Your default account is <b>%s</b>.', 'wplister'), WPLE_eBayAccount::getAccountTitle($wpl_default_account)); ?> </p> <p> <?php echo __('The default account will always be used by WP-Lister unless specified otherwise.', 'wplister'); ?> </p> <?php } ?> </div> </div>
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 – ' . 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); }
function wplister_woocommerce_custom_shop_order_columns($column) { global $post, $woocommerce; if ($column != 'wpl_order_src') { return; } // check if order was placed on eBay $ebay_order_id = get_post_meta($post->ID, '_ebay_order_id', true); if (!$ebay_order_id) { return; } // get order details $om = new EbayOrdersModel(); $order = $om->getOrderByOrderID($ebay_order_id); $account = $order ? WPLE_eBayAccount::getAccount($order['account_id']) : false; $tooltip = 'This order was placed on eBay.'; if ($account) { $tooltip .= '<br>(' . $account->title . ')'; } echo '<div>'; echo '<img src="' . WPLISTER_URL . 'img/ebay-42x16.png" style="width:32px;vertical-align:bottom;padding:0;" class="tips" data-tip="' . $tooltip . '" />'; // show shipping status - if _ebay_marked_as_shipped is set to yes if (get_post_meta($post->ID, '_ebay_marked_as_shipped', true)) { $date_shipped = get_post_meta($post->ID, '_date_shipped', true); $date_shipped = is_numeric($date_shipped) ? date('Y-m-d', $date_shipped) : $date_shipped; // convert timestamp to date - support for Shipment Tracking plugin echo '<img src="' . WPLISTER_URL . 'img/icon-success-32x32.png" style="width:12px;vertical-align:middle;padding:0;" class="tips" data-tip="This order was completed and marked as shipped on eBay on ' . $date_shipped . '" />'; } elseif (get_post_meta($post->ID, '_wple_debug_last_error', true)) { // if not marked as shipped but there is an error result, CompleteSale failed... echo '<img src="' . WPLISTER_URL . 'img/error.gif" style="vertical-align:middle;padding:0;" class="tips" data-tip="There was a problem completing this order on eBay!" />'; } echo '</div>'; }
public function doFetchToken($account_id = false) { // $account_id = $account_id ? $account_id : get_option('wplister_default_account_id'); // we can *not* fall back to the default account here, or adding a new account would overwrite the default account's token $SessionID = get_option('wplister_ebay_sessionid'); $token = $this->FetchToken($SessionID); if ($token) { if ($account_id) { $account = new WPLE_eBayAccount($account_id); $account->token = $token; $account->update(); } // check if setup wizard is still active if (get_option('wplister_setup_next_step') == 1) { // update legacy data update_option('wplister_ebay_token', $token); // move setup to step 2 update_option('wplister_setup_next_step', '2'); // remember when WP-Lister was connected to an eBay account for the first time update_option('ignore_orders_before_ts', time()); } // // obsolete - already called in fetchTokenForAccount() // update_option('wplister_ebay_token_is_invalid', false ); } return $token; }