Пример #1
0
 function downloadReturnPolicyDetails($session, $site_id)
 {
     WPLE()->logger->info("downloadReturnPolicyDetails()");
     $this->initServiceProxy($session);
     // download ebay details
     $req = new GeteBayDetailsRequestType();
     $req->setDetailName('ReturnPolicyDetails');
     $res = $this->_cs->GeteBayDetails($req);
     // handle response and check if successful
     if ($this->handleResponse($res)) {
         // save array of ReturnsWithin options
         $ReturnsWithinOptions = array();
         foreach ($res->ReturnPolicyDetails->ReturnsWithin as $Detail) {
             $ReturnsWithinOptions[$Detail->ReturnsWithinOption] = $Detail->Description;
         }
         // update legacy option
         update_option('wplister_ReturnsWithinOptions', $ReturnsWithinOptions);
         // save array of ShippingCostPaidBy options
         $ShippingCostPaidByOptions = array();
         foreach ($res->ReturnPolicyDetails->ShippingCostPaidBy as $Detail) {
             $ShippingCostPaidByOptions[$Detail->ShippingCostPaidByOption] = $Detail->Description;
         }
         // update legacy option
         update_option('wplister_ShippingCostPaidByOptions', $ShippingCostPaidByOptions);
         // update site properties
         $Site = new WPLE_eBaySite($site_id);
         $Site->ReturnsWithinOptions = serialize($ReturnsWithinOptions);
         $Site->ShippingCostPaidByOptions = serialize($ShippingCostPaidByOptions);
         $Site->update();
     }
     // call successful
 }
Пример #2
0
 public function handleSubmit()
 {
     WPLE()->logger->debug("handleSubmit()");
     if ($this->requestAction() == 'display_log_entry') {
         $this->displayLogEntry($_REQUEST['log_id']);
         exit;
     }
     // handle delete action
     if ($this->requestAction() == 'delete') {
         $log_ids = @$_REQUEST['log'];
         if (is_array($log_ids)) {
             foreach ($log_ids as $id) {
                 $this->deleteLogEntry($id);
             }
             $this->showMessage(__('Selected items were removed.', 'wplister'));
         }
     }
     if ($this->requestAction() == 'wpl_clear_ebay_log') {
         $this->clearLog();
         $this->showMessage(__('Database log has been cleared.', 'wplister'));
     }
     if ($this->requestAction() == 'wpl_optimize_ebay_log') {
         $count = $this->optimizeLog();
         $this->showMessage($count . ' ' . __('expired records have been removed and the database table has been optimized.', 'wplister'));
     }
 }
Пример #3
0
 public function handleActionsOnInit()
 {
     WPLE()->logger->debug("handleActionsOnInit()");
     // these actions have to wait until 'init'
     if ($this->requestAction() == 'view_trx_details') {
         $this->showTransactionDetails($_REQUEST['transaction']);
         exit;
     }
 }
Пример #4
0
 public function handleActionsOnInit()
 {
     WPLE()->logger->debug("handleActionsOnInit()");
     // these actions have to wait until 'init'
     if ($this->requestAction() == 'view_ebay_message_details') {
         $this->showMessageDetails($_REQUEST['ebay_message']);
         exit;
     }
 }
Пример #5
0
 function getTokenExpirationTime($token)
 {
     $body = "\n  <RequesterCredentials><eBayAuthToken>{$token}</eBayAuthToken></RequesterCredentials>\n";
     $expdate = $this->TradeAPI('GetTokenStatus', $body, 'ExpirationTime');
     WPLE()->logger->info('getTokenExpirationTime: ' . $expdate);
     $expdate = str_replace('T', ' ', $expdate);
     $expdate = str_replace('.000Z', '', $expdate);
     #echo '<p/>Your token expires on:<p/>' . $expdate;
     return $expdate;
 }
Пример #6
0
 public function handleSubmit()
 {
     WPLE()->logger->debug("handleSubmit()");
     // handle download template
     if ($this->requestAction() == 'download_listing_template') {
         $this->downloadTemplate();
     }
     // handle delete action
     if ($this->requestAction() == 'delete_listing_template') {
         $this->deleteTemplate();
     }
 }
Пример #7
0
 function insertJob($jobname, $tasklist)
 {
     global $wpdb;
     // get current user id
     $user = wp_get_current_user();
     // generate job key
     $key = md5($jobname . rand());
     // insert row into db
     $data = array();
     $data['job_key'] = $key;
     $data['job_name'] = $jobname;
     $data['tasklist'] = self::encodeObject($tasklist);
     $data['date_created'] = date('Y-m-d H:i:s');
     $data['user_id'] = $user->ID;
     $wpdb->insert($this->tablename, $data);
     WPLE()->logger->info("insertJob( {$jobname} ) - key {$key}");
     $this->key = $key;
     return $key;
 }
