Tradera.com logotype

Tradera Developer Program

OrderService

Documentation Version 3 > OrderService > GetSellerOrders

GetSellerOrders |WebMethod|

Returns all orders that have taken place within the specified constraints. The seller in this case is the user for which the call is made for.

Parameters
  1. request, Holds request information for this call, see GetSellerOrdersRequest for detailed information.
Returns

Array of found SellerOrder objects

Code Example

The following is a code example in PHP. It prints all order information.

  1:
  2:
  3:
  4:
  5:
  6:
  7:
  8:
  9:
 10:
 11:
 12:
 13:
 14:
 15:
 16:
 17:
 18:
 19:
 20:
 21:
 22:
 23:
 24:
 25:
 26:
 27:
 28:
 29:
 30:
 31:
 32:
 33:
 34:
 35:
 36:
 37:
 38:
 39:
 40:
 41:
 42:
 43:
 44:
 45:
 46:
 47:
 48:
 49:
 50:
 51:
 52:
 53:
 54:
 55:
 56:
 57:
 58:
 59:
 60:
 61:
 62:
 63:
 64:
 65:
 66:
 67:
 68:
 69:
 70:
 71:
 72:
 73:
 74:
 75:
 76:
 77:
 78:
 79:
 80:
 81:
 82:
 83:
 84:
 85:
 86:
 87:
 88:
 89:
 90:
 91:
 92:
 93:
 94:
 95:
 96:
 97:
 98:
 99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
////////////////////////////////////////
// helper functions
////////////////////////////////////////

function ItemToString($item){
	echo '  Item Id: ' . $item -> ItemId . PHP_EOL
	. '  Title: ' . $item -> Title . PHP_EOL
	. '  Quantity: ' . $item -> Quantity . PHP_EOL
	. '  UnitPrice: ' . $item -> UnitPrice . PHP_EOL
	. '  VAT: ' . $item -> VatRate . PHP_EOL . PHP_EOL;
}
function ItemsToString($items){
	$itemsString = 'Items:' . PHP_EOL;
	if(is_array($items)){
		foreach ($items as $item) {
			$itemsString = $itemsString . ItemToString($item);
		}
	}
	else {
		$itemsString = $itemsString . ItemToString($items);
	}
	return $itemsString;
}

function PrintOrder($order, $paid = true){
	$paymentInfo = null;
	if ($paid){
		$paymentInfo = 	'Payment info:' . PHP_EOL
		. '   -' . $order -> SellerOrderPayments -> SellerOrderPayment -> PaymentType . PHP_EOL
		. '   -' . $order -> SellerOrderPayments -> SellerOrderPayment -> Reference . PHP_EOL
		. '   -' . $order -> SellerOrderPayments -> SellerOrderPayment -> Amount . PHP_EOL
		. '   -' . $order -> SellerOrderPayments -> SellerOrderPayment -> PaidDate . PHP_EOL
		. '   -' . $order -> SellerOrderPayments -> SellerOrderPayment -> PaymentCost . PHP_EOL;
	}

	echo 'Order #' . $order -> OrderId . PHP_EOL
	. 'Created: ' . $order -> CreatedDate . PHP_EOL
	. 'Subtotal (VAT incl): ' . $order -> SubTotal . PHP_EOL
	. 'Shipping type: ' . $order -> ShippingType . PHP_EOL
	. 'Shipping cost (VAT incl): ' . $order -> ShippingCost . PHP_EOL
	. $paymentInfo
	. 'Items:' . PHP_EOL . ItemsToString($order -> Items -> SellerOrderItem) . PHP_EOL
	. 'Buyer:' . PHP_EOL
	. '  UserId: : ' . $order -> Buyer -> UserId . PHP_EOL
	. '  First Name: : ' . $order -> Buyer -> FirstName . PHP_EOL
	. '  Last Name: ' . $order -> Buyer -> LastName . PHP_EOL
	. '  AddressLine1: ' . $order -> Buyer -> AddressLine1 . PHP_EOL
	. '  ZipCode: ' . $order -> Buyer -> ZipCode . PHP_EOL
	. '  City: ' . $order -> Buyer -> City . PHP_EOL
	. '  Country: ' . $order -> Buyer -> CountryName . PHP_EOL
	. '  E-mail: ' . $order -> Buyer -> Email . PHP_EOL
	. '  Phone: ' . $order -> Buyer -> Phone . PHP_EOL
	. '  User alias: ' . $order -> Buyer -> Alias . PHP_EOL
	. 'Shipping address:' . PHP_EOL
	. '   -' . $order -> ShipTo -> Name . PHP_EOL
	. '   -' . $order -> ShipTo -> AddressLine1 . PHP_EOL
	. '   -' . $order -> ShipTo -> ZipCode . PHP_EOL
	. '   -' . $order -> ShipTo -> City . PHP_EOL
	. '   -' . $order -> ShipTo -> CountryName . PHP_EOL . PHP_EOL;
}

