> For the complete documentation index, see [llms.txt](https://docs.prestashop-project.org/1-5-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.prestashop-project.org/1-5-documentation/english-documentation/developer-guide/developer-tutorials/using-the-prestashop-web-service/chapter-6-creation-remote-online-form.md).

# Chapter 6 - Creation - Remote Online Form

**Objective**: A Web application to list and create a new customer.\
&#x20;**Difficulty**: \*\*

## Preparation <a href="#chapter6-creation-remoteonlineform-preparation" id="chapter6-creation-remoteonlineform-preparation"></a>

Copy the file `list_the_clients.php` from Section 3.3 to a file named `C-CRUD.php` at the root of your Web server.

The addition of resource can be likened to an upgrade from an empty element.

But how do we retrieve an XML formatted as an empty client?

In the web service, there is a method to retrieve an empty XML. It is accessible via a URL formatted as follows: `http://example.com/api/(resource name)?schema=blank`

It is possible to replace the parameter scheme value "blank" with "synopsis" in order to gain more information about the resource fields.

As we saw in Section 3.3 (List customers) it is possible make an array of parameters for "get ", "resource," and "id." It is also possible to specify only one URL this way:

```
$xml = $webService->get(array('url' => 'http://example.com/api/customers?schema=blank'));
```

Here, we get the entire XML variable from an empty client.

```
<prestashop>
  <customer>
    <id_default_group/>
etc...Beginning of the XML file retrieved:
```

We can then, thanks to the many fields we have, create an associated form.

## Getting of all fields <a href="#chapter6-creation-remoteonlineform-gettingofallfields" id="chapter6-creation-remoteonlineform-gettingofallfields"></a>

```
$resources = $xml->children()->children();
```

Path of all fields and part of the dynamic creation of form fields in a table

```
foreach ($resources as $key => $resource) {
	echo '<tr><th>' . $key . '</th><td>'; 
	echo '<input type="text" name="' . $key . '" value=""/>';
	echo '</td></tr>';
}
```

Once the data is passed in POST, we combined the data sent with the blank XML file, which is the same technique used for updating data.

```
foreach ($resources as $nodeKey => $node) {
	$resources->$nodeKey = $_POST[$nodeKey];
}
```

Calling the web service is similar to what we have seen previously:

```
$opt = array('resource' => 'customers');
$opt['postXml'] = $xml->asXML();
$xml = $webService->add($opt);
```

Now create a script that adds a client. Remember that some fields are mandatory, so do not forget to fill them out.

If you have trouble, look at the code the `3-Create.php` sample file.

When a client is created from within PrestaShop's administration interface, a confirmation e-mail is sent to the client. This cannot be done directly with the webservice: there is no way to trigger the sending of that confirmation e-mail.

However, you can create an override file for the `Customer` class and override the `addWs()` method. This method is similar to `ObjectModel::add()` but is only called from the webservice. You can find examples of its use in the `Product` and `Order` classes.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.prestashop-project.org/1-5-documentation/english-documentation/developer-guide/developer-tutorials/using-the-prestashop-web-service/chapter-6-creation-remote-online-form.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
