This method allows to reserve a given quantity of model. Especially you can increment, decrement a quantity of a reserved model, or add a new one. If a model is not in the reservation, the method will automatically add it.
Use
Method | Url |
---|---|
POST | /restful/ghost/orders/sold/ |
Request Headers
This method works using JSON or XML format, set the following headers to choose the format you want to use:
Key | Value |
---|---|
Accept | application/xml or application/json |
Content-type | application/xml or application/json |
Request Body
The request body contains a list of the operations necessary to update the quantity of some products in the reservation. There are three kind of operation:
- lock : to ask additional quantities
- unlock : to free a model locked amount
- set : to set the total amount of locked quantities
Lock and unlock change quantities relatively, set change quantities absolutely.
These three kinds of operations can be combined in any way: you can use just one of these or all of them.
Each operation contains a list of model affected by it. Each model has two attributes:
- stock_id : the numerical id of the model
- quantity : the quantity interested by the operation
Example XML Body
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<operation type="lock">
<model stock_id="3" quantity="3"/>
<model stock_id="5" quantity="10"/>
</operation>
<operation type="unlock">
<model stock_id="69" quantity="5"/>
<model stock_id="79" quantity="8"/>
</operation>
<operation type="set">
<model stock_id="55" quantity="10"/>
<model stock_id="29" quantity="15"/>
</operation>
</root>
Example JSON Body
{
"operations": [
{
"type": "lock",
"models": [
{
"stock_id": "1567",
"quantity": "1"
},
{
"stock_id": "1578",
"quantity": "2"
}
]
},
{
"type": "unlock",
"models": [
]
},
{
"type": "set",
"models": [
]
}
]
}
Response Body
The response body contains a list of the model in the reservation. Each model has three attributes:
- stock_id : the numerical id of the model
- locked : the amount of locked quantity
- available : the amount of model still available.
Example XML Response
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root order_id="1000">
<model stock_id="3" locked="11" available="5" />
<model stock_id="5" locked="33" available="2" />
<model stock_id="29" locked="5" available="1" />
<model stock_id="55" locked="2" available="11" />
<model stock_id="120" locked="1" available="120" />
<model stock_id="133" locked="9" available="0" />
</root>
Example JSON Response
{
"models": [
{
"stock_id": "1578",
"locked": "2",
"available": "0"
},
{
"stock_id": "1567",
"locked": "1",
"available": "0"
}
],
"order_id": "0"
}
Notes
-
The maximum bookable quantity of a model depends on the available quantity. You can't exceed this quantity with a lock or set operation.
-
If the request body contains an invalid stock_id, this will not affect the other operation. You will not see an error message for invalid stock_id of a model.