public function ryi($params) { $this->session->setRequestToken($params['AuthToken']); $scope = $params['scope']; $req = new ReviseFixedPriceItemRequestType(); $item = new ItemType(); $item->setItemID($params['ItemID']); if (in_array('description', $scope)) { $item->setDescription($params['Description']); } if (in_array('sku', $scope)) { $item->setApplicationData($params['ApplicationData']); $item->setSKU($params['SKU']); } $item->setHitCounter("HiddenStyle"); $req->setItem($item); $res = $this->proxy->ReviseItem($req); switch ($res->getAck()) { case AckCodeType::CodeType_Success: return true; break; case AckCodeType::CodeType_Warning: echo "Item ID: {$params['ItemID']}<br>"; echo $this->proxy->getErrorsToString($res, true); return true; break; default: echo "Item ID: {$params['ItemID']}<br>"; echo $this->proxy->getErrorsToString($res, true); $this->dumpObject($res); return false; break; } }
function reviseItem($id, $session, $force_full_update = false, $restricted_mode = false) { // skip this item if item status not allowed $allowed_statuses = array('published', 'changed'); if (!$this->itemHasAllowedStatus($id, $allowed_statuses)) { return $this->result; } // check if product has variations $listing_item = self::getItem($id); // $useFixedPriceItem = ( ProductWrapper::hasVariations( $listing_item['post_id'] ) ) ? true : false; // $useFixedPriceItem = ( 'FixedPriceItem' == $listing_item['auction_type'] ) ? true : false; // handle locked items if ($listing_item['locked'] && !$force_full_update) { return $this->reviseInventoryStatus($id, $session, false); } // build item $ibm = new ItemBuilderModel(); $item = $ibm->buildItem($id, $session, true); if (!$ibm->checkItem($item, true)) { return $ibm->result; } // check for variations to be deleted $item = $ibm->fixDeletedVariations($item, $listing_item); // handle restricted revise mode if ($restricted_mode) { $item = $ibm->applyRestrictedReviseMode($item); } // if quantity is zero, end item instead if ($item->Quantity == 0 && !$ibm->VariationsHaveStock && !self::thisListingUsesOutOfStockControl($listing_item)) { WPLE()->logger->info("Item #{$id} has no stock, switching from reviseItem() to endItem()"); return $this->endItem($id, $session); } // checkItem should run after check for zero quantity - not it shouldn't as VariationsHaveStock will be undefined // TODO: separate quantity checks from checkItem() and run checkQuantity() first, maybe end item, if not then run other sanity checks // (This helps users who use the import plugin and WP-Lister Pro but forgot to set a primary category in their profile) // if ( ! $ibm->checkItem($item) ) return $ibm->result; // eBay Motors (beta) if ($item->Site == 'eBayMotors') { $session->setSiteId(100); } // preparation - set up new ServiceProxy with given session $this->initServiceProxy($session); // set ItemID to revise $item->setItemID(self::getEbayIDFromID($id)); WPLE()->logger->info("Revising #{$id}: " . $listing_item['auction_title']); // switch to FixedPriceItem if product has variations if (self::listingUsesFixedPriceItem($listing_item)) { $req = new ReviseFixedPriceItemRequestType(); $req->setItem($item); WPLE()->logger->debug("Request: " . print_r($req, 1)); $res = $this->_cs->ReviseFixedPriceItem($req); } else { $req = new ReviseItemRequestType(); $req->setItem($item); WPLE()->logger->debug("Request: " . print_r($req, 1)); $res = $this->_cs->ReviseItem($req); } // handle response and check if successful if ($this->handleResponse($res)) { // handle Error 21916734: Variation pictures cannot be removed during restricted revise. if (21916734 == $this->handle_error_code) { if (!$restricted_mode) { // make sure we try again only once WPLE()->logger->info("Error 21916734 - switching to restricted revise mode for item {$id}"); return $this->reviseItem($id, $session, $force_full_update, $restricted_mode = true); } } // update listing status $data['status'] = 'published'; if (1047 == $this->handle_error_code) { $data['status'] = 'ended'; } if (291 == $this->handle_error_code) { $data['status'] = 'ended'; } if (17 == $this->handle_error_code) { $data['status'] = 'archived'; } self::updateListing($id, $data); // get details like ViewItemURL from ebay automatically - unless item does not exist on eBay (17) if (17 != $this->handle_error_code) { $this->updateItemDetails($id, $session, true); $this->postProcessListing($id, $res->ItemID, $item, $listing_item, $res, $session); } WPLE()->logger->info("Item #{$id} was revised, ItemID is " . $res->ItemID); } // call successful self::processErrorsAndWarnings($id, $this->result); return $this->result; }