user_email); $info = $this->getInfo(wp_create_nonce('aramex-shipment-check' . wp_get_current_user()->user_email)); $postArray = $this->formatPost($_POST); $post = $postArray['data']; $account = $info['clientInfo']['AccountNumber']; $trackingvalue = $post["aramex-track"]; $response = array(); //SOAP object $soapClient = new SoapClient($info['baseUrl'] . 'Tracking.wsdl', array('soap_version' => SOAP_1_1)); $aramexParams = $this->_getAuthDetails($info); $aramexParams['Transaction'] = array('Reference1' => '001'); $aramexParams['Shipments'] = array($trackingvalue); $resAramex = $soapClient->TrackShipments($aramexParams); if (is_object($resAramex) && !$resAramex->HasErrors) { $response['type'] = 'success'; if (!empty($resAramex->TrackingResults->KeyValueOfstringArrayOfTrackingResultmFAkxlpY->Value->TrackingResult)) { $response['html'] = $this->getTrackingInfoTable($resAramex->TrackingResults->KeyValueOfstringArrayOfTrackingResultmFAkxlpY->Value->TrackingResult); } else { $response['html'] = __('Unable to retrieve quotes, please check if the Tracking Number is valid or contact your administrator.', 'aramex'); } } else { $response['type'] = 'error'; foreach ($resAramex->Notifications as $notification) { $response['html'] .= '' . $notification->Code . '' . $notification->Message; } } print json_encode($response); die(); } /** * Get Client info from array * * @param $info array Client info * @return array Client info */ private function _getAuthDetails($info) { return array( 'ClientInfo' => $info['clientInfo'] ); } /** * Creates HTML code for tracking table * * @param $HAWBHistory array * @return string */ private function getTrackingInfoTable($HAWBHistory) { $checkArray = is_array($HAWBHistory); $resultTable = ''; $resultTable .= ""; if ($checkArray) { foreach ($HAWBHistory as $HAWBUpdate) { $resultTable .= ''; } } else { $resultTable .= ''; } $resultTable .= '
" . __('Location', 'aramex') . " " . __('Action Date/Time', 'aramex') . " " . __('Tracking Description', 'aramex') . " " . __('Comments', 'aramex') . "
' . $HAWBUpdate->UpdateLocation . ' ' . $HAWBUpdate->UpdateDateTime . ' ' . $HAWBUpdate->UpdateDescription . ' ' . $HAWBUpdate->Comments . '
' . $HAWBHistory->UpdateLocation . ' ' . $HAWBHistory->UpdateDateTime . ' ' . $HAWBHistory->UpdateDescription . ' ' . $HAWBHistory->Comments . '
'; return $resultTable; } }