Contents
On this page

Adjust Loyalty Points - Plugixa POS for WooCommerce

POST /plugixa-pos/v1/loyalty/{customer_id}/adjust

Correct a customer’s points by hand. The change goes to the ledger and the audit log.

Needs a user with the plugixa_pos_manage_settings 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.

Request

POST https://your-site.example/wp-json/plugixa-pos/v1/loyalty/88/adjust

Path parameters

Name Type Description
customer_id integer The customer’s user id

Request body

Content type: application/json

Field Type Required Description
points integer Yes Points to add, negative to remove.
note string Yes Why, 1 to 200 characters.
{
  "points": 500,
  "note": "Welcome bonus"
}

Responses

200 OK. data is the history, as in Get Loyalty History.

{
  "success": true,
  "data": {
    "customer_id": 88,
    "points": 9157,
    "value": "91.57",
    "value_of_100": "1.00",
    "ledger": []
  }
}

Errors

Status Code When
409 plugixa_pos_loyalty_balance Removing more points than the customer holds.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-pos/v1/loyalty/88/adjust" \
  -u "$WP_USER:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"points":500,"note":"Welcome bonus"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-pos/v1/loyalty/88/adjust');
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([
        'points' => 500,
        'note'   => 'Welcome bonus',
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-pos/v1/loyalty/88/adjust', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ points: 500, note: 'Welcome bonus' }),
});
const { data } = await response.json();

Quick Links

Share