Contents
On this page
Set Product Cost - Plugixa POS for WooCommerce
PUT /plugixa-pos/v1/product-costs/{product_id}
Set or clear a cost price. 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/product-costs/3827
Path parameters
| Name | Type | Description |
|---|---|---|
product_id |
integer |
A simple product or a variation |
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
cost |
string|null |
Yes | Decimal cost. Empty or null clears it. |
{
"cost": "1.10"
}
Responses
200 OK.
{
"success": true,
"data": {
"id": 3827,
"cost": "1.1000"
}
}
Errors
| Status | Code | When |
|---|---|---|
404 |
plugixa_pos_not_found |
No such product (variable parents are refused). |
Plus the errors every endpoint can return.
Examples
curl -s -X PUT "https://your-site.example/wp-json/plugixa-pos/v1/product-costs/3827" \
-u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"cost":"1.10"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-pos/v1/product-costs/3827');
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([
'cost' => '1.10',
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-pos/v1/product-costs/3827', {
method: 'PUT',
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ cost: '1.10' }),
});
const { data } = await response.json();
Quick Links
Share