Пример #8
0
 public function handleSubmitOnInit()
 {
     WPLE()->logger->debug("handleSubmit()");
     if ($this->requestAction() == 'prepare_auction') {
         $listingsModel = new ListingsModel();
         $listings = $listingsModel->prepareListings($_REQUEST['post']);
         // redirect to listings page
         wp_redirect(get_admin_url() . 'admin.php?page=wplister');
         exit;
     }
     if ($this->requestAction() == 'reselect') {
         ListingsModel::reSelectListings($_REQUEST['auction']);
         // redirect to listings page
         wp_redirect(get_admin_url() . 'admin.php?page=wplister');
         exit;
     }
     if ($this->requestAction() == 'apply_listing_profile') {
         WPLE()->logger->info('apply_listing_profile');
         #WPLE()->logger->info( print_r( $_REQUEST, 1 ) );
         $profilesModel = new ProfilesModel();
         $profile = $profilesModel->getItem($_REQUEST['wpl_e2e_profile_to_apply']);
         $listingsModel = new ListingsModel();
         $items = $listingsModel->applyProfileToNewListings($profile);
         // remember selected profile
         self::updateOption('last_selected_profile', intval($_REQUEST['wpl_e2e_profile_to_apply']));
         // redirect to listings page
         if (@$_REQUEST['wpl_e2e_verify_after_profile'] == '1') {
             // verify new listings if asked to
             wp_redirect(get_admin_url() . 'admin.php?page=wplister&action=verifyPreparedItemsNow');
         } else {
             wp_redirect(get_admin_url() . 'admin.php?page=wplister');
         }
         exit;
     }
     // handle preview action
     if ($this->requestAction() == 'preview_auction') {
         $this->previewListing($_REQUEST['auction']);
         exit;
     }
 }
Пример #9
0
function wple_show_message($message, $type = 'info', $params = null)
{
    WPLE()->messages->add_message($message, $type, $params);
}
Пример #10
0
 function update_products_on_shutdown()
 {
     // get queue
     $collected_products = get_option('wplister_updated_products_queue', array());
     if (!is_array($collected_products)) {
         $collected_products = array();
     }
     // DEBUG
     WPLE()->logger->info("CSV: update_products_on_shutdown() - collected_products: " . print_r($collected_products, 1));
     // mark each queued product as modified
     foreach ($collected_products as $post_id) {
         do_action('wplister_product_has_changed', $post_id);
     }
     // clear queue
     delete_option('wplister_updated_products_queue');
 }
Пример #11
0
 protected function handleCronSettings($schedule)
 {
     WPLE()->logger->info("handleCronSettings( {$schedule} )");
     // remove scheduled event
     $timestamp = wp_next_scheduled('wplister_update_auctions');
     wp_unschedule_event($timestamp, 'wplister_update_auctions');
     if ($schedule == 'external') {
         return;
     }
     if (!wp_next_scheduled('wplister_update_auctions')) {
         wp_schedule_event(time(), $schedule, 'wplister_update_auctions');
     }
 }
