addInventoryPurchaseOrderItems
The method allows you to add items to an existing purchase order, or to update an existing item while the purchase order is in draft status. Entering the product with the ID and price updates the previously saved position only if all other parameters match. If any parameter differs (e.g. location), a new item will be added.
Input parameters
| order_id | int | Purchase order identifier |
| items | array | List of items to add or update. At most 1000 items with item_id can be updated at a time. Each item should contain fields listed below |
| | - item_id | int | (optional) Existing item identifier. When provided, only quantity and item_cost can be updated, at least one of them is required, and only in draft status |
| | - product_id | int | Product identifier, required when item_id is not provided |
| | - quantity | int | Item quantity, required when item_id is not provided |
| | - item_cost | decimal(10,2) | (optional) Item unit cost |
| | - supplier_code | varchar(50) | (optional) Product code from supplier |
| | - location | varchar(255) | (optional) Storage location |
| | - batch | varchar(128) | (optional) Batch number |
| | - expiry_date | text | (optional) Expiry date |
| | - serial_no | varchar(128) | (optional) Serial number |
| | - comments | varchar(255) | (optional) Item comments or notes |
Output data
The method returns the data in JSON format.
| status | varchar(30) | SUCCESS - request executed correctly ERROR - an error occurred during an API request. Error details will be described in 2 additional returned fields: error_message and error_code |
| items | array | List of created or updated order items. Each element contains fields listed below |
| | - item_id | int | Item identifier |
| | - position | int | Item position in order |
Sample
Input data:Output data:
A sample request in PHP: