Contents
Replace My Shopping List - Plugixa Recipe
PUT /plugixa-recipe/v1/frontend/shopping-list
Replace every line of the signed-in user’s own list with the lines you send.
Needs any signed-in WordPress user, a subscriber included: a visitor with an account, signed in with the site cookie and nonce or an Application Password. Needs Plugixa Recipe Pro with the Shopping Lists app on.
Note. This replaces the whole list: lines you leave out are deleted. Sending no
itemsempties it.
Request
PUT https://your-site.example/wp-json/plugixa-recipe/v1/frontend/shopping-list
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
items |
object[] |
Yes | The whole list, in order. At most 300 lines; the rest are dropped. |
items[].name |
string |
Yes | Lines without a name are skipped. Cut to 500 characters. |
items[].quantity, items[].unit |
string |
No | Cut to 50 characters each. |
items[].checked |
boolean |
No | Ticked off. |
The list is created the first time, named My shopping list, with status personal.
{
"items": [
{
"name": "flour",
"quantity": "2",
"unit": "cups",
"checked": false
},
{
"name": "lemons",
"quantity": "2",
"unit": "",
"checked": true
}
]
}
Responses
200 OK. data is the list as stored now.
{
"success": true,
"data": [
{
"name": "flour",
"quantity": "2",
"unit": "cups",
"checked": false
},
{
"name": "lemons",
"quantity": "2",
"unit": "",
"checked": true
}
]
}
| Field | Type | Meaning |
|---|---|---|
data[] |
object[] |
As in My Shopping List |
Errors
| Status | Code | When |
|---|---|---|
401 |
rest_forbidden |
The request is not signed in. |
Plus the errors every endpoint can return.
Examples
curl -s -X PUT "https://your-site.example/wp-json/plugixa-recipe/v1/frontend/shopping-list" \
-u "jane:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"items":[{"name":"flour","quantity":"2","unit":"cups","checked":false}]}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-recipe/v1/frontend/shopping-list');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => 'jane:' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'name' => 'flour',
'quantity' => '2',
'unit' => 'cups',
'checked' => false,
],
],
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const auth = 'Basic ' + btoa(`jane:${process.env.WP_APP_PASSWORD}`);
const response = await fetch('https://your-site.example/wp-json/plugixa-recipe/v1/frontend/shopping-list', {
method: 'PUT',
headers: {
'Authorization': auth,
'Content-Type': 'application/json',
},
body: JSON.stringify({"items": [{"name": "flour", "quantity": "2", "unit": "cups", "checked": false}]}),
});
const { data } = await response.json();
Quick Links
Share