Пример #12
0
 function handleResponse($res, $is_second_request = false)
 {
     $errors = array();
     $this->handle_error_code = null;
     // prevent fatal error when response is not an object
     if (!is_object($res)) {
         echo 'Unexpected error: eBay response is invalid.<br>';
         echo "<pre>";
         print_r($res);
         echo "</pre>";
         WPLE()->logger->error('eBay response is not an object: ' . print_r($res, 1));
         return false;
     }
     // echo errors and warnings - call can be successful but with warnings
     if ($res->getErrors()) {
         foreach ($res->getErrors() as $error) {
             // hide warning #21917103 ("Delivery estimate based on shipping service and handling time")
             if ($error->getErrorCode() == 21917103) {
                 continue;
             }
             // #37 means soap error - and htmlentities have to be encoded (maybe not anymore?)
             if ($error->getErrorCode() == 37) {
                 $longMessage = htmlspecialchars($error->getLongMessage());
                 // $longMessage = $error->getLongMessage();
             } else {
                 $longMessage = htmlspecialchars($error->getLongMessage());
                 // $longMessage = $error->getLongMessage();
             }
             $shortMessage = htmlspecialchars($error->getShortMessage());
             // #240 - generic error on listing item
             if ($error->getErrorCode() == 240) {
                 $longMessage .= '<br><br>' . '<b>Note:</b> The message above is a generic error message from eBay which is not to be taken literally.';
                 $longMessage .= '<br>' . 'Below you find an explaination as to what triggered the above error:';
             }
             // #1047 - Auction closed / The auction has been closed.
             if ($error->getErrorCode() == 1047) {
                 // change status from Error to Warning to allow post processing of this error
                 $res->setAck('Warning');
                 $this->handle_error_code = 1047;
                 $longMessage .= '<br><br>' . '<b>Note:</b> Listing status was changed to ended.';
             }
             // #291 - Auction ended / You are not allowed to revise ended listings.
             if ($error->getErrorCode() == 291) {
                 // change status from Error to Warning to allow post processing of this error
                 $res->setAck('Warning');
                 $this->handle_error_code = 291;
                 $longMessage .= '<br><br>' . '<b>Note:</b> Listing status was changed to ended.';
             }
             // #17 - This item cannot be accessed because the listing has been deleted, ... or you are not the seller.
             if ($error->getErrorCode() == 17) {
                 // change status from Error to Warning to allow post processing of this error
                 $res->setAck('Warning');
                 $this->handle_error_code = 17;
                 $longMessage .= '<br><br>' . '<b>Note:</b> Listing status was changed to archived.';
             }
             // #21916734 - Error: Pictures cannot be removed. - Variation pictures cannot be removed during restricted revise.
             if ($error->getErrorCode() == 21916734) {
                 // change status from Error to Warning to allow post processing of this error (retry in restricted revise mode)
                 $res->setAck('Warning');
                 $this->handle_error_code = 21916734;
                 $longMessage .= '<br><br>' . '<i>Switching to restricted revise mode...</i>';
             }
             // #55 - Error: Adding feedback failed: invalid item number or invalid transaction or feedback already left
             if ($error->getErrorCode() == 55) {
                 $this->handle_error_code = 55;
                 // remember error code for callCompleteOrder()
             }
             // #302 - Invalid auction listing type
             if ($error->getErrorCode() == 302) {
                 $longMessage .= '<br><br>' . '<b>Note:</b> eBay does not allow changing the listing type of an active listing.';
                 $longMessage .= '<br>' . 'To change a listing type from auction to fixed price or vice versa, you need to end and relist the item.';
             }
             // #931 - Auth token is invalid
             if ($error->getErrorCode() == 931) {
                 $shortMessage = 'Your API token is invalid';
                 // $longMessage .= '<br><br>'. '<b>Your API token is invalid.</b> Please authenticate WP-Lister with eBay again.';
                 $longMessage .= '<br><br>' . '<b>Please authenticate WP-Lister with eBay again.</b>';
                 $longMessage .= '<br>' . 'This can happen if you enabled the sandbox mode or if your token has expired.';
                 $longMessage .= '<br>' . 'To refresh your eBay token, please visit Settings &raquo; Account &raquo; Edit and follow the instructions in the sidebar.';
                 // update_option( 'wplister_ebay_token_is_invalid', true ); // update legacy option
                 update_option('wplister_ebay_token_is_invalid', array('site_id' => $this->site_id, 'account_id' => $this->account_id));
                 // store site and account
             }
             // #21916519 - Error: Listing is missing required item specific(s)
             if ($error->getErrorCode() == 21916519) {
                 // $longMessage .= '<br><br>'. '<b>How to add item specifics to your eBay listings</b>'.'<br>';
                 $longMessage .= '<br><br>' . '<b>Why am I seeing this error message?</b>' . '<br>';
                 $longMessage .= 'eBay requires sellers to provide these item specifics (product attributes) for the selected primary category.' . '<br>';
                 $longMessage .= '<br>';
                 $longMessage .= 'You have two options to add item specifics to your listings:' . '<!br>';
                 $longMessage .= '<ol>';
                 $longMessage .= '<li>Create product attributes with the exact same name as required by eBay.' . '</li>';
                 if (WPLISTER_LIGHT) {
                     $longMessage .= '<li>Upgrade to WP-Lister Pro where you can define item specifics in your profile. You can either enter fixed values or map existing WooCommerce product attributes to eBay item specifics.' . '</li>';
                 } else {
                     $longMessage .= '<li>Define item specifics in your listing profile where you can either enter fixed values or map WooCommerce product attributes to eBay item specifics.' . '</li>';
                 }
                 $longMessage .= '</ol>';
                 if (!defined('WPLISTER_RESELLER_VERSION')) {
                     $longMessage .= 'More detailed information about item specifics in WP-Lister Pro can be found here: ';
                     $longMessage .= '<a href="https://www.wplab.com/list-your-products-with-item-specifics-recommended-by-ebay/" target="_blank">https://www.wplab.com/list-your-products-with-item-specifics-recommended-by-ebay/</a>';
                 }
             }
             // #219422   - Error: Invalid PromotionalSale item / Item format does not qualify for promotional sale
             // #21916391 - Error: Not an Active SM subscriber  / "user" is not subscribed to Selling Manager.
             if ($error->getErrorCode() == 219422 || $error->getErrorCode() == 21916391) {
                 $longMessage .= '<br><br>' . '<b>Why am I seeing this error message?</b>' . '<br>';
                 $longMessage .= 'You might not be allowed to use eBay\'s <i>Selling Manager Pro</i>.' . '<br>';
                 $longMessage .= '<br>';
                 $longMessage .= 'If you see this error when listing a new item on eBay it will still be listed, ';
                 $longMessage .= 'but you should disable the <i>Auto Relist</i> option in your listing profile in the box labeled "Selling Manager Pro" in order to make this error message disappear.';
             }
             // #21915307 - Warning: Shipping Service - Pickup is set as last service.
             if ($error->getErrorCode() == 21915307) {
                 $longMessage .= '<br><br>' . '<b>Why am I seeing this message?</b>' . '<br>';
                 $longMessage .= 'The warning above can be misleading. What eBay actually means is: ';
                 $longMessage .= 'If there are two or more services and one is "pickup", "pickup" must not be specified as the first service.';
             }
             // #21916543 - Error: ExternalPictureURL server not available.
             if ($error->getErrorCode() == 21916543) {
                 $longMessage .= '<br><br>' . '<b>Why am I seeing this message?</b>' . '<br>';
                 $longMessage .= 'eBay tried to fetch an image from your website but your server did not respond in time.<br>';
                 $longMessage .= 'This could be a temporary issue with eBay, but it could as well indicate problems with your server. ';
                 $longMessage .= 'You should wait a few hours and see if this issue disappears, but if it persists you should consider moving to a better hosting provider.';
                 $longMessage .= '<br>';
                 $longMessage .= 'If your site uses SSL, make sure that static content like images is accessible both with and without SSL. eBay is not able to fetch images from SSL-only sites.';
                 $longMessage .= '<br>';
                 $longMessage .= 'Alternatively visit the developer settings page and set the <i>EPS transfer mode</i> option to active. This will send the image data directly instead of an URL and should fix uploading image on SSL sites.';
             }
             // #21919028 - Error: Portions of this listing cannot be revised if the item has bid or active Best Offers or is ending in 12 hours.
             if ($error->getErrorCode() == 21919028) {
                 $longMessage .= '<br><br>' . '<b>Why am I seeing this message?</b>' . '<br>';
                 $longMessage .= 'You probably tried to disable Best Offer for this item.<br>';
                 $longMessage .= 'Turning off the Best Offer feature is not an allowed after an item has had sales.';
             }
             // #21917327 - Error: You've provided an invalid postage policy.
             if ($error->getErrorCode() == 21917327) {
                 $longMessage .= '<br><br>' . '<b>Why am I seeing this message?</b>' . '<br>';
                 $longMessage .= 'Your shipping profiles on eBay have changed.<br>';
                 $longMessage .= 'Please visit WP-Lister &raquo; Settings &raquo; Accounts and click on <i>Refresh details</i> to fetch the current list of profiles from eBay. ';
                 $longMessage .= 'You should check your profiles and products after doing so - you might have to update them.';
             }
             // #21919152 - Error: Shipping policy is required
             if ($error->getErrorCode() == 21919152) {
                 $longMessage .= '<br><br>' . '<b>Why am I seeing this message?</b>' . '<br>';
                 $longMessage .= 'eBay has silently changed their requirements regarding business policies and now expects either all three business policies to be used, or none of them.<br>';
                 $longMessage .= 'Please make sure that you select a shipping policy, a payment policy <i>and</i> a return policy in your listing profile - or disable all three policies.';
             }
             // #21919153 - Error: Payment policy is required
             if ($error->getErrorCode() == 21919153) {
                 $longMessage .= '<br><br>' . '<b>Why am I seeing this message?</b>' . '<br>';
                 $longMessage .= 'eBay has silently changed their requirements regarding business policies and now expects either all three business policies to be used, or none of them.<br>';
                 $longMessage .= 'Please make sure that you select a shipping policy, a payment policy <i>and</i> a return policy in your listing profile - or disable all three policies.';
             }
             // #21919154 - Error: Return policy is required
             if ($error->getErrorCode() == 21919154) {
                 $longMessage .= '<br><br>' . '<b>Why am I seeing this message?</b>' . '<br>';
                 $longMessage .= 'eBay has silently changed their requirements regarding business policies and now expects either all three business policies to be used, or none of them.<br>';
                 $longMessage .= 'Please make sure that you select a shipping policy, a payment policy <i>and</i> a return policy in your listing profile - or disable all three policies.';
             }
             // #21916635 - Error: Invalid Multi-SKU item id.
             if ($error->getErrorCode() == 21916635) {
                 $longMessage .= '<br><br>' . '<b>Why am I seeing this message?</b>' . '<br>';
                 $longMessage .= 'You are trying to change an existing non-variable eBay listing to a variable listing - which is not allowed by eBay, although it is technically possible in WooCommerce.<br>';
                 $longMessage .= 'In order to revise or relist this product you have to end the eBay listing first, move it to the archive and then create a new listing from your product.';
             }
             // #21916564 - Error: Variations not enabled in category
             if ($error->getErrorCode() == 21916564) {
                 $longMessage .= '<br><br>' . '<b>Why am I seeing this message?</b>' . '<br>';
                 $longMessage .= 'Not all eBay categories support listings with variations. If you get this error when attempting to list an item, you will need to select an alternative eBay category to list the item.<br>';
                 $longMessage .= 'To learn more about variations and allowed categories you should visit this page: ';
                 $longMessage .= '<a href="http://pages.ebay.com/help/sell/listing-variations.html" target="_blank">http://pages.ebay.com/help/sell/listing-variations.html</a>';
             }
             // #488 - Error: Duplicate UUID used.
             if ($error->getErrorCode() == 488) {
                 $longMessage .= '<br><br>' . '<b>Why am I seeing this message?</b>' . '<br>';
                 $longMessage .= 'You probably tried to list the same product twice within a short time period.<br>';
                 $longMessage .= 'Please wait for about one hour and you will be able to list this product again. ';
             }
             // #21917091 - Warning: Requested StartPrice and Quantity revision is redundant.
             if ($error->getErrorCode() == 21917091) {
                 continue;
             }
             // #21917092 - Warning: Requested Quantity revision is redundant.
             if ($error->getErrorCode() == 21917092) {
                 continue;
             }
             // #90002 - soap-fault: org.xml.sax.SAXParseException: The element type "Description" must be terminated by the matching end-tag "</Description>".
             if ($error->getErrorCode() == 90002 && strpos($longMessage, 'Description')) {
                 $longMessage .= '<br><br>' . '<b>Why am I seeing this message?</b>' . '<br>';
                 $longMessage .= 'Your listing template probably contains CDATA tags which can not be used in a listing description.<br>';
                 $longMessage .= 'Please remove all CDATA tags from your listing template and try again - or contact support. ';
             }
             // #10007 - Error: Internal error to the application
             if ($error->getErrorCode() == 10007) {
                 $longMessage .= '<br><br>' . '<b>Why am I seeing this message?</b>' . '<br>';
                 $longMessage .= 'This message indicates an error on the eBay server side.<br>';
                 $longMessage .= 'You should try using a different primary category for your listing - if that does not help, please contact support.';
             }
             // handle PartialFailure on CompleteSale requests
             // #21919444 - Warning: Duplicate request, seller has already marked paid.
             // (ignore redundant warning for orders already paid on eBay)
             if ($error->getErrorCode() == 21919444) {
                 // change status from PartialFailure to Warning - because the request was (partially) successful after all
                 $res->setAck('Warning');
                 continue;
             }
             // some errors like #240 may return an extra ErrorParameters array
             // deactivated for now since a copy of this will be found in $res->getMessage()
             // if ( isset( $error->ErrorParameters ) ) {
             // 	$extraMsg  = '<div id="message" class="updated update-nag" style="display:block !important;"><p>';
             // 	$extraMsg .= print_r( $error->ErrorParameters, 1 );
             // 	$extraMsg .= '</p></div>';
             // 	if ( ! $this->is_ajax() ) echo $extraMsg;
             // } else {
             // 	$extraMsg = '';
             // }
             // display error message - if this is not an ajax request
             $class = $error->SeverityCode == 'Error' ? 'error' : 'updated update-nag';
             $htmlMsg = '<div id="message" class="' . $class . '" style="display:block !important;"><p>';
             $htmlMsg .= '<b>' . $error->SeverityCode . ': ' . $shortMessage . '</b>' . ' (#' . $error->getErrorCode() . ') ';
             $htmlMsg .= '<br>' . $longMessage . '';
             // handle optional ErrorParameters
             if (!empty($error->ErrorParameters)) {
                 foreach ($error->ErrorParameters as $param) {
                     $htmlMsg .= '<br><code>' . $param . '</code>';
                 }
             }
             $htmlMsg .= '</p></div>';
             // $htmlMsg .= $extraMsg;
             if (!$this->is_ajax()) {
                 echo $htmlMsg;
             }
             // save errors and warnings as array of objects
             $errorObj = new stdClass();
             $errorObj->SeverityCode = $error->SeverityCode;
             $errorObj->ErrorCode = $error->getErrorCode();
             $errorObj->ShortMessage = $error->getShortMessage();
             $errorObj->LongMessage = $longMessage;
             $errorObj->HtmlMessage = $htmlMsg;
             $errors[] = $errorObj;
         }
     }
     // some errors like #240 may trigger an extra Message field returned in the response
     if ($res->getMessage()) {
         $class = $res->getAck() == 'Failure' ? 'error' : 'updated update-nag';
         $extraMsg = '<div id="message" class="' . $class . '" style="display:block !important;">';
         $extraMsg .= $res->getMessage();
         $extraMsg .= '</div>';
         if (!$this->is_ajax()) {
             echo $extraMsg;
         }
         // save errors and warnings as array of objects
         $errorObj = new stdClass();
         $errorObj->SeverityCode = 'Info';
         $errorObj->ErrorCode = 101;
         $errorObj->ShortMessage = __('Additional details about this error', 'wplister');
         $errorObj->LongMessage = $res->getMessage();
         $errorObj->HtmlMessage = $extraMsg;
         $errors[] = $errorObj;
     }
     // check if request was successful
     if ($res->getAck() == 'Success' || $res->getAck() == 'Warning') {
         $success = true;
     } else {
         $success = false;
     }
     // save results as local property - except for GetItem calls following a ReviseItem call
     // if ( ! isset($this->result) && get_class($res) != 'GetItemResponseType' ) {
     if (!$is_second_request) {
         $this->result = new stdClass();
         $this->result->success = $success;
         $this->result->errors = $errors;
         $this->save_last_result();
         // store result in db to show after edit product redirect
     }
     // // save last result - except for GetItem calls which usually follow ReviseItem calls
     // if ( 'GetItemResponseType' != get_class($res) )
     // 	$this->save_last_result();
     // // WPLE()->logger->info('handleResponse() - type: '.get_class($res));
     // // WPLE()->logger->info('handleResponse() - result: '.print_r($this->result,1));
     return $success;
 }
