diff --git a/autoload/api/Controllers/ProductsApiController.php b/autoload/api/Controllers/ProductsApiController.php index c204635..738a13d 100644 --- a/autoload/api/Controllers/ProductsApiController.php +++ b/autoload/api/Controllers/ProductsApiController.php @@ -497,6 +497,21 @@ class ProductsApiController $d['products_related'] = $body['products_related']; } + // Custom fields (Dodatkowe pola) + if (isset($body['custom_fields']) && is_array($body['custom_fields'])) { + $d['custom_field_name'] = []; + $d['custom_field_type'] = []; + $d['custom_field_required'] = []; + foreach ($body['custom_fields'] as $cf) { + if (!is_array($cf) || empty($cf['name'])) { + continue; + } + $d['custom_field_name'][] = (string)$cf['name']; + $d['custom_field_type'][] = isset($cf['type']) ? (string)$cf['type'] : 'text'; + $d['custom_field_required'][] = !empty($cf['is_required']) ? 1 : 0; + } + } + return $d; } } diff --git a/docs/API.md b/docs/API.md index 963de7f..5a5772b 100644 --- a/docs/API.md +++ b/docs/API.md @@ -302,11 +302,15 @@ Content-Type: application/json } }, "categories": [1, 5], - "products_related": [10, 20] + "products_related": [10, 20], + "custom_fields": [ + {"name": "Napis na koszulce", "type": "text", "is_required": 1} + ] } ``` Wymagane: `languages` (min. 1 jezyk z `name`) oraz `price_brutto`. +`custom_fields` — opcjonalne; kazdy element wymaga `name`, `type` (domyslnie `text`), `is_required` (0/1). Odpowiedz (HTTP 201): ```json diff --git a/updates/versions.php b/updates/versions.php index ac6b5c3..2f0b4de 100644 --- a/updates/versions.php +++ b/updates/versions.php @@ -1,5 +1,5 @@