Contents
On this page

Set Option Stock - Plugixa Extra Product Options

PUT /plugixa-epo/v1/stock/{id}

Set how many of one choice are left. It applies at once: stock is not part of the draft, so there is nothing to publish. PATCH and POST work the same.

Needs a user with the plugixa_epo_manage capability (signed in with an Application Password, or the login cookie with an X-WP-Nonce header). Administrators and shop managers hold it; see Permissions. Pro only: on the free plugin this route answers 404 rest_no_route.

Request

PUT https://your-store.example/wp-json/plugixa-epo/v1/stock/7

Path parameters

Name Type Description
id integer The group’s id

Request body

Content type: application/json

Field Type Required Description
field string Yes The field’s id.
option string Yes The choice’s id.
quantity integer No How many are left, 0 to 999999. null or left out: stop tracking (unlimited).
{
  "field": "fk3q8x2ma",
  "option": "op7r2v9tc",
  "quantity": 12
}

Responses

200 OK. data is the group’s stock, as in Get Option Stock.

{
  "success": true,
  "data": {
    "fk3q8x2ma": {
      "op7r2v9tc": 12
    }
  }
}

Errors

Status Code When
401 / 403 plugixa_epo_forbidden The caller lacks the capability: You are not allowed to do that.
404 plugixa_epo_not_found No group has this id: Not found.
400 plugixa_epo_invalid field or option is missing: Choose an option first.

Plus the errors every endpoint can return.

Examples

curl -s -X PUT "https://your-store.example/wp-json/plugixa-epo/v1/stock/7" \
  -u "$WP_USER:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"field":"fk3q8x2ma","option":"op7r2v9tc","quantity":12}'
<?php
$ch = curl_init('https://your-store.example/wp-json/plugixa-epo/v1/stock/7');
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([
        'field'    => 'fk3q8x2ma',
        'option'   => 'op7r2v9tc',
        'quantity' => 12,
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-store.example/wp-json/plugixa-epo/v1/stock/7', {
  method: 'PUT',
  headers: {
    'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ field: 'fk3q8x2ma', option: 'op7r2v9tc', quantity: 12 }),
});
const { data } = await response.json();

Quick Links

Share