Пример #13
0
 public function checkToken()
 {
     // legacy option - not used anymore
     // $expdate = get_option( 'wplister_ebay_token_expirationtime' );
     // get all accounts
     $accounts = WPLE()->accounts;
     if (!is_array($accounts) || empty($accounts)) {
         return;
     }
     $two_weeks_from_now = time() + 3600 * 24 * 7 * 2;
     foreach ($accounts as $account) {
         // get a valid expiration time
         $expdate = $account->valid_until;
         if (!$expdate) {
             continue;
         }
         if (!($exptime = strtotime($expdate))) {
             continue;
         }
         if (!$account->active) {
             continue;
         }
         if ($exptime < time()) {
             // token has already expired
             wple_show_message('<p>' . '<b> ' . sprintf(__('Warning: The token for your eBay account %s has expired on %s.', 'wplister'), $account->title, $expdate) . ' (' . human_time_diff(strtotime($expdate)) . ' ago) ' . '</b>' . '<br><br>' . 'To refresh your eBay token, please visit Settings &raquo; Account &raquo; Edit and follow the instructions in the sidebar.' . '</p>', 'error');
         } elseif ($exptime < $two_weeks_from_now) {
             // token will expire soon
             wple_show_message('<p>' . '<b> ' . sprintf(__('Warning: The token for your eBay account %s will expire on %s.', 'wplister'), $account->title, $expdate) . ' (in ' . human_time_diff(strtotime($expdate)) . ') ' . '</b>' . '<br><br>' . 'To refresh your eBay token, please visit Settings &raquo; Account &raquo; Edit and follow the instructions in the sidebar.' . '</p>', 'warn');
         }
     }
     // foreach account
     // warn about invalid token - could be obsolete since we check for expiry time already, but maybe it's still useful
     if ($token_data = get_option('wplister_ebay_token_is_invalid')) {
         if (is_array($token_data) && isset($token_data['site_id'])) {
             $account = isset(WPLE()->accounts[$token_data['account_id']]) ? WPLE()->accounts[$token_data['account_id']] : false;
             $account_title = $account ? $account->title . '(' . $account->site_code . ')' : 'Default';
             $msg1 = sprintf(__('The token for your eBay account %s seems to be invalid.', 'wplister'), $account_title);
             $msg2 = 'To refresh your eBay token, please visit Settings &raquo; Account &raquo; Edit and follow the instructions in the sidebar.';
             $msg = "<b>{$msg1}</b></p><p>{$msg2}";
             wple_show_message($msg, 'warn');
         }
     }
 }
