Contents
On this page
Create Pricing Rule - Plugixa Car Rental
POST /plugixa-car-rental/v1/pricing-rules
Create a pricing rule.
Needs Plugixa Car Rental Pro with the Pricing rules app on. The user needs the plugixa_car_rental_create capability.
Request
POST https://your-site.example/wp-json/plugixa-car-rental/v1/pricing-rules
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
name |
string |
Yes | Must not be blank. Customers see it on the price line. Up to 100 characters. |
amount |
number |
Yes | For percent, -100 to 1000 and not 0 (15 adds 15%). For fixed, not 0: added to each day, negative to take off. For set, the day’s new price, not negative. Rounded to 2 decimals. |
adjustment |
string |
No | percent (the default), fixed or set. |
priority |
integer |
No | 0 to 9999, lowest runs first. Defaults to 10. |
stop |
boolean |
No | Skip later rules on a day this one applies to. Defaults to false. |
conditions |
object |
No | When the rule applies; every condition set must be true. Omitted: every rental, every day. |
conditions.model_ids |
integer[] |
No | Only these vehicle models. Empty: all. |
conditions.location_ids |
integer[] |
No | Only rentals picked up at these locations. Empty: all. |
conditions.date_from |
string |
No | First day, YYYY-MM-DD. Each rental day is checked on its own. |
conditions.date_to |
string |
No | Last day, YYYY-MM-DD, on or after date_from. |
conditions.weekdays |
integer[] |
No | Days of the week, 1 Monday to 7 Sunday. Empty: every day. |
conditions.min_days |
integer |
No | Shortest rental, in days. 0 for no minimum. |
conditions.max_days |
integer |
No | Longest rental. 0 for no maximum, else at least min_days. |
conditions.min_lead_days |
integer |
No | Booked at least this many days before pickup. 0 for no minimum. |
conditions.max_lead_days |
integer |
No | Booked at most this many days before pickup. 0 for no maximum, else at least min_lead_days. |
status |
string |
No | published (the default) or unpublished. |
Day counts in conditions are capped at 1000, and values that are not ids, dates or numbers are dropped rather than refused.
{
"name": "Weekend in Paris",
"priority": 10,
"adjustment": "percent",
"amount": 15,
"conditions": {
"location_ids": [
1
],
"weekdays": [
6,
7
]
}
}
Responses
201 Created. data is the new pricing rule.
{
"success": true,
"data": {
"id": 3,
"name": "Weekend in Paris",
"priority": 10,
"adjustment": "percent",
"amount": 15.0,
"stop": false,
"conditions": {
"model_ids": [],
"location_ids": [
1
],
"date_from": "",
"date_to": "",
"weekdays": [
6,
7
],
"min_days": 0,
"max_days": 0,
"min_lead_days": 0,
"max_lead_days": 0
},
"status": "published",
"created_by": 1,
"modified_by": 1,
"created_at": "2026-11-12 09:30:00",
"modified_at": "2026-11-12 09:30:00",
"deleted_at": null
}
}
| Field | Type | Meaning |
|---|---|---|
data.id |
integer |
The rule’s id |
data.name |
string |
Shown to customers on the price line it adds |
data.priority |
integer |
Rules run lowest first, 0 to 9999 |
data.adjustment |
string |
percent, fixed or set |
data.amount |
number |
Percentage, amount added per day, or the day’s new price |
data.stop |
boolean |
Whether later rules are skipped on a day this rule applies to |
data.conditions |
object |
When the rule applies. See the request body |
data.status |
string |
published or unpublished. Only a published rule applies |
data.created_at |
string |
UTC datetime the record was created |
data.modified_at |
string |
UTC datetime of the last change. Send it back on an update to be warned of a conflicting edit |
data.deleted_at |
string|null |
null unless the record is in the trash |
Errors
| Status | Code | When |
|---|---|---|
422 |
plugixa_car_rental_invalid |
name is blank, amount does not suit adjustment, a date or day range in conditions is the wrong way round, or conditions names a model or location that does not exist. data.field names the field, for example conditions.date_to. |
422 |
plugixa_car_rental_invalid_choice |
status or adjustment is not one of its values. data.allowed lists them. |
422 |
plugixa_car_rental_not_a_number |
A number field was sent as something else. data.field names it. |
422 |
plugixa_car_rental_negative_number |
priority is negative. |
422 |
plugixa_car_rental_too_long |
A text field is longer than its column. data.field names it and data.max gives the limit. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-car-rental/v1/pricing-rules" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"name":"Weekend in Paris","priority":10,"adjustment":"percent","amount":15,"conditions":{"location_ids":[1],"weekdays":[6,7]}}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-car-rental/v1/pricing-rules');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => 'admin:' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Weekend in Paris',
'priority' => 10,
'adjustment' => 'percent',
'amount' => 15,
'conditions' => [
'location_ids' => [1],
'weekdays' => [6, 7],
],
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const auth = Buffer.from(`admin:${process.env.WP_APP_PASSWORD}`).toString('base64');
const response = await fetch('https://your-site.example/wp-json/plugixa-car-rental/v1/pricing-rules', {
method: 'POST',
headers: {
'Authorization': `Basic ${auth}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Weekend in Paris',
priority: 10,
adjustment: 'percent',
amount: 15,
conditions: { location_ids: [1], weekdays: [6, 7] },
}),
});
const { data } = await response.json();
Quick Links
Share