/**
  * sample_VerifyAddItem::dispatchCall()
  * 
  * Dispatch the call
  *
  * @param array $params array of parameters for the eBay API call
  * 
  * @return boolean success
  */
 public function dispatchCall($params)
 {
     $req = new VerifyAddItemRequestType();
     $item = new ItemType();
     $item->setTitle($params['Title']);
     $item->setQuantity($params['Quantity']);
     $item->setCurrency($params['Currency']);
     $item->setCountry($params['Country']);
     $item->setStartPrice($params['StartPrice']);
     $item->setListingDuration($params['ListingDuration']);
     $item->setLocation($params['Location']);
     $item->setPaymentMethods($params['PaymentMethods']);
     $item->setListingType($params['ListingType']);
     $item->setDescription($params['Description']);
     $primaryCategory = new CategoryType();
     $primaryCategory->setCategoryID($params['CategoryID']);
     $item->setPrimaryCategory($primaryCategory);
     $req->setItem($item);
     $res = $this->proxy->VerifyAddItem($req);
     if ($this->testValid($res)) {
         $this->dumpObject($res);
         return true;
     } else {
         return false;
     }
 }
 /**
  * sample_AddItem::dispatchCall()
  * 
  * Dispatch the call
  *
  * @param array $params array of parameters for the eBay API call
  * 
  * @return boolean success
  */
 public function dispatchCall($params)
 {
     $a = new ShippingServiceOptionsType();
     $a->setShippingService('UPS2ndDay');
     $a->setShippingServicePriority('1');
     $a->setShippingServiceCost('5');
     $b = new ShippingDetailsType();
     //print '<pre>'.print_r(get_class_methods($b),true).'</pre><br>';
     $b->setShippingServiceOptions($a);
     //$b->setDefaultShippingCost(5);
     $b->setShippingType('Flat');
     $req = new AddItemRequestType();
     $item = new ItemType();
     $item->setTitle($params['Title']);
     $item->setQuantity($params['Quantity']);
     $item->setCurrency($params['Currency']);
     $item->setCountry($params['Country']);
     $item->setStartPrice($params['StartPrice']);
     $item->setListingDuration($params['ListingDuration']);
     $item->setLocation($params['Location']);
     $item->setPaymentMethods($params['PaymentMethods']);
     $item->setListingType($params['ListingType']);
     $item->setDescription($params['Description']);
     $item->ShippingService = 'UPS Ground';
     $item->setShippingDetails($b);
     //print '<pre>'.print_r(get_class_methods($a),true).'</pre><br>';
     //$this->dumpObject($a);
     //$this->dumpObject($item);
     $primaryCategory = new CategoryType();
     $primaryCategory->setCategoryID($params['CategoryID']);
     $item->setPrimaryCategory($primaryCategory);
     $req->setItem($item);
     $res = $this->proxy->AddItem($req);
     $this->dumpObject($res);
     if ($this->testValid($res)) {
         $this->dumpObject($res);
         return true;
     } else {
         return false;
     }
 }
 /**
  * sample_AddItem::dispatchCall()
  * 
  * Dispatch the call
  *
  * @param array $params array of parameters for the eBay API call
  * 
  * @return boolean success
  */
 public function dispatchCall($params)
 {
     $req = new AddItemRequestType();
     $item = new ItemType();
     $item->setTitle($params['Title']);
     $item->setQuantity($params['Quantity']);
     $item->setCurrency($params['Currency']);
     $item->setCountry($params['Country']);
     $item->setStartPrice($params['StartPrice']);
     $item->setListingDuration($params['ListingDuration']);
     $item->setLocation($params['Location']);
     $item->setPaymentMethods($params['PaymentMethods']);
     $item->setListingType($params['ListingType']);
     $item->setDescription($params['Description']);
     $item->setSubTitle($params['SubTitle']);
     $item->setHitCounter($params['HitCounter']);
     $item->setListingEnhancement($params['ListingEnhancement']);
     $listingDesigner = new ListingDesignerType();
     $listingDesigner->setLayoutID($params['LayoutID']);
     $listingDesigner->setThemeID($params['ThemeID']);
     $item->setListingDesigner($listingDesigner);
     $primaryCategory = new CategoryType();
     $primaryCategory->setCategoryID($params['CategoryID']);
     $item->setPrimaryCategory($primaryCategory);
     $secondaryCategory = new CategoryType();
     $secondaryCategory->setCategoryID($params['secondaryCategoryID']);
     $item->setSecondaryCategory($secondaryCategory);
     $picture = new PictureDetailsType();
     $picture->setPictureURL($params['PictureURL']);
     $item->setPictureDetails($picture);
     $req->setItem($item);
     $res = $this->proxy->AddItem($req);
     if ($this->testValid($res)) {
         $this->dumpObject($res);
         return true;
     } else {
         return false;
     }
 }
 /**
  * sample_AddItem::dispatchCall()
  * 
  * Dispatch the call
  * 
  * @param array $params array of parameters for the eBay API call
  * 
  * @return boolean success
  */
 public function dispatchCall($params)
 {
     $reqPic = new UploadSiteHostedPicturesRequestType();
     $reqPic->setPictureData(file_get_contents("/var/www/apache2-default/playground/johann/php5/Fotolia.jpg"));
     $reqPic->setPictureSet(PictureSetCodeType::CodeType_Supersize);
     $resPic = $this->proxy->UploadSiteHostedPictures($reqPic);
     if ($this->testValid($resPic)) {
         $pictureUrl = $resPic->getSiteHostedPictureDetails()->getFullURL();
         $reqItem = new AddItemRequestType();
         $item = new ItemType();
         $item->setTitle('ipod');
         $item->setQuantity(1);
         $item->setCurrency('EUR');
         $item->setCountry('DE');
         $item->setStartPrice('5.00');
         $item->setListingDuration('Days_7');
         $item->setLocation('Cologne');
         $item->setPaymentMethods('CashOnPickup');
         $item->setListingType('Chinese');
         $item->setDescription('Neuer iPod mit Kopfhörer Ladekabel und Pc-Anschlusskabel.');
         $item->setSubTitle('Brandneuer iPod Mini!');
         $item->setHitCounter('BasicStyle');
         $item->setListingEnhancement('Highlight');
         $listingDesigner = new ListingDesignerType();
         $listingDesigner->setLayoutID('7710001');
         $listingDesigner->setThemeID('7730714');
         $item->setListingDesigner($listingDesigner);
         $primaryCategory = new CategoryType();
         $primaryCategory->setCategoryID(10610);
         $item->setPrimaryCategory($primaryCategory);
         $secondaryCategory = new CategoryType();
         $secondaryCategory->setCategoryID(8267);
         $item->setSecondaryCategory($secondaryCategory);
         $picture = new PictureDetailsType();
         $picture->setPictureURL($pictureUrl);
         $item->setPictureDetails($picture);
         $attSet = new AttributeSetType();
         $attSet->setTypeAttribute('attributeSetID', 1950);
         $att = new AttributeType();
         $att->setTypeAttribute('attributeID', 10244);
         $attValue = new ValType();
         $attValue->setValueID(10426);
         $att->setValue($attValue, 0);
         $attSet->setAttribute($att, 0);
         $atts = new AttributeSetArrayType();
         $atts->setAttributeSet($attSet, 0);
         $attSet2 = new AttributeSetType();
         $attSet2->setTypeAttribute('attributeSetID', 2136);
         $att2 = new AttributeType();
         $att2->setTypeAttribute('attributeID', 3803);
         $attValue2 = new ValType();
         $attValue2->setValueID(32040);
         $att2->setValue($attValue2, 0);
         $att3 = new AttributeType();
         $att3->setTypeAttribute('attributeID', 3806);
         $attValue3 = new ValType();
         $attValue3->setValueID(-3);
         $attValue3->setValueLiteral('siehe Artikelbeschreibung');
         $att3->setValue($attValue3, 0);
         $attSet2->setAttribute($att3, 1);
         $atts->setAttributeSet($attSet2, 1);
         $item->setAttributeSetArray($atts);
         $reqItem->setItem($item);
         $resItem = $this->proxy->AddItem($reqItem);
         if ($this->testValid($resItem)) {
             $this->dumpObject($resItem);
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
 require_once $ebatns_dir . 'EbatNs_Logger.php';
 require_once $ebatns_dir . 'VerifyAddItemRequestType.php';
 require_once $ebatns_dir . 'AddItemRequestType.php';
 require_once $ebatns_dir . 'ItemType.php';
 require_once $ebatns_dir . 'ListingEnhancementsCodeType.php';
 require_once $ebatns_dir . 'BuyerPaymentMethodCodeType.php';
 require_once $ebatns_dir . 'CountryCodeType.php';
 $session = create_ebay_session();
 if ($session) {
     $ListingEnhancementsCodeType = new BuyerPaymentMethodCodeType();
     $PaymentMethodCode = new BuyerPaymentMethodCodeType();
     $CountryCodeType = new CountryCodeType();
     $cs = new EbatNs_ServiceProxy($session);
     $item = new ItemType();
     //auction type
     $item->setListingType($auction_type_name);
     $item->Currency = DEFAULT_CURRENCY;
     //currency
     $item->Site = 'Germany';
     //site (ebay.de)
     //use sheduling if there is one
     if (isset($future_auction)) {
         $item->setScheduleTime($mynewstarttime);
     }
     //set title
     $product_title = stripcslashes($product_title);
     $product_title = striptags($product_title);
     $item->Title = $product_title;
     //set subtitle
     $product_title = stripcslashes($product_subtitle);
     $product_title = striptags($product_subtitle);
Beispiel #6
0
 function buildItem($id, $session, $reviseItem = false, $preview = false)
 {
     // fetch record from db
     $listing = ListingsModel::getItem($id);
     $post_id = $listing['post_id'];
     $profile_details = $listing['profile_data']['details'];
     $hasVariations = ProductWrapper::hasVariations($post_id);
     $isVariation = ProductWrapper::isSingleVariation($post_id);
     // remember listing id and account id for checkItem() and buildPayment()
     $this->listing_id = $id;
     $this->account_id = $listing['account_id'];
     // adjust profile details from product level options
     $profile_details = $this->adjustProfileDetails($id, $post_id, $profile_details);
     // create Item
     $item = new ItemType();
     // set quantity
     // $item->Quantity = $listing['quantity'];
     // get current quantity from WooCommerce
     $woocom_stock = ProductWrapper::getStock($post_id);
     // get max_quantity from profile
     $max_quantity = isset($profile_details['max_quantity']) && intval($profile_details['max_quantity']) > 0 ? $profile_details['max_quantity'] : PHP_INT_MAX;
     $item->Quantity = min($max_quantity, intval($woocom_stock));
     // handle fixed quantity
     if (intval($profile_details['quantity']) > 0) {
         $item->Quantity = $profile_details['quantity'];
     }
     if ($item->Quantity < 0) {
         $item->Quantity = 0;
     }
     // prevent error for negative qty
     // set listing title
     $item->Title = $this->prepareTitle($listing['auction_title']);
     // set listing duration
     $product_listing_duration = get_post_meta($post_id, '_ebay_listing_duration', true);
     $item->ListingDuration = $product_listing_duration ? $product_listing_duration : $listing['listing_duration'];
     // omit ListingType when revising item
     if (!$reviseItem) {
         $product_listing_type = get_post_meta($post_id, '_ebay_auction_type', true);
         $ListingType = $product_listing_type ? $product_listing_type : $listing['auction_type'];
         // handle classified ads
         if ($ListingType == 'ClassifiedAd') {
             $ListingType = 'LeadGeneration';
             $item->setListingSubtype2('ClassifiedAd');
         }
         $item->setListingType($ListingType);
     }
     // set eBay Site
     $item = $this->setEbaySite($item, $session);
     // add prices
     $item = $this->buildPrices($id, $item, $post_id, $profile_details, $listing);
     // add images
     $item = $this->buildImages($id, $item, $post_id, $profile_details, $session);
     // if this is a split variation, use parent post_id for all further processing
     if ($isVariation) {
         // prepare item specifics / variation attributes
         $this->prepareSplitVariation($id, $post_id, $listing);
         // use parent post_id for all further processing
         $post_id = ProductWrapper::getVariationParent($post_id);
     }
     // add various options from $profile_details
     $item = $this->buildProfileOptions($item, $profile_details);
     // add various options that depend on $profile_details and $post_id
     $item = $this->buildProductOptions($id, $item, $post_id, $profile_details, $listing, $hasVariations, $isVariation);
     // add payment and return options
     $item = $this->buildPayment($item, $profile_details);
     // add shipping services and options
     $item = $this->buildShipping($id, $item, $post_id, $profile_details, $listing, $isVariation);
     // add seller profiles
     $item = $this->buildSellerProfiles($id, $item, $post_id, $profile_details);
     // add ebay categories and store categories
     $item = $this->buildCategories($id, $item, $post_id, $profile_details);
     // add variations
     if ($hasVariations) {
         if (@$profile_details['variations_mode'] == 'flat') {
             // don't build variations - list as flat item
             $item = $this->flattenVariations($id, $item, $post_id, $profile_details);
         } else {
             // default: list as variations
             $item = $this->buildVariations($id, $item, $profile_details, $listing, $session);
         }
     }
     // add item specifics (attributes) - after variations
     $item = $this->buildItemSpecifics($id, $item, $listing, $post_id);
     // add part compatibility list
     $item = $this->buildCompatibilityList($id, $item, $listing, $post_id);
     // set listing description - after $item has been built
     $item->Description = $this->getFinalHTML($id, $item, $preview);
     // adjust item if this is a ReviseItem request
     if ($reviseItem) {
         $item = $this->adjustItemForRevision($id, $item, $profile_details, $listing);
     } else {
         $item = $this->buildSchedule($item, $profile_details);
     }
     // add UUID to prevent duplicate AddItem or RelistItem calls
     if (!$reviseItem) {
         // build UUID from listing Title, product_id, previous ItemID and today's date and hour
         $uuid_src = $item->Title . $post_id . $listing['ebay_id'] . date('Y-m-d h');
         $item->setUUID(md5($uuid_src));
         WPLE()->logger->info('UUID src: ' . $uuid_src);
     }
     // filter final item object before it's sent to eBay
     $item = apply_filters('wplister_filter_listing_item', $item, $listing, $profile_details, $post_id);
     $item = apply_filters('wple_filter_listing_item', $item, $listing, $profile_details, $post_id, $reviseItem);
     return $item;
 }