Пример #14
0
 protected function fixEnabledSites()
 {
     global $wpdb;
     // disable all sites
     $wpdb->update($wpdb->prefix . 'ebay_sites', array('enabled' => 0), array('enabled' => 1));
     // enable site for each account
     foreach (WPLE()->accounts as $account) {
         $wpdb->update($wpdb->prefix . 'ebay_sites', array('enabled' => 1), array('id' => $account->site_id));
     }
 }
Пример #15
0
 function mapItemDetailToDB($Detail)
 {
     //#type $Detail MyMessagesMessageType
     $data['message_id'] = $Detail->MessageID;
     $data['received_date'] = self::convertEbayDateToSql($Detail->ReceiveDate);
     $data['expiration_date'] = self::convertEbayDateToSql($Detail->ExpirationDate);
     $data['subject'] = $Detail->Subject;
     $data['sender'] = $Detail->Sender;
     $data['flag_read'] = $Detail->Read;
     $data['flag_replied'] = $Detail->Replied;
     $data['flag_flagged'] = $Detail->Flagged;
     $data['item_title'] = $Detail->ItemTitle;
     $data['item_id'] = $Detail->ItemID;
     $data['folder_id'] = $Detail->Folder->FolderID;
     $data['response_url'] = $Detail->ResponseDetails->ResponseURL;
     $data['site_id'] = $this->site_id;
     $data['account_id'] = $this->account_id;
     if ($Detail->Text != '') {
         $data['msg_text'] = $Detail->Text;
     }
     if ($Detail->Content != '') {
         $data['msg_content'] = $Detail->Content;
     }
     // save GetMyMessages reponse in details
     $data['details'] = self::encodeObject($Detail);
     WPLE()->logger->info("IMPORTING message #" . $Detail->MessageID);
     return $data;
 }
