Beispiel #1
0
 /** ************************************************************************
  * 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('profiles_per_page', 20);
     // define columns
     $this->_column_headers = $this->get_column_info();
     // fetch profiles from model
     $profilesModel = new ProfilesModel();
     $this->items = $profilesModel->getPageItems($current_page, $per_page);
     $total_items = $profilesModel->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)));
 }
Beispiel #2
0
    function extra_tablenav($which)
    {
        if ('top' != $which) {
            return;
        }
        $pm = new ProfilesModel();
        $wpl_profiles = $pm->getAll();
        $profile_id = isset($_REQUEST['profile_id']) ? $_REQUEST['profile_id'] : false;
        $account_id = isset($_REQUEST['account_id']) ? $_REQUEST['account_id'] : false;
        // echo "<pre>";print_r($wpl_profiles);echo"</pre>";die();
        ?>
        <div class="alignleft actions" style="">

            <select name="profile_id">
                <option value=""><?php 
        _e('All profiles', 'wplister');
        ?>
</option>
                <?php 
        foreach ($wpl_profiles as $profile) {
            ?>
                    <option value="<?php 
            echo $profile['profile_id'];
            ?>
"
                        <?php 
            if ($profile_id == $profile['profile_id']) {
                echo 'selected';
            }
            ?>
                        ><?php 
            echo $profile['profile_name'];
            ?>
</option>
                <?php 
        }
        ?>
            </select>            

            <?php 
        if (WPLE()->multi_account) {
            ?>

            <select name="account_id">
                <option value=""><?php 
            _e('All accounts', 'wplister');
            ?>
</option>
                <?php 
            foreach (WPLE()->accounts as $account) {
                ?>
                    <option value="<?php 
                echo $account->id;
                ?>
"
                        <?php 
                if ($account_id == $account->id) {
                    echo 'selected';
                }
                ?>
                        ><?php 
                echo $account->title;
                ?>
</option>
                <?php 
            }
            ?>
            </select>            

            <?php 
        }
        ?>

            <input type="submit" name="" id="post-query-submit" class="button" value="Filter">


            <!--
            <a class="btn_verify_all_prepared_items button wpl_job_button"
               title="<?php 
        echo __('Verify all prepared items with eBay and get listing fees.', 'wplister');
        ?>
"
                ><?php 
        echo __('Verify all prepared items', 'wplister');
        ?>
</a>
            -->

            <?php 
        #if ( current_user_can( 'publish_ebay_listings' ) ) :
        ?>
            <!--
            <a class="btn_publish_all_verified_items button wpl_job_button"
               title="<?php 
        echo __('Publish all verified items on eBay.', 'wplister');
        ?>
"
                ><?php 
        echo __('Publish all verified items', 'wplister');
        ?>
</a>
            -->
            <?php 
        #endif;
        ?>


        </div>
        <?php 
    }
Beispiel #3
0
 function wplister_prepare_listing($post_id, $profile_id)
 {
     // prepare product
     $listingsModel = new ListingsModel();
     $listingsModel->prepareProductForListing($post_id);
     if (!$profile_id) {
         return;
     }
     // get profile
     $profilesModel = new ProfilesModel();
     $profile = $profilesModel->getItem($profile_id);
     if (!$profile) {
         return;
     }
     $listingsModel->applyProfileToNewListings($profile);
 }
Beispiel #4
0
 public function jobs_run_task()
 {
     // quit if no job name provided
     if (!isset($_REQUEST['job'])) {
         return false;
     }
     if (!isset($_REQUEST['task'])) {
         return false;
     }
     $job = $_REQUEST['job'];
     $task = $_REQUEST['task'];
     $site_id = isset($task['site_id']) ? $task['site_id'] : false;
     $account_id = isset($task['account_id']) ? $task['account_id'] : false;
     // register shutdown handler
     global $wpl_shutdown_handler_enabled;
     $wpl_shutdown_handler_enabled = true;
     register_shutdown_function(array($this, 'shutdown_handler'));
     WPLE()->logger->info('running task: ' . print_r($task, 1));
     // handle job name
     switch ($task['task']) {
         case 'loadShippingServices':
             // call EbayController
             $this->initEC($account_id, $site_id);
             $result = $this->EC->loadShippingServices($site_id);
             $this->EC->closeEbay();
             // build response
             $response = new stdClass();
             $response->job = $job;
             $response->task = $task;
             $response->result = $result;
             $response->errors = array();
             $response->success = true;
             $this->returnJSON($response);
             exit;
         case 'loadPaymentOptions':
             // call EbayController
             $this->initEC($account_id, $site_id);
             $result = $this->EC->loadPaymentOptions($site_id);
             $this->EC->closeEbay();
             // build response
             $response = new stdClass();
             $response->job = $job;
             $response->task = $task;
             $response->result = $result;
             $response->errors = array();
             $response->success = true;
             $this->returnJSON($response);
             exit;
         case 'loadStoreCategories':
             // call EbayController
             $this->initEC($account_id);
             $result = $this->EC->loadStoreCategories($account_id);
             $this->EC->closeEbay();
             // build response
             $response = new stdClass();
             $response->job = $job;
             $response->task = $task;
             $response->result = $result;
             $response->errors = array();
             $response->success = true;
             $this->returnJSON($response);
             exit;
         case 'loadUserAccountDetails':
             // call EbayController
             $this->initEC($account_id);
             $result = $this->EC->loadUserAccountDetails();
             $this->EC->closeEbay();
             // update account (seller profiles etc.)
             $account = new WPLE_eBayAccount($account_id);
             if ($account) {
                 $account->updateUserDetails();
             }
             // build response
             $response = new stdClass();
             $response->job = $job;
             $response->task = $task;
             $response->result = $result;
             $response->errors = array();
             $response->success = true;
             $this->returnJSON($response);
             exit;
         case 'loadEbayCategoriesBranch':
             // call EbayController
             $this->initEC($account_id, $site_id);
             $result = $this->EC->loadEbayCategoriesBranch($task['cat_id'], $task['site_id']);
             $this->EC->closeEbay();
             // build response
             $response = new stdClass();
             $response->job = $job;
             $response->task = $task;
             $response->result = $result;
             $response->errors = array();
             $response->success = true;
             $this->returnJSON($response);
             exit;
         case 'verifyItem':
             // call EbayController
             $this->initEC($account_id);
             $results = $this->EC->verifyItems($task['id']);
             $this->EC->closeEbay();
             $this->handleSubTasksInResults($results, $job, $task);
             // build response
             $response = new stdClass();
             $response->job = $job;
             $response->task = $task;
             $response->errors = $results[0]->errors;
             $response->success = $results[0]->success;
             $this->returnJSON($response);
             exit;
         case 'publishItem':
             // call EbayController
             $this->initEC($account_id);
             $results = $this->EC->sendItemsToEbay($task['id']);
             $this->EC->closeEbay();
             $this->handleSubTasksInResults($results, $job, $task);
             // build response
             $response = new stdClass();
             $response->job = $job;
             $response->task = $task;
             $response->errors = $results[0]->errors;
             $response->success = $results[0]->success;
             $this->returnJSON($response);
             exit;
         case 'reviseItem':
             // call EbayController
             $this->initEC($account_id);
             $results = $this->EC->reviseItems($task['id']);
             $this->EC->closeEbay();
             $this->handleSubTasksInResults($results, $job, $task);
             // build response
             $response = new stdClass();
             $response->job = $job;
             $response->task = $task;
             $response->errors = $results[0]->errors;
             $response->success = $results[0]->success;
             $this->returnJSON($response);
             exit;
         case 'updateItem':
             // call EbayController
             $this->initEC($account_id);
             $results = $this->EC->updateItemsFromEbay($task['id']);
             $this->EC->closeEbay();
             // build response
             $response = new stdClass();
             $response->job = $job;
             $response->task = $task;
             $response->errors = $results[0]->errors;
             $response->success = $results[0]->success;
             $this->returnJSON($response);
             exit;
         case 'endItem':
             // call EbayController
             $this->initEC($account_id);
             $results = $this->EC->endItemsOnEbay($task['id']);
             $this->EC->closeEbay();
             $this->handleSubTasksInResults($results, $job, $task);
             // build response
             $response = new stdClass();
             $response->job = $job;
             $response->task = $task;
             $response->errors = $results[0]->errors;
             $response->success = $results[0]->success;
             $this->returnJSON($response);
             exit;
         case 'relistItem':
             // call EbayController
             $this->initEC($account_id);
             $results = $this->EC->relistItems($task['id']);
             $this->EC->closeEbay();
             $this->handleSubTasksInResults($results, $job, $task);
             // build response
             $response = new stdClass();
             $response->job = $job;
             $response->task = $task;
             $response->errors = $results[0]->errors;
             $response->success = $results[0]->success;
             $this->returnJSON($response);
             exit;
         case 'uploadToEPS':
             // call EbayController
             $this->initEC($account_id);
             $lm = new ListingsModel();
             $eps_url = $lm->uploadPictureToEPS($task['img'], $task['id'], $this->EC->session);
             $this->EC->closeEbay();
             // build response
             $response = new stdClass();
             $response->job = $job;
             $response->task = $task;
             // $response->errors   = $eps_url ? false : $lm->result->errors;
             $response->errors = is_array($lm->result->errors) ? $lm->result->errors : array();
             // $response->success  = $lm->result->success;
             $response->success = $eps_url ? true : false;
             $this->returnJSON($response);
             exit;
         case 'applyProfileDelayed':
             $profile_id = $task['profile_id'];
             $offset = $task['offset'];
             $limit = $task['limit'];
             $profilesModel = new ProfilesModel();
             $profile = $profilesModel->getItem($profile_id);
             $lm = new ListingsModel();
             $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);
             // extract batch
             $items = array_slice($items, $offset, $limit);
             // apply profile to items
             $lm->applyProfileToItems($profile, $items);
             // reset reminder option when last batch is run
             if ($offset + $limit >= $total_items) {
                 update_option('wple_job_reapply_profile_id', '');
             }
             // build response
             $response = new stdClass();
             $response->job = $job;
             $response->task = $task;
             $response->errors = array();
             // $response->errors   = array( array( 'HtmlMessage' => ' Profile was applied to '.sizeof($items).' items ') );
             $response->success = true;
             $this->returnJSON($response);
             exit;
         default:
             // echo "unknown task";
             // exit();
     }
 }
Beispiel #5
0
 private function saveProfile()
 {
     global $wpdb;
     $details = $this->getPreprocessedPostDetails();
     $profile_id = $this->getValueFromPost('profile_id');
     $account_id = $this->getValueFromPost('account_id');
     if (!$account_id) {
         $account_id = get_option('wplister_default_account_id');
     }
     // fix entered prices
     $details = self::fixProfilePrices($details);
     // process item specifics
     $item_specifics = array();
     $itmSpecs_name = @$_POST['itmSpecs_name'];
     $itmSpecs_value = @$_POST['itmSpecs_value'];
     $itmSpecs_attrib = @$_POST['itmSpecs_attrib'];
     if (is_array($itmSpecs_name)) {
         foreach ($itmSpecs_name as $key => $name) {
             #$name = str_replace('\\\\', '', $name );
             $name = stripslashes($name);
             $value = trim($itmSpecs_value[$key]);
             $attribute = trim($itmSpecs_attrib[$key]);
             if ($value != '' || $attribute != '') {
                 $spec = new stdClass();
                 $spec->name = $name;
                 $spec->value = $value;
                 $spec->attribute = $attribute;
                 $item_specifics[] = $spec;
             }
         }
     }
     $details['item_specifics'] = $item_specifics;
     // add category names
     $details['ebay_category_1_name'] = EbayCategoriesModel::getCategoryName($details['ebay_category_1_id']);
     $details['ebay_category_2_name'] = EbayCategoriesModel::getCategoryName($details['ebay_category_2_id']);
     $details['store_category_1_name'] = EbayCategoriesModel::getStoreCategoryName($details['store_category_1_id']);
     $details['store_category_2_name'] = EbayCategoriesModel::getStoreCategoryName($details['store_category_2_id']);
     // fix prices - already done in fixProfilePrices()
     // $details['start_price'] = str_replace(',', '.', $details['start_price'] );
     // $details['fixed_price'] = str_replace(',', '.', $details['fixed_price'] );
     // if the user enters only fixed price but no start price, move fixed price to start price
     if ($details['start_price'] == '' && $details['fixed_price'] != '') {
         $details['start_price'] = $details['fixed_price'];
         $details['fixed_price'] = '';
     }
     // fix quantities
     if (!$details['custom_quantity_enabled']) {
         $details['quantity'] = '';
         $details['max_quantity'] = '';
     }
     // do we have a primary category?
     if (intval($details['ebay_category_1_id']) != 0) {
         $primary_category_id = $details['ebay_category_1_id'];
     } else {
         // if not use default category
         $primary_category_id = self::getOption('default_ebay_category_id');
     }
     // // do we have ConditionDetails for primary category?
     // // $conditions = $this->fetchItemConditions( $primary_category_id, $profile_id, $account_id );
     // $conditions = EbayCategoriesModel::getConditionsForCategory( $primary_category_id, false, $account_id );
     // // do we have item specifics for primary category?
     // if ( intval($profile_id) != 0 ) {
     // 	// $saved_specifics = $wpdb->get_var('SELECT category_specifics FROM '.$wpdb->prefix.'ebay_profiles WHERE profile_id = '.$profile_id);
     // 	$saved_specifics = $wpdb->get_var( $wpdb->prepare( "SELECT category_specifics FROM {$wpdb->prefix}ebay_profiles WHERE profile_id = %d", $profile_id ) );
     // 	$saved_specifics = unserialize($saved_specifics);
     // }
     // // fetch required item specifics for primary category
     // if ( ( isset( $saved_specifics[ $primary_category_id ] ) ) && ( $saved_specifics[ $primary_category_id ] != 'none' ) ) {
     // 	$specifics = $saved_specifics;
     // } elseif ( (int)$primary_category_id != 0 ) {
     // 	$this->initEC( $account_id );
     // 	$specifics = $this->EC->getCategorySpecifics( $primary_category_id );
     // 	$this->EC->closeEbay();
     // } else {
     // 	$specifics = array();
     // }
     // // do we have item specifics for primary category?
     // (improved version of the above, using ebay_categories as cache)
     // $specifics = EbayCategoriesModel::getItemSpecificsForCategory( $primary_category_id, false, $account_id );
     // // $specifics = array( $primary_category_id => $specifics );
     if (WPLISTER_LIGHT) {
         $specifics = array();
     }
     // sql columns
     $item = array();
     $item['profile_id'] = $profile_id;
     $item['profile_name'] = $this->getValueFromPost('profile_name');
     $item['profile_description'] = $this->getValueFromPost('profile_description');
     $item['listing_duration'] = $this->getValueFromPost('listing_duration');
     $item['type'] = $this->getValueFromPost('auction_type');
     $item['sort_order'] = intval($this->getValueFromPost('sort_order'));
     $item['details'] = json_encode($details);
     // $item['conditions']			 		= serialize( $conditions );	// deprecated
     // $item['category_specifics']	 		= serialize( $specifics );	// deprecated
     $item['conditions'] = '';
     $item['category_specifics'] = '';
     $item['account_id'] = $account_id;
     $item['site_id'] = WPLE()->accounts[$item['account_id']]->site_id;
     // insert or update
     if ($item['profile_id'] == 0) {
         // insert new profile
         unset($item['profile_id']);
         $result = $wpdb->insert($wpdb->prefix . 'ebay_profiles', $item);
     } else {
         // update profile
         $result = $wpdb->update($wpdb->prefix . 'ebay_profiles', $item, array('profile_id' => $item['profile_id']));
     }
     // proper error handling
     if ($result === false) {
         $this->showMessage("There was a problem saving your profile.<br>SQL:<pre>" . $wpdb->last_query . '</pre>' . $wpdb->last_error, true);
     } else {
         $this->showMessage(__('Profile saved.', 'wplister'));
         // if we were updating this template as part of setup, move to next step
         if ('4' == self::getOption('setup_next_step')) {
             self::updateOption('setup_next_step', 5);
         }
     }
     // if this is a new profile, skip further processing
     if (!$profile_id) {
         return;
     }
     // handle delayed update option
     if (isset($_POST['wple_delay_profile_application'])) {
         update_option('wple_job_reapply_profile_id', $profile_id);
         return;
     }
     // prepare for updating items
     $listingsModel = new ListingsModel();
     $profilesModel = new ProfilesModel();
     $profile = $profilesModel->getItem($this->getValueFromPost('profile_id'));
     // re-apply profile to all prepared
     if ($this->getValueFromPost('apply_changes_to_all_prepared') == 'yes') {
         $items = WPLE_ListingQueryHelper::getAllPreparedWithProfile($item['profile_id']);
         $listingsModel->applyProfileToItems($profile, $items);
         $this->showMessage(sprintf(__('%s prepared items updated.', 'wplister'), count($items)));
     }
     // re-apply profile to all verified
     if ($this->getValueFromPost('apply_changes_to_all_verified') == 'yes') {
         $items = WPLE_ListingQueryHelper::getAllVerifiedWithProfile($item['profile_id']);
         $listingsModel->applyProfileToItems($profile, $items);
         $this->showMessage(sprintf(__('%s verified items updated.', 'wplister'), count($items)));
     }
     // re-apply profile to all published
     if ($this->getValueFromPost('apply_changes_to_all_published') == 'yes') {
         $items = WPLE_ListingQueryHelper::getAllPublishedWithProfile($item['profile_id']);
         $listingsModel->applyProfileToItems($profile, $items);
         $this->showMessage(sprintf(__('%s published items changed.', 'wplister'), count($items)));
     }
     // re-apply profile to all ended
     if ($this->getValueFromPost('apply_changes_to_all_ended') == 'yes') {
         $items = WPLE_ListingQueryHelper::getAllEndedWithProfile($item['profile_id']);
         $listingsModel->applyProfileToItems($profile, $items);
         $this->showMessage(sprintf(__('%s ended items updated.', 'wplister'), count($items)));
         // update ended listings - required for autorelist to be applied
         // $listingsModel->updateEndedListings();
         $this->initEC($account_id);
         $this->EC->updateListings();
         $this->EC->closeEbay();
     }
 }
Beispiel #6
0
 public function checkSetup($page = false)
 {
     global $pagenow;
     // check if safe mode is enabled
     $this->isPhpSafeMode();
     // check if incomatible plugins are active
     $this->checkPlugins();
     // check if a recent version of WooCommerce is installed
     $this->checkWooCommerce();
     // check if cURL is loaded
     if (!$this->isCurlLoaded()) {
         return false;
     }
     // check for windows server
     // if ( $this->isWindowsServer() ) return false;
     $this->isWindowsServer($page);
     // create folders if neccessary
     if ($this->checkFolders()) {
         return false;
     }
     // check for updates
     $this->checkForUpdates();
     // check if cron is working properly
     $this->checkCron();
     // check if any sites need to be refreshed
     $this->checkSites();
     // check database after migration
     // $this->checkDatabase();
     // $this->checkDbForInvalidAccounts();
     // check for multisite installation
     // if ( $this->checkMultisite() ) return false;
     $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : false;
     // setup wizard
     // if ( self::getOption('ebay_token') == '' ) {
     if ('1' == self::getOption('setup_next_step') && $current_tab != 'accounts') {
         $msg1 = __('You have not linked WP-Lister to your eBay account yet.', 'wplister');
         $msg2 = __('To complete the setup procedure go to %s and follow the instructions.', 'wplister');
         $accounts_page = get_option('wplister_enable_accounts_page') ? 'wplister-settings-accounts' : 'wplister-settings&tab=accounts';
         $link = sprintf('<a href="admin.php?page=%s">%s</a>', $accounts_page, __('Account Settings', 'wplister'));
         $msg2 = sprintf($msg2, $link);
         $msg = "<b>{$msg1}</b></p><p>{$msg2}";
         wple_show_message($msg, 'info');
     } elseif ('2' == self::getOption('setup_next_step')) {
         $title = __('Setup - Step 2', 'wplister');
         $msg1 = __('Before creating your first profile, we need to download certain information which are specific to the eBay site you selected.', 'wplister');
         $msg2 = __('This includes shipping options, payment methods, your custom store categories as well as the whole eBay category tree, which might take a while.', 'wplister');
         // old button
         // $button = '<a href="#" id="btn_update_ebay_data" onclick="return false;" class="button-primary">'.__('Update eBay details','wplister').'</a>';
         // new button - use site_id of default (first) account
         $account = WPLE()->accounts[get_option('wplister_default_account_id')];
         $button = '<a href="#" data-site_id="' . $account->site_id . '" data-account_id="' . $account->id . '" class="btn_update_ebay_data_for_site button-primary">' . __('Refresh eBay details', 'wplister') . '</a>';
         $msg = "<p><b>{$title}</b></p><p>{$msg1}</p><p>{$msg2}</p>";
         $msg .= $button;
         wple_show_message($msg, 'info');
         // // remember when WP-Lister was connected to an eBay account for the first time
         // update_option( 'ignore_orders_before_ts', time() );
     } elseif ('3' == self::getOption('setup_next_step')) {
         $tm = new TemplatesModel();
         $templates = $tm->getAll();
         if (sizeof($templates) > 0) {
             self::updateOption('setup_next_step', '4');
         } else {
             $title = __('Setup - Step 3', 'wplister');
             $msg1 = __('Create a default listing template.', 'wplister');
             $msg2 = __('To create your first listing template click on %s.', 'wplister') . '<br>';
             if (@$_GET['action'] == 'add_new_template') {
                 $msg2 = __('Replace the default text according to your requirements and save your template to continue.', 'wplister');
             }
             $link = '<a href="admin.php?page=wplister-templates&action=add_new_template">' . __('New Template', 'wplister') . '</a>';
             $msg2 = sprintf($msg2, $link);
             $msg = "<p><b>{$title}</b></p><p><b>{$msg1}</b></p><p>{$msg2}</p>";
             wple_show_message($msg, 'info');
         }
     } elseif ('4' == self::getOption('setup_next_step')) {
         $pm = new ProfilesModel();
         $profiles = $pm->getAll();
         if (sizeof($profiles) > 0) {
             self::updateOption('setup_next_step', '0');
         } else {
             $title = __('Setup - Step 4', 'wplister');
             $msg1 = __('The final step: create your first listing profile.', 'wplister');
             $msg2 = __('Click on %s and start defining your listing options.<br>After saving your profile, visit your Products page and select the products to list on eBay.', 'wplister');
             $link = '<a href="admin.php?page=wplister-profiles&action=add_new_profile">' . __('New Profile', 'wplister') . '</a>';
             $msg2 = sprintf($msg2, $link);
             $msg = "<b>{$msg1}</b></p><p>{$msg2}";
             wple_show_message($msg, 'info');
         }
     } elseif ('5' == self::getOption('setup_next_step')) {
         $title = __('Setup is complete.', 'wplister');
         $msg1 = __('You are ready now to list your first items.', 'wplister');
         $msg2 = __('Visit your Products page, select a few items and select "List on eBay" from the bulk actions menu.', 'wplister');
         $msg = "<b>{$msg1}</b></p><p>{$msg2}";
         wple_show_message($msg, 'info');
         update_option('wplister_setup_next_step', '0');
     }
     // db upgrade
     WPLE_UpgradeHelper::upgradeDB();
     // check token expiration date
     self::checkToken();
     // check if all db tables exist
     self::checkDatabaseTables($page);
     // // fetch user details if not done yet
     // if ( ( self::getOption('ebay_token') != '' ) && ( ! self::getOption('ebay_user') ) ) {
     // 	$this->initEC();
     // 	$UserID = $this->EC->GetUser();
     // 	$this->EC->closeEbay();
     // }
     // // fetch user details if not done yet
     // if ( ( self::getOption('ebay_token') != '' ) && ( ! self::getOption('ebay_seller_profiles_enabled') ) ) {
     // 	$this->initEC();
     // 	$this->EC->GetUserPreferences();
     // 	$this->EC->closeEbay();
     // }
     // // fetch token expiration date if not done yet
     // if ( ( self::getOption('ebay_token') != '' ) && ( ! self::getOption('ebay_token_expirationtime') ) ) {
     // 	$this->initEC();
     // 	$expdate = $this->EC->GetTokenStatus();
     // 	$this->EC->closeEbay();
     // }
 }
Beispiel #7
0
 public function displayPrepareListingsPage($selectedProducts)
 {
     // show warning if duplicate products found
     $this->checkForDuplicates();
     //Create an instance of our package class...
     // $this->listingsTable = new ListingsTable();
     //Fetch, prepare, sort, and filter our data...
     $this->listingsTable->selectedItems = $selectedProducts;
     $this->listingsTable->prepare_items();
     // get profiles
     $profilesModel = new ProfilesModel();
     $profiles = $profilesModel->getAll();
     $aData = array('plugin_url' => self::$PLUGIN_URL, 'message' => $this->message, 'last_selected_profile' => self::getOption('last_selected_profile'), 'profiles' => $profiles, 'listingsTable' => $this->listingsTable, 'form_action' => 'admin.php?page=' . self::ParentMenuId);
     $this->display('listings_prepare_page', $aData);
 }
Beispiel #8
0
 public function reapplyProfileToItem($id)
 {
     // get item
     if (!$id) {
         return;
     }
     $item = self::getItem($id);
     if (empty($item)) {
         return;
     }
     // get profile
     $profilesModel = new ProfilesModel();
     $profile = $profilesModel->getItem($item['profile_id']);
     // re-apply profile
     $this->applyProfileToItem($profile, $item);
 }
Beispiel #9
0
 function addPrepareActions($wp_admin_bar, $post_id)
 {
     // Prepare listing link
     $url = '#';
     $args = array('id' => 'wplister_tb_prepare_listing', 'title' => __('List on eBay', 'wplister'), 'href' => $url, 'parent' => 'wplister_top', 'meta' => array('class' => 'wplister-toolbar-page'));
     $wp_admin_bar->add_node($args);
     $pm = new ProfilesModel();
     $profiles = $pm->getAll();
     foreach ($profiles as $profile) {
         // echo "<pre>";print_r($profile);echo"</pre>";#die();
         $profile_id = $profile['profile_id'];
         $url = admin_url('admin.php?page=wplister&action=wpl_prepare_single_listing&product_id=' . $post_id . '&profile_id=' . $profile_id);
         $args = array('id' => 'wplister_list_on_ebay_' . $profile['profile_id'], 'title' => $profile['profile_name'], 'href' => $url, 'parent' => 'wplister_tb_prepare_listing', 'meta' => array('class' => 'wplister-toolbar-page'));
         $wp_admin_bar->add_node($args);
     }
     return $args;
 }
Beispiel #10
0
 function get_current_listing_profile()
 {
     if ($this->_listing_profile === null) {
         // get listing object
         $listing = $this->get_current_ebay_item();
         $profile_id = $listing && $listing->profile_id ? $listing->profile_id : false;
         // get profile
         $pm = new ProfilesModel();
         $profile = $profile_id ? $pm->getItem($profile_id) : false;
         $this->_listing_profile = is_array($profile) ? $profile : false;
     }
     return $this->_listing_profile;
 }
Beispiel #11
0
 public function deleteProfiles($id)
 {
     $sm = new ProfilesModel();
     if (is_array($id)) {
         foreach ($id as $single_id) {
             $sm->deleteItem($single_id);
         }
     } else {
         $sm->deleteItem($id);
     }
 }