'customers'); if (isset($_GET['Create'])) $xml = $webService->get(array('url' => PS_SHOP_PATH.'/api/customers?schema=blank')); else $xml = $webService->get($opt); $resources = $xml->children()->children(); } catch (PrestaShopWebserviceException $e) { // Here we are dealing with errors $trace = $e->getTrace(); if ($trace[0]['args'][0] == 404) echo 'Bad ID'; else if ($trace[0]['args'][0] == 401) echo 'Bad auth key'; else echo 'Other error'; } if (count($_POST) > 0) { // Here we have XML before update, lets update XML foreach ($resources as $nodeKey => $node) { $resources->$nodeKey = $_POST[$nodeKey]; } try { $opt = array('resource' => 'customers'); if ($_GET['Create'] == 'Creating') { $opt['postXml'] = $xml->asXML(); $xml = $webService->add($opt); echo "Successfully added."; } } catch (PrestaShopWebserviceException $ex) { // Here we are dealing with errors $trace = $ex->getTrace(); if ($trace[0]['args'][0] == 404) echo 'Bad ID'; else if ($trace[0]['args'][0] == 401) echo 'Bad auth key'; else echo 'Other error
'.$ex->getMessage(); } } // We set the Title echo '

Customer\'s '; if (isset($_GET['Create'])) echo 'Creation'; else echo 'List'; echo '

'; // We set a link to go back to list if we are in creation if (isset($_GET['Create'])) echo 'Return to the list'; if (!isset($_GET['Create'])) echo ''; else echo '
'; echo ''; if (isset($resources)) { echo ''; if (count($_GET) == 0) { echo ''; foreach ($resources as $resource) { echo ''; } } else { echo ''; foreach ($resources as $key => $resource) { echo ''; } } } echo '
Id
'.$resource->attributes().'
'.$key.''; if (isset($_GET['Create'])) echo ''; echo '

'; if (isset($_GET['Create'])) echo '
'; ?>