Пример #16
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 
    }
Пример #17
0
 function column_account($item)
 {
     $account_title = isset(WPLE()->accounts[$item['account_id']]) ? WPLE()->accounts[$item['account_id']]->title : '<span style="color:darkred">Invalid Account ID: ' . $item['account_id'] . '</span>';
     if (!$item['account_id']) {
         $account_title = '&mdash;';
     }
     return sprintf('%1$s <br><span style="color:silver">%2$s</span>', $account_title, EbayController::getEbaySiteCode($item['site_id']));
 }
Пример #18
0
    function extra_tablenav($which)
    {
        if ('top' != $which) {
            return;
        }
        $account_id = isset($_REQUEST['account_id']) ? $_REQUEST['account_id'] : false;
        ?>
        <div class="alignleft actions" style="">

            <?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>            

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

            <?php 
        }
        ?>

        </div>
        <?php 
    }
Пример #19
0
 function fetchDoesNotApplyText($session, $site_id)
 {
     WPLE()->logger->info("fetchDoesNotApplyText()");
     $this->initServiceProxy($session);
     // download ebay details
     $req = new GeteBayDetailsRequestType();
     $req->setDetailName('ProductDetails');
     $res = $this->_cs->GeteBayDetails($req);
     // handle response and check if successful
     if ($this->handleResponse($res)) {
         // get text - default is 'Does not apply'
         $DoesNotApplyText = $res->ProductDetails->ProductIdentifierUnavailableText;
         // update site property
         $Site = new WPLE_eBaySite($site_id);
         $Site->DoesNotApplyText = $DoesNotApplyText;
         $Site->update();
     }
     // call successful
 }
