private function reListItem($item) { $ShipToLocations = array(); $sql = "select id from site where name = '" . $item['Site'] . "'"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $this->configEbay($row['id']); try { $client = new eBaySOAP($this->session); $Version = $this->version; $itemArray = array(); $itemArray['ConditionID'] = 1000; if (count($item['AttributeSetArray']) > 0) { $itemArray['AttributeSetArray'] = $item['AttributeSetArray']; } if (!empty($item['BuyItNowPrice']) && $item['BuyItNowPrice'] != 0 && $itemArray['BuyItNowPrice'] > $itemArray['StartPrice']) { $itemArray['BuyItNowPrice'] = $item['BuyItNowPrice']; } $itemArray['CategoryMappingAllowed'] = true; $itemArray['Country'] = $item['Country']; $itemArray['Currency'] = $item['Currency']; $itemArray['Description'] = $item['Description']; if (!empty($item['DispatchTimeMax'])) { $itemArray['DispatchTimeMax'] = $item['DispatchTimeMax']; } $itemArray['ItemID'] = $item['ItemID']; $itemArray['ListingDuration'] = $item['ListingDuration']; if ($item['BoldTitle'] == true) { $itemArray['ListingEnhancement'][] = "BoldTitle"; } if ($item['Border'] == true) { $itemArray['ListingEnhancement'][] = "Border"; } if ($item['Featured'] == true) { $itemArray['ListingEnhancement'][] = "Featured"; } if ($item['Highlight'] == true) { $itemArray['ListingEnhancement'][] = "Highlight"; } if ($item['HomePageFeatured'] == true) { $itemArray['ListingEnhancement'][] = "HomePageFeatured"; } $itemArray['ListingType'] = $item['ListingType']; if (!empty($item['Location'])) { $itemArray['Location'] = $item['Location']; } if (empty($item['Country']) || $item['Country'] == 'CN' || $item['Country'] == 'HK') { $itemArray['Country'] = 'HK'; } $itemArray['PaymentMethods'] = $item['PaymentMethods']; $itemArray['PayPalEmailAddress'] = $item['PayPalEmailAddress']; //PictureDetails if ($item['GalleryTypeFeatured']) { $itemArray['PictureDetails']['GalleryType'] = "Featured"; } if ($item['GalleryTypeGallery']) { $itemArray['PictureDetails']['GalleryType'] = "Gallery"; } if ($item['GalleryTypePlus']) { $itemArray['PictureDetails']['GalleryType'] = "Plus"; } if (!empty($item['GalleryURL'])) { $itemArray['PictureDetails']['GalleryURL'] = $item['GalleryURL']; } if (!empty($item['PictureURL']) && is_array($item['PictureURL'])) { $i = 0; foreach ($item['PictureURL'] as $p) { $itemArray['PictureDetails']['PictureURL'][$i] = $p; $i++; } } if (!empty($item['PostalCode'])) { $itemArray['PostalCode'] = $item['PostalCode']; } $itemArray['PrimaryCategory']['CategoryID'] = $item['PrimaryCategoryCategoryID']; if ($item['Site'] != "Germany") { $itemArray['PrivateListing'] = true; } $itemArray['Quantity'] = $item['Quantity']; if (!empty($item['ReturnPolicyReturnsAcceptedOption'])) { $itemArray['ReturnPolicy']['ReturnsAcceptedOption'] = $item['ReturnPolicyReturnsAcceptedOption']; if (!empty($item['ReturnPolicyDescription'])) { $itemArray['ReturnPolicy']['Description'] = $item['ReturnPolicyDescription']; } if (!empty($item['ReturnPolicyRefundOption'])) { $itemArray['ReturnPolicy']['RefundOption'] = $item['ReturnPolicyRefundOption']; } if (!empty($item['ReturnPolicyReturnsWithinOption'])) { $itemArray['ReturnPolicy']['ReturnsWithinOption'] = $item['ReturnPolicyReturnsWithinOption']; } if (!empty($item['ReturnPolicyShippingCostPaidByOption'])) { $itemArray['ReturnPolicy']['ShippingCostPaidByOption'] = $item['ReturnPolicyShippingCostPaidByOption']; } } if (!empty($item['SecondaryCategoryCategoryID'])) { $itemArray['SecondaryCategory']['CategoryID'] = $item['SecondaryCategoryCategoryID']; } if (!empty($item['InsuranceOption'])) { $itemArray['ShippingDetails']['InsuranceDetails']['InsuranceOption'] = $item['InsuranceOption']; $itemArray['ShippingDetails']['InsuranceDetails']['InsuranceFee'] = $item['InsuranceFee']; } if (!empty($item['InternationalInsurance'])) { $itemArray['ShippingDetails']['InternationalInsuranceDetails']['InsuranceOption'] = $item['InternationalInsurance']; $itemArray['ShippingDetails']['InternationalInsuranceDetails']['InsuranceFee'] = $item['InternationalInsuranceFee']; } $itemArray['ShippingDetails']['ShippingType'] = $item['ShippingType']; if (!empty($item['ShippingServiceOptions']) && is_array($item['ShippingServiceOptions'])) { $i = 0; foreach ($item['ShippingServiceOptions'] as $s) { $itemArray['ShippingDetails']['ShippingServiceOptions'][$i]['FreeShipping'] = $s['FreeShipping']; $itemArray['ShippingDetails']['ShippingServiceOptions'][$i]['ShippingService'] = $s['ShippingService']; $itemArray['ShippingDetails']['ShippingServiceOptions'][$i]['ShippingServiceCost'] = $s['ShippingServiceCost']; $itemArray['ShippingDetails']['ShippingServiceOptions'][$i]['ShippingServiceAdditionalCost'] = $s['ShippingServiceAdditionalCost']; $itemArray['ShippingDetails']['ShippingServiceOptions'][$i]['ShippingServicePriority'] = $s['ShippingServicePriority']; $i++; } } if (!empty($item['InternationalShippingServiceOption']) && is_array($item['InternationalShippingServiceOption'])) { $j = 0; foreach ($item['InternationalShippingServiceOption'] as $i) { $itemArray['ShippingDetails']['InternationalShippingServiceOption'][$j]['ShippingService'] = $i['ShippingService']; $itemArray['ShippingDetails']['InternationalShippingServiceOption'][$j]['ShippingServiceCost'] = $i['ShippingServiceCost']; $itemArray['ShippingDetails']['InternationalShippingServiceOption'][$j]['ShippingServiceAdditionalCost'] = $i['ShippingServiceAdditionalCost']; $itemArray['ShippingDetails']['InternationalShippingServiceOption'][$j]['ShippingServicePriority'] = $i['ShippingServicePriority']; if (!empty($i['ShipToLocation'])) { if (strpos($i['ShipToLocation'], ',') != false) { //echo "test1"; $stl_array = explode(',', $i['ShipToLocation']); foreach ($stl_array as $stl) { if (!in_array($stl, $ShipToLocations)) { array_push($ShipToLocations, $stl); } } //$ShipToLocations = array_merge($ShipToLocations, explode(',', $i['ShipToLocation'])); $itemArray['ShippingDetails']['InternationalShippingServiceOption'][$j]['ShipToLocation'] = explode(',', $i['ShipToLocation']); } else { //echo "test2"; if (!in_array($i['ShipToLocation'], $ShipToLocations)) { array_push($ShipToLocations, $i['ShipToLocation']); } $itemArray['ShippingDetails']['InternationalShippingServiceOption'][$j]['ShipToLocation'] = $i['ShipToLocation']; } } $j++; } } //print_r($itemArray['ShippingDetails']['InternationalShippingServiceOption']); //exit; //ShipToLocations //$itemArray['ShipToLocations'] = "Worldwide"; if (!empty($ShipToLocations)) { $itemArray['ShipToLocations'] = $ShipToLocations; } $itemArray['BuyerResponsibleForShipping'] = false; $itemArray['ShippingTermsInDescription'] = true; $itemArray['Site'] = $item['Site']; $itemArray['SKU'] = $item['SKU']; if (!empty($item['StartPrice']) && $item['StartPrice'] != 0) { $itemArray['StartPrice'] = $item['StartPrice']; } if (!empty($item['StoreCategoryID'])) { $itemArray['Storefront']['StoreCategoryID'] = $item['StoreCategoryID']; if (!empty($item['StoreCategory2ID'])) { $itemArray['Storefront']['StoreCategory2ID'] = $item['StoreCategory2ID']; } else { $itemArray['Storefront']['StoreCategory2ID'] = 0; } } if (!empty($item['SubTitle'])) { $itemArray['SubTitle'] = $item['SubTitle']; } $itemArray['Title'] = $item['Title']; //print_r($itemArray); $params = array('Version' => $Version, 'Item' => $itemArray); $results = $client->RelistItem($params); //print_r($results); if (!empty($results->Errors)) { //$sql_0 = "update items set Status = 4 where Id = '".$item['Id']."'"; //$result_0 = mysql_query($sql_0); $this->parseEbayResponse("relist", $item, $results); if (!empty($results->ItemID)) { foreach ($results->Fees->Fee as $fee) { switch ($fee->Name) { case "InsertionFee": $InsertionFee = $fee->Fee->_; break; case "ListingFee": $ListingFee = $fee->Fee->_; break; } } $sql = "update items set ItemID = '" . $results->ItemID . "',Status='2',StartTime='" . $results->StartTime . "',\n\t\t EndTime='" . $results->EndTime . "',InsertionFee='" . $InsertionFee . "',ListingFee='" . $ListingFee . "' where Id = '" . $item['Id'] . "'"; echo $sql; $result = mysql_query($sql); $sql_1 = "select parentId from items where Id = '" . $item['Id'] . "'"; $result_1 = mysql_query($sql_1, eBayListing::$database_connect); $row_1 = mysql_fetch_assoc($result_1); $sql_2 = "update items set Relist = 'Y' where Id = " . $row_1['parentId']; $result_2 = mysql_query($sql_2, eBayListing::$database_connect); $this->log("relist", $item['Id'] . " relist success, ItemID is " . $results->ItemID); } } elseif (!empty($results->ItemID)) { foreach ($results->Fees->Fee as $fee) { switch ($fee->Name) { case "InsertionFee": $InsertionFee = $fee->Fee->_; break; case "ListingFee": $ListingFee = $fee->Fee->_; break; } } $sql = "update items set ItemID = '" . $results->ItemID . "',Status='2',StartTime='" . $results->StartTime . "',\n\t\tEndTime='" . $results->EndTime . "',InsertionFee='" . $InsertionFee . "',ListingFee='" . $ListingFee . "' where Id = '" . $item['Id'] . "'"; echo $sql; $result = mysql_query($sql); $sql_1 = "select parentId from items where Id = '" . $item['Id'] . "'"; $result_1 = mysql_query($sql_1, eBayListing::$database_connect); $row_1 = mysql_fetch_assoc($result_1); $sql_2 = "update items set Relist = 'Y' where Id = " . $row_1['parentId']; $result_2 = mysql_query($sql_2, eBayListing::$database_connect); $this->log("relist", $item['Id'] . " relist success, ItemID is " . $results->ItemID); } if (!empty($results->faultcode)) { //$sql_0 = "update items set Status = 4 where Id = '".$item['Id']."'"; //$result_0 = mysql_query($sql_0); $this->log("relist", $item['Id'] . " " . $results->faultcode . ": " . $results->faultstring, "error"); } //---------- debug -------------------------------- //print "Request: \n".$client->__getLastRequest() ."\n"; //print "Response: \n".$client->__getLastResponse()."\n"; //$this->saveFetchData("addItem-Request-".date("YmdHis").".html", print_r($results, true)); $this->saveFetchData("relistItem-Request-" . date("YmdHis") . ".xml", $client->__getLastRequest()); $this->saveFetchData("relistItem-Response-" . date("YmdHis") . ".xml", $client->__getLastResponse()); } catch (SOAPFault $f) { print $f; // error handling } }