예제 #1
0
 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);
 }
예제 #2
0
 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;
 }
예제 #3
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);
 }
예제 #4
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>';
 }