Пример #20
0
 function getDateOfFirstOrder()
 {
     global $wpdb;
     // regard ignore_orders_before_ts timestamp if set
     if ($ts = get_option('ignore_orders_before_ts')) {
         WPLE()->logger->info("getDateOfFirstOrder() - using ignore_orders_before_ts: {$ts} (raw)");
         return $ts;
     }
     $date = $wpdb->get_var("\n\t\t\tSELECT date_created\n\t\t\tFROM {$this->tablename}\n\t\t\tORDER BY date_created ASC LIMIT 1\n\t\t");
     return strtotime($date);
 }
Пример #21
0
 public function ajax_handle_ebay_notify()
 {
     // require_once WPLISTER_PATH . '/includes/EbatNs/' . 'EbatNs_NotificationClient.php';
     // require_once WPLISTER_PATH . '/includes/EbatNs/' . 'EbatNs_ResponseError.php';
     // load eBay classes
     EbayController::loadEbayClasses();
     $handler = new EbatNs_NotificationClient();
     $body = file_get_contents('php://input');
     $res = $handler->getResponse($body);
     WPLE()->logger->info('handle_ebay_notify() - time: ' . date('Y-m-d H:i:s'));
     //WPLE()->logger->info('POST:  '.print_r($_POST,1));
     WPLE()->logger->info('REQUEST: ' . print_r($_REQUEST, 1));
     WPLE()->logger->info('SERVER:  ' . print_r($_SERVER, 1));
     $headers = getallheaders();
     WPLE()->logger->info('headers: ' . print_r($headers, 1));
     WPLE()->logger->info('body:    ' . print_r($body, 1));
     WPLE()->logger->info('response:' . print_r($res, 1));
     // log to db
     $this->dblogger = new WPL_EbatNs_Logger();
     $this->dblogger->updateLog(array('callname' => 'handle_ebay_notify', 'request_url' => 'platform notification', 'request' => $body . "\n\n" . print_r($_REQUEST, 1) . "\n\n" . print_r($_SERVER, 1), 'response' => json_encode($res), 'success' => 'Success'));
     // send email (for debugging only)
     $msg = 'A notification was received at ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "\n\n";
     $msg .= 'Body:     ' . print_r($body, 1) . "\n\n";
     $msg .= 'Response: ' . print_r($res, 1) . "\n";
     $msg .= 'REQUEST:  ' . print_r($_REQUEST, 1) . "\n";
     $msg .= 'SERVER:   ' . print_r($_SERVER, 1) . "\n";
     $msg .= 'Headers:  ' . print_r($headers, 1) . "\n";
     // $to = get_option('admin_email', '*****@*****.**');
     $to = '*****@*****.**';
     $subject = 'New WPLE platform notification (debug info)';
     wp_mail($to, $subject, $msg);
     echo 'ACK';
     exit;
 }
Пример #22
0
 public function processAttributeShortcodes($post_id, $tpl_html, $max_length = false)
 {
     // check for attribute shortcodes
     if (preg_match_all("/\\[\\[attribute_(.*)\\]\\]/uUsm", $tpl_html, $matches)) {
         // attribute shortcodes i.e. [[attribute_Brand]]
         $product_attributes = ProductWrapper::getAttributes($post_id);
         WPLE()->logger->debug('processAttributeShortcodes() - product_attributes: ' . print_r($product_attributes, 1));
         // parent attribute for split child variations
         $parent_post_id = ProductWrapper::getVariationParent($post_id);
         $parent_attributes = $parent_post_id ? ProductWrapper::getAttributes($parent_post_id) : array();
         WPLE()->logger->debug('processAttributeShortcodes() - parent_attributes: ' . print_r($parent_attributes, 1));
         // process each found shortcode
         foreach ($matches[1] as $attribute) {
             // check product and parent attributes
             if (isset($product_attributes[$attribute])) {
                 $attribute_value = $product_attributes[$attribute];
             } elseif (isset($parent_attributes[$attribute])) {
                 $attribute_value = $parent_attributes[$attribute];
             } else {
                 $attribute_value = '';
             }
             // format multiple attribute values
             $attribute_value = str_replace('|', '<br/>', $attribute_value);
             // replace placeholder
             $processed_html = str_replace('[[attribute_' . $attribute . ']]', $attribute_value, $tpl_html);
             // check if string exceeds max_length after processing shortcode
             if ($max_length && $this->mb_strlen($processed_html) > $max_length) {
                 $attribute_value = '';
                 $processed_html = str_replace('[[attribute_' . $attribute . ']]', $attribute_value, $tpl_html);
             }
             $tpl_html = $processed_html;
         }
     }
     return $tpl_html;
 }
