Answer the question
In order to leave comments, you need to log in
How to display status history in measoft api?
Good afternoon!
I'm trying to track an order using api wiki.courierexe.ru/,
I'm using
an example of calling a service in PHP.
I create a function
public function tracking($orderno){
$results = $this->sendRequest($this->makeXML('statusreq', ['orderno' => $orderno]));
$attrsStatusHistory = $results->order->statushistory->status->attributes();
$order = array();
foreach ($results as $result) {
$order = array(
'order' => array(
'orderno' => $orderno,
'weight' => (string)$result->weight,
'price' => (string)$result->price,
'barcode' => (string)$result->barcode,
'return' => (string)$result->return,
'quantity' => (string)$result->quantity,
'paytype' => (string)$result->paytype,
'print_check' => (string)$result->print_check,
'service' => (string)$result->service,
'return_service' => (string)$result->return_service,
'type' => (string)$result->type,
'return_type' => (string)$result->return_type,
'waittime' => (string)$result->waittime,
'inshprice' => (string)$result->inshprice,
'receiverpays' => (string)$result->receiverpays,
'status' => (string)$result->status,
'customstatecode' => (string)$result->customstatecode,
'deliveredto' => (string)$result->deliveredto,
'delivereddate' => (string)$result->delivereddate,
'deliveredtime' => (string)$result->deliveredtime,
'sender' => array(
'company' => (string)$result->sender->company,
'person' => (string)$result->sender->person,
'phone' => (string)$result->sender->phone,
'town' => (string)$result->sender->town,
'address' => (string)$result->sender->address,
'date' => (string)$result->sender->date,
'time_min' => (string)$result->sender->time_min,
'time_max' => (string)$result->sender->time_max,
'contacts' => array(
'phone' => (string)$result->sender->contacts->phone,
'email' => (string)$result->sender->contacts->email
),
),
'receiver' => array(
'company' => (string)$result->receiver->company,
'person' => (string)$result->receiver->person,
'phone' => (string)$result->receiver->phone,
'zipcode' => (string)$result->receiver->zipcode,
'town' => (string)$result->receiver->town,
'address' => (string)$result->receiver->address,
'date' => (string)$result->receiver->date,
'time_min' => (string)$result->receiver->time_min,
'time_max' => (string)$result->receiver->time_max,
'contacts' => array(
'phone' => (string)$result->receiver->contacts->phone,
'email' => (string)$result->receiver->contacts->email
),
),
'statushistory' => array(
'status' => array(
'eventstore' => $attrsStatusHistory['eventstore'],
'eventtime' => $attrsStatusHistory['eventtime'],
'createtimegmt' => $attrsStatusHistory['createtimegmt'],
'title' => $attrsStatusHistory['title']
),
),
),
);
}
return $order;
}
Array
(
[order] => Array
(
[orderno] => ks_nata_3683
[weight] => 0.1
[price] => 25180.00
[barcode] => 000308041
[return] => NO
[quantity] => 1
[paytype] => CASH
[print_check] => YES
[service] => 1
[return_service] => 1
[type] => 1
[return_type] => 1
[waittime] => 0
[inshprice] => 0.00
[receiverpays] => NO
[status] => COMPLETE
[customstatecode] => 1
[deliveredto] => досавлено
[delivereddate] => 2020-03-03
[deliveredtime] => 15:40:00
[sender] => Array
(
[company] => ТЕСТМ
[person] => Мария
[phone] => 79873936436
[town] => Москва город
[address] => Красная площадь, 1
[date] =>
[time_min] =>
[time_max] =>
[contacts] => Array
(
[phone] => +79873936436
[email] =>
)
)
[receiver] => Array
(
[company] => Test-name gsdf
[person] => Test-name gsdf
[phone] => 1234567890
[zipcode] => 141018
[town] => Санкт-Петербург город
[address] => Лебединая ул.
[date] => 2020-03-03
[time_min] => 10:00:00
[time_max] => 18:00:00
[contacts] => Array
(
[phone] => +71234567890
[email] =>
)
)
[statushistory] => Array
(
[status] => Array
(
[eventstore] => SimpleXMLElement Object
(
[0] => Web-службы
)
[eventtime] => SimpleXMLElement Object
(
[0] => 2020-03-03 15:11:10
)
[createtimegmt] => SimpleXMLElement Object
(
[0] => 2020-03-03 12:11:10
)
[title] => SimpleXMLElement Object
(
[0] => Новый
)
)
)
)
)
Answer the question
In order to leave comments, you need to log in
foreach ($results as $result)
{
//получаем массив со списком статусов для заказа
$statushistory = array();
foreach($result->statushistory[0] as $child)
{
$attrsStatusHistory = $child->attributes();
$status = array(
'eventstore' => (string)$attrsStatusHistory['eventstore'],
'eventtime' => (string)$attrsStatusHistory['eventtime'],
'createtimegmt' => (string)$attrsStatusHistory['createtimegmt'],
'title' => (string)$attrsStatusHistory['title']
);
$statushistory[] = $status;
}
$order = array(
// ... код как у вас был
'statushistory' => $statushistory,
);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question