Contents
Price Cart - Plugixa POS for WooCommerce
POST /plugixa-pos/v1/orders/quote
Ask the server what a cart comes to, with the same pricing, taxes, coupons and promotions as a real sale. Nothing is kept: the order is built and rolled back. The register calls this when coupons or server-side rules are involved.
Needs a user with the plugixa_pos_sell capability (signed in with an Application Password, or the login cookie with an X-WP-Nonce header). Administrators hold it; other roles only when you grant it. The user must also be allowed to use the register (register access).
Note. This route is not the Pro Quotes feature (printed price quotes): see Create Quote.
Request
POST https://your-site.example/wp-json/plugixa-pos/v1/orders/quote
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
register_id |
integer |
Yes | The register. |
customer_id |
integer |
No | The customer, for customer-based rules. Defaults to 0. |
cart_discount |
object|null |
No | Discount on the whole cart: type and value as for a line discount. |
coupons |
string[] |
No | WooCommerce coupon codes, up to 10. |
lines |
object[] |
Yes | 1 to 500 lines. Each line: |
lines[].product_id |
integer |
Yes | The product. 0 with custom for a custom item. |
lines[].variation_id |
integer |
No | The variation of a variable product. |
lines[].qty |
integer |
Yes | 1 to 100000. |
lines[].discount |
object|null |
No | Line discount: type percent (whole percent) or fixed (minor units for the whole line, 500 is 5.00), and value. |
lines[].custom |
object|null |
No | A custom item: name (1 to 120 characters), price (decimal string), tax_class (slug, optional). Needs plugixa_pos_discount. |
lines[].note |
string |
No | Line note, up to 200 characters. |
lines[].options |
string[] |
No | Modifier option keys PRO, up to 50. |
lines[].serials |
string[] |
No | Serial numbers sold PRO. |
lines[].label_code |
string |
No | A scale label code, 8 to 14 digits PRO. |
lines[].ref |
string |
No | A reference set by Pro features, such as a quote line (quote:12:0). |
{
"register_id": 1,
"customer_id": 88,
"coupons": [],
"lines": [
{
"product_id": 3800,
"variation_id": 3801,
"qty": 1
},
{
"product_id": 3835,
"qty": 1
}
]
}
Responses
200 OK. data is the priced cart.
{
"success": true,
"data": {
"total": "29.00",
"tax_total": "4.83",
"discount_total": "0.00",
"coupons": []
}
}
| Field | Type | Meaning |
|---|---|---|
data.total |
string |
Total to pay |
data.tax_total |
string |
Tax in it |
data.discount_total |
string |
All discounts, tax included |
data.coupons |
object[] |
code and discount per coupon applied |
Errors
| Status | Code | When |
|---|---|---|
404 |
plugixa_pos_no_register |
No register with that id. |
403 |
plugixa_pos_register_forbidden |
The register is missing or archived, or the user may not use it. |
409 |
plugixa_pos_line_invalid |
A line cannot be sold (unknown product, not purchasable…). data.line is its index. |
409 |
plugixa_pos_out_of_stock |
Not enough stock for a line. data.line is its index. |
422 |
plugixa_pos_coupon_and_discount |
A coupon is combined with a register discount. |
500 |
plugixa_pos_quote_failed |
The cart could not be priced. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-pos/v1/orders/quote" \
-u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"register_id":1,"customer_id":88,"coupons":[],"lines":[{"product_id":3800,"variation_id":3801,"qty":1},{"product_id":3835,"qty":1}]}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-pos/v1/orders/quote');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'register_id' => 1,
'customer_id' => 88,
'coupons' => [],
'lines' => [
[
'product_id' => 3800,
'variation_id' => 3801,
'qty' => 1,
],
[
'product_id' => 3835,
'qty' => 1,
],
],
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-pos/v1/orders/quote', {
method: 'POST',
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ register_id: 1, customer_id: 88, coupons: [], lines: [{ product_id: 3800, variation_id: 3801, qty: 1 }, { product_id: 3835, qty: 1 }] }),
});
const { data } = await response.json();
Quick Links
Share