Пример #23
0
?>
							
						</div>
					</div>

					<?php 
if (WPLE()->multi_account) {
    ?>
					<div class="postbox" id="AccountsBox">
						<h3><span><?php 
    echo __('Account', 'wplister');
    ?>
</span></h3>
						<div class="inside">
							<?php 
    foreach (WPLE()->accounts as $account) {
        ?>
								<?php 
        $account_id = $account->id;
        $checked = $wpl_item['account_id'] == $account_id ? 'checked="checked"' : '';
        $disabled = $account->active ? '' : 'disabled="disabled"';
        ?>

								<input type="radio" value="<?php 
        echo $account_id;
        ?>
" id="account-<?php 
        echo $account_id;
        ?>
" name="wpl_e2e_account_id" class="post-format" <?php 
        echo $checked;
Пример #24
0
 static function getProduct($post_id, $is_variation = false)
 {
     // use get_product() on WC 2.0+
     if (function_exists('get_product')) {
         // return get_product( $post_id );
         return WPLE()->memcache->getProductObject($post_id);
     } else {
         // instantiate WC_Product on WC 1.x
         return $is_variation ? new WC_Product_Variation($post_id) : new WC_Product($post_id);
     }
 }
Пример #25
0
 public function removeLock()
 {
     if (file_exists($this->lockfile)) {
         unlink($this->lockfile);
         WPLE()->logger->info("lockfile was removed: " . $this->lockfile);
     }
 }
Пример #26
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();
     }
 }
Пример #27
0
 /** ************************************************************************
  * REQUIRED! This method dictates the table's columns and titles. This should
  * return an array where the key is the column slug (and class) and the value 
  * is the column's title text. If you need a checkbox for bulk actions, refer
  * to the $columns array below.
  * 
  * The 'cb' column is treated differently than the rest. If including a checkbox
  * column in your table you must create a column_cb() method. If you don't need
  * bulk actions or checkboxes, simply leave the 'cb' entry out of your array.
  * 
  * @see WP_List_Table::::single_row_columns()
  * @return array An associative array containing column information: 'slugs'=>'Visible Titles'
  **************************************************************************/
 function get_columns()
 {
     $columns = array('cb' => '<input type="checkbox" />', 'profile_name' => __('Profile', 'wplister'), 'listing_duration' => __('Duration', 'wplister'), 'price' => __('Price', 'wplister'), 'category' => __('Category', 'wplister'), 'type' => __('Type', 'wplister'), 'template' => __('Template', 'wplister'), 'account' => __('Account', 'wplister'));
     if (!WPLE()->multi_account) {
         unset($columns['account']);
     }
     return $columns;
 }
Пример #28
0
 public function updateById($id, $data)
 {
     global $wpdb;
     // handle NULL values
     foreach ($data as $key => $value) {
         if (NULL === $value) {
             $key = esc_sql($key);
             $wpdb->query($wpdb->prepare("UPDATE {$this->tablename} SET {$key} = NULL WHERE id = %s", $id));
             WPLE()->logger->info('SQL to set NULL value: ' . $wpdb->last_query);
             WPLE()->logger->info($wpdb->last_error);
             unset($data[$key]);
         }
     }
     // update
     $wpdb->update($this->tablename, $data, array('id' => $id));
     WPLE()->logger->debug('sql: ' . $wpdb->last_query);
     WPLE()->logger->info($wpdb->last_error);
 }
Пример #29
0
 
        <table class="wple_profile_results" style="width:100%">
        <?php 
    foreach ($wpl_profiles as $profile) {
        ?>
        
            <tr><td class="info hover">
                <big>
                    <?php 
        echo $profile['profile_name'];
        ?>
                    <?php 
        if (WPLE()->multi_account) {
            ?>
                        &nbsp;<span style="color:silver;"><?php 
            echo WPLE()->accounts[$profile['account_id']]->title;
            ?>
</span>
                    <?php 
        }
        ?>
                </big><br>

                <small><?php 
        echo $profile['profile_description'];
        ?>
</small>
                <br>

            </td><td class="info hover" style="text-align:right">
       
Пример #30
0
 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() . '&nbsp;&nbsp;';
             $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>' . '&nbsp;&nbsp;';
             $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);
 }