function HandleOrders($orders){
	if (is_array($orders)) {
		echo '=============================================' . PHP_EOL
		.'===============  Paid Orders ================' . PHP_EOL;
		foreach ($orders as $order) {
			if(isset($order -> SellerOrderPayments -> SellerOrderPayment)){
				PrintOrder($order);
				echo '=============================================' . PHP_EOL;
			}
		}
		echo '=============================================' . PHP_EOL
		.'=============== Unpaid Orders ===============' . PHP_EOL;
		foreach ($orders as $order) {
			if(!isset($order -> SellerOrderPayments -> SellerOrderPayment)){
				PrintOrder($order, false);
				echo '=============================================' . PHP_EOL;
			}
		}
	}
	else {
		echo '=============================================' . PHP_EOL;
	 	if(isset($orders -> SellerOrderPayments -> SellerOrderPayment)){
		echo '===============  Paid Order  ================' . PHP_EOL;
		}
		else {
		echo '=============== Unpaid Order ================' . PHP_EOL;

		}
		PrintOrder($orders, isset($orders -> SellerOrderPayments -> SellerOrderPayment));
		echo '=============================================' . PHP_EOL;
	}
}


///////////////////////////////////////////////
// Method call
///////////////////////////////////////////////
try {

	// Replace the following variables with your own key management
	// $APPLICATION_KEY
	// $TOKEN
	// $USER_ID
	// $APPLICATION_ID
	$appId = $APPLICATION_ID;
	$userId = $USER_ID;
	$token = $TOKEN;
	$appKey = $APPLICATION_KEY;
	$orderServiceUrl = 'https://api.tradera.com/v3/OrderService.asmx';

	$orderServiceUrlWithAuth = $orderServiceUrl
					. '?appId=' . $appId
					. '&appKey=' . $appKey
					. '&userId=' . $userId
					. '&token=' . $token;

	$orderClient = new SoapClient(
		$orderServiceUrl . '?WSDL',
		array('location' => $orderServiceUrlWithAuth)
	);
	// The dates for which we want to get orders
	$fromDate = mktime(15, 0, 0, 12, 24, 2015);
	$toDate = null; // All dates after from date

	$getSellerOrdersRequest = new StdClass();
	$getSellerOrdersRequest -> FromDate = $fromDate;
	$getSellerOrdersRequest -> ToDate = $toDate;
	$getSellerOrdersRequest -> QueryDateMode = 'LastUpdatedDate';


	$getSellerOrdersParams = new StdClass();
	$getSellerOrdersParams -> request = $getSellerOrdersRequest;


	echo 'Getting orders for time span: ';
	echo (isset($fromDate) ? date('c', $fromDate) : 'start of time');
	echo ' to ';
	echo (isset($toDate) ? date('c', $toDate) : 'end of time') . PHP_EOL;

	// Make Soap call
	$getSellerOrdersResponse = $orderClient->GetSellerOrders($getSellerOrdersParams);

	// Handle result
	if(!isset($getSellerOrdersResponse -> GetSellerOrdersResult -> SellerOrders -> SellerOrder)) {
		echo 'No orders in time span' . PHP_EOL;
	}
	else{
		$sellerOrders = $getSellerOrdersResponse -> GetSellerOrdersResult -> SellerOrders -> SellerOrder;
		HandleOrders($sellerOrders);
	}


}
catch(SoapFault $soapFault) {
	echo 'Error: ' . $soapFault->faultstring;
}

SOAP 1.1

The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.

