Contents
On this page
Update Purchase Order - Plugixa POS for WooCommerce
PUT /plugixa-pos/v1/purchase-orders/{id}
Replace an order’s details and lines. supplier_id and lines are required every time. POST and PATCH work the same way.
Needs a user with the plugixa_pos_purchase capability (signed in with an Application Password, or the login cookie with an X-WP-Nonce header). Unlike the other capabilities, Pro gives this one to administrators and to the WooCommerce Shop manager role.
Request
PUT https://your-site.example/wp-json/plugixa-pos/v1/purchase-orders/4
Path parameters
| Name | Type | Description |
|---|---|---|
id |
integer |
The purchase order’s id |
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
supplier_id |
integer |
Yes | An active supplier. |
outlet_id |
integer |
No | The store receiving the goods. Defaults to 0, the home store. |
expected_at |
string|null |
No | Expected date, YYYY-MM-DD. |
note |
string |
No | Up to 1000 characters. |
lines |
object[] |
Yes | 1 to 500: product_id (a simple product or variation), qty and unit_cost (decimal, optional: the supplier cost otherwise). |
{
"supplier_id": 4,
"outlet_id": 1,
"note": "Monthly restock",
"lines": [
{
"product_id": 3831,
"qty": 8,
"unit_cost": "5.00"
}
]
}
Responses
200 OK. data is the order.
Errors
| Status | Code | When |
|---|---|---|
404 |
plugixa_pos_not_found |
No purchase order with that id. |
409 |
plugixa_pos_po_status |
The order cannot do that in its current state. |
422 |
plugixa_pos_invalid_line |
A line has no valid product or quantity. |
Plus the errors every endpoint can return.
Examples
curl -s -X PUT "https://your-site.example/wp-json/plugixa-pos/v1/purchase-orders/4" \
-u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"supplier_id":4,"outlet_id":1,"note":"Monthly restock","lines":[{"product_id":3831,"qty":8,"unit_cost":"5.00"}]}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-pos/v1/purchase-orders/4');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'supplier_id' => 4,
'outlet_id' => 1,
'note' => 'Monthly restock',
'lines' => [
[
'product_id' => 3831,
'qty' => 8,
'unit_cost' => '5.00',
],
],
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-pos/v1/purchase-orders/4', {
method: 'PUT',
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ supplier_id: 4, outlet_id: 1, note: 'Monthly restock', lines: [{ product_id: 3831, qty: 8, unit_cost: '5.00' }] }),
});
const { data } = await response.json();
Quick Links
Share