Actualizar cliente
Actualizar los datos de un cliente.
PUT /api/rest_admin/customers/:id
Parámetros
get
id integer | Id del cliente. |
post
{
"firstname": "Pere",
"lastname": "Monjo",
"email": "peremonjo2@example.com",
"password": "password",
"confirm": "password",
"telephone": "935555555",
"fax": "",
"newsletter": "0",
"status": "1",
"date_modified": "2021-01-15 12:00:00",
"approved": "1",
"safe": "0",
"customer_group_id": "1",
"custom_field": {
"1": "55555555T"
},
"address": [
{
"address_id": "",
"firstname": "Pere",
"lastname": "Monjo",
"company": " My Company Name",
"address_1": "Address 1",
"address_2": "Address 2",
"city": "Vilassar",
"postcode": "12345",
"country_id": "195",
"zone_id": "2979",
"default": "1"
}
]
}
firstname string | Nombre. |
lastname string | Apellidos. |
email string | Correo electrónico. |
password string | Constraseña. |
confirm string | Confirmar contraseña. |
telephone string | Número de teléfono. |
fax string | Número de fax. |
newsletter integer | Sucripción al Newsletter (1 subcribir; 0 no subcribir). |
status integer | Estado del cliente (1 activado; 0 desactivado). |
date_modified datetime | Fecha de modificación (Formato: AAAA-MM-DD hh:mm:ss). Es opcional, solo aplica si existe y si el formato es correcto. |
approved integer | Si ha sido aprobado el cliente o no (1 aprobado; 0 no aprobado). |
safe integer | Por defecto 0. |
customer_group_id | Id del grupo dónde pertence el cliente. Por defecto 1. |
custome_field | Campos personalizados. |
custome_field > 1 string | NIF/CIF. |
address | Dirección principal del cliente. |
address > address_id integer | Por defecto vacio. |
address > firstname string | Nombre. |
address > lastname string | Apellidos. |
address > company string | Nombre de la empresa. |
address > address_1 string | Primera línea de la dirección postal. |
address > address_2 string | Segunda línea de la dirección postal. |
address > city string | Ciudad. |
address > postcode string | Código postal. |
address > country_id integer | Id del país. |
address > zone_id integer | Id de la zona. |
address > default integer | Si es la dirección por defecto. Por defecto 1. |
Cabeceras HTTP
X-Sushi-Token-Id | Token de autorización. |
Respuesta
{
"success": 1,
"error": [],
"data": {
"customer_id": 8
}
}
success integer | 0 si hay error, 1 si no hay error. |
error string | Descripción del error. |
data json object | Datos de respuesta. |
customer_id integer | Id del cliente. |
Ejemplos
cURL
curl --location --request PUT 'http://sushi.loc/api/rest_admin/customers/4' \
--header 'X-Sushi-Token-Id: dk2d8rel0e8cpk7dep84t6gc44' \
--header 'Content-Type: application/json' \
--data-raw '{
"firstname": "Pere",
"lastname": "Monjo",
"email": "peremonjo@example.com",
"password": "password",
"confirm": "password",
"telephone": "933333333",
"fax": "",
"newsletter": "0",
"status": "1",
"approved": "1",
"safe": "0",
"customer_group_id": "1",
"custom_field": {
"1": "55555555T"
},
"address": [
{
"address_id": "",
"firstname": "Pere",
"lastname": "Monjo",
"company": " My Company Name",
"address_1": "Address 1",
"address_2": "Address 2 1er 2a",
"city": "Vilassar",
"postcode": "12345",
"country_id": "195",
"zone_id": "2979",
"default": "1"
}
]
}'
PHP - cURL
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://sushi.loc/api/rest_admin/customers/4",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS =>"{\n \"firstname\": \"Pere\",\n \"lastname\": \"Monjo\",\n \"email\": \"peremonjo@example.com\",\n \"password\": \"password\",\n \"confirm\": \"password\",\n \"telephone\": \"933333333\",\n \"fax\": \"\",\n \"newsletter\": \"0\",\n \"status\": \"1\",\n \"approved\": \"1\",\n \"safe\": \"0\",\n \"customer_group_id\": \"1\",\n \"custom_field\": {\n \"1\": \"55555555T\"\n },\n \"address\": [\n {\n \"address_id\": \"\",\n \"firstname\": \"Pere\",\n \"lastname\": \"Monjo\",\n \"company\": \" My Company Name\",\n \"address_1\": \"Address 1\",\n \"address_2\": \"Address 2 1er 2a\",\n \"city\": \"Vilassar\",\n \"postcode\": \"12345\",\n \"country_id\": \"195\",\n \"zone_id\": \"2979\",\n \"default\": \"1\"\n }\n ]\n}",
CURLOPT_HTTPHEADER => array(
"X-Sushi-Token-Id: dk2d8rel0e8cpk7dep84t6gc44",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;