POST /v3/OrderService.asmx HTTP/1.1
Host: api.tradera.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://api.tradera.com/GetSellerOrders"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <AuthenticationHeader xmlns="http://api.tradera.com">
      <AppId>int</AppId>
      <AppKey>string</AppKey>
    </AuthenticationHeader>
    <AuthorizationHeader xmlns="http://api.tradera.com">
      <UserId>int</UserId>
      <Token>string</Token>
    </AuthorizationHeader>
    <ConfigurationHeader xmlns="http://api.tradera.com">
      <Sandbox>int</Sandbox>
      <MaxResultAge>int</MaxResultAge>
    </ConfigurationHeader>
  </soap:Header>
  <soap:Body>
    <GetSellerOrders xmlns="http://api.tradera.com">
      <request>
        <FromDate>dateTime</FromDate>
        <ToDate>dateTime</ToDate>
        <QueryDateMode>CreatedDate or LastUpdatedDate</QueryDateMode>
      </request>
    </GetSellerOrders>
  </soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetSellerOrdersResponse xmlns="http://api.tradera.com">
      <GetSellerOrdersResult>
        <SellerOrders>
          <SellerOrder>
            <OrderId>int</OrderId>
            <CreatedDate>dateTime</CreatedDate>
            <LastUpdatedDate>dateTime</LastUpdatedDate>
            <SubTotal>int</SubTotal>
            <Seller xsi:nil="true" />
            <Buyer xsi:nil="true" />
            <ShipTo xsi:nil="true" />
            <Items xsi:nil="true" />
            <SellerOrderPayments xsi:nil="true" />
            <ShippingType>string</ShippingType>
            <ShippingCost>int</ShippingCost>
          </SellerOrder>
          <SellerOrder>
            <OrderId>int</OrderId>
            <CreatedDate>dateTime</CreatedDate>
            <LastUpdatedDate>dateTime</LastUpdatedDate>
            <SubTotal>int</SubTotal>
            <Seller xsi:nil="true" />
            <Buyer xsi:nil="true" />
            <ShipTo xsi:nil="true" />
            <Items xsi:nil="true" />
            <SellerOrderPayments xsi:nil="true" />
            <ShippingType>string</ShippingType>
            <ShippingCost>int</ShippingCost>
          </SellerOrder>
        </SellerOrders>
      </GetSellerOrdersResult>
    </GetSellerOrdersResponse>
  </soap:Body>
</soap:Envelope>

SOAP 1.2

The following is a sample SOAP 1.2 request and response. The placeholders shown need to be replaced with actual values.

POST /v3/OrderService.asmx HTTP/1.1
Host: api.tradera.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Header>
    <AuthenticationHeader xmlns="http://api.tradera.com">
      <AppId>int</AppId>
      <AppKey>string</AppKey>
    </AuthenticationHeader>
    <AuthorizationHeader xmlns="http://api.tradera.com">
      <UserId>int</UserId>
      <Token>string</Token>
    </AuthorizationHeader>
    <ConfigurationHeader xmlns="http://api.tradera.com">
      <Sandbox>int</Sandbox>
      <MaxResultAge>int</MaxResultAge>
    </ConfigurationHeader>
  </soap12:Header>
  <soap12:Body>
    <GetSellerOrders xmlns="http://api.tradera.com">
      <request>
        <FromDate>dateTime</FromDate>
        <ToDate>dateTime</ToDate>
        <QueryDateMode>CreatedDate or LastUpdatedDate</QueryDateMode>
      </request>
    </GetSellerOrders>
  </soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <GetSellerOrdersResponse xmlns="http://api.tradera.com">
      <GetSellerOrdersResult>
        <SellerOrders>
          <SellerOrder>
            <OrderId>int</OrderId>
            <CreatedDate>dateTime</CreatedDate>
            <LastUpdatedDate>dateTime</LastUpdatedDate>
            <SubTotal>int</SubTotal>
            <Seller xsi:nil="true" />
            <Buyer xsi:nil="true" />
            <ShipTo xsi:nil="true" />
            <Items xsi:nil="true" />
            <SellerOrderPayments xsi:nil="true" />
            <ShippingType>string</ShippingType>
            <ShippingCost>int</ShippingCost>
          </SellerOrder>
          <SellerOrder>
            <OrderId>int</OrderId>
            <CreatedDate>dateTime</CreatedDate>
            <LastUpdatedDate>dateTime</LastUpdatedDate>
            <SubTotal>int</SubTotal>
            <Seller xsi:nil="true" />
            <Buyer xsi:nil="true" />
            <ShipTo xsi:nil="true" />
            <Items xsi:nil="true" />
            <SellerOrderPayments xsi:nil="true" />
            <ShippingType>string</ShippingType>
            <ShippingCost>int</ShippingCost>
          </SellerOrder>
        </SellerOrders>
      </GetSellerOrdersResult>
    </GetSellerOrdersResponse>
  </soap12:Body>
</soap12:Envelope>

XHTML CSS