> For the complete documentation index, see [llms.txt](https://rymera.gitbook.io/advanced-coupons-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rymera.gitbook.io/advanced-coupons-api/loyalty-program-v1-lpfw/settings.md).

# Settings

The admin settings API allows you to do the following:

* fetch setting sections
* fetch a section's list of fields
* &#x20;read, update and delete setting options for LPFW.

### GE&#x54;**:** /wp-json/loyalty-program/v1/settings/sections <a href="#get-wp-json-loyalty-program-v-1-dashboard" id="get-wp-json-loyalty-program-v-1-dashboard"></a>

Fetch all sections of LPFW settings.

{% tabs %}
{% tab title="Request" %}
**Requirements:**

* Logged-in user
* user role with `manage_woocommerce` user capability

| Method | Endpoint                                      |
| ------ | --------------------------------------------- |
| GET    | /wp-json/loyalty-program/v1/settings/sections |

| Request Headers | Required | Type    | Description                                                                                  |
| --------------- | -------- | ------- | -------------------------------------------------------------------------------------------- |
| ​section        | ​false   | ​string | <p>Slug of the current section.</p><p>When filled, it will preload the section's fields.</p> |
| {% endtab %}    |          |         |                                                                                              |

{% tab title="Request Example" %}
Get all sections

```
GET: http://example.com/wp-json/loyalty-program/v1/settings/sections
```

Searching for customers

```
GET: http://example.com/wp-json/loyalty-program/v1/settings/sections

Custom Headers JSON
{
    "section": "points_earning"
}
```

{% endtab %}

{% tab title="Response Example" %}
**Status: 200 OK**

Get all setting sections.

```
[
    {
        "id": "general",
        "title": "General",
        "fields": []
    },
    {
        "id": "points_earning",
        "title": "Points Earning",
        "fields": []
    },
    {
        "id": "redemption_expiry",
        "title": "Redemption Expiry",
        "fields": []
    },
    {
        "id": "role_restrictions",
        "title": "Role Restrictions",
        "fields": []
    },
    {
        "id": "help",
        "title": "Help",
        "fields": []
    }
]
```

Get all setting sections and load fields for current section

```
[
    {
        "id": "general",
        "title": "General",
        "fields": []
    },
    {
        "id": "points_earning",
        "title": "Points Earning",
        "fields": [
            {
                "title": "Points Calculation",
                "type": "subtitle"
            },
            ...fields
        ]
    },
    {
        "id": "redemption_expiry",
        "title": "Redemption Expiry",
        "fields": []
    },
    {
        "id": "role_restrictions",
        "title": "Role Restrictions",
        "fields": []
    },
    {
        "id": "help",
        "title": "Help",
        "fields": []
    }
]
```

**Status: 403 Forbidden**

```
{
    "code": "rest_forbidden_context",
    "message": "Sorry, you are not allowed access to this endpoint.",
    "data": {
        "status": 401
    }
}
```

{% endtab %}
{% endtabs %}

### GE&#x54;**:** /wp-json/loyalty-program/v1/settings/sections/{section\_id} <a href="#get-wp-json-loyalty-program-v-1-dashboard" id="get-wp-json-loyalty-program-v-1-dashboard"></a>

Get fields for a given setting section

{% tabs %}
{% tab title="Request" %}
**Requirements:**

* Logged-in user
* user role with `manage_woocommerce` user capability

| Method       | Endpoint                                                    |
| ------------ | ----------------------------------------------------------- |
| GET          | /wp-json/loyalty-program/v1/settings/sections/{section\_id} |
| {% endtab %} |                                                             |

{% tab title="Request Example" %}
Get fields for general section

```
GET: http://example.com/wp-json/loyalty-program/v1/settings/sections/general
```

{% endtab %}

{% tab title="Response Example" %}
**Status: 200 OK**

Get fields for general section

```
{
    "id": "general",
    "fields": [
        {
            "title": "Price to points earned ratio",
            "type": "price",
            "desc_tip": "Define the ratio of points earned for each ₱ spent. Example: Setting a ratio of 1 means 1 point is earned for every ₱1,00 spent. Setting a ratio 5 means 5 points are earned for every ₱1,00 spent.",
            "default": 1,
            "id": "acfw_loyalprog_cost_points_ratio",
            "value": 10
        },
        {
            "title": "Points to price redeemed ratio",
            "type": "number",
            "desc_tip": "Define the worth of each point. Example: Setting a points to price redeemed ratio of 1 means 1 point is worth ₱1,00. Setting a ratio of 10 means 10 points is worth ₱1,00.",
            "default": 10,
            "id": "acfw_loyalprog_redeem_points_ratio",
            "min": 1,
            "value": 1
        },
        {
            "title": "Points name",
            "type": "text",
            "desc_tip": "By default, points are called “Points” throughout the store. You can override the name of your points here.",
            "placeholder": "Points",
            "id": "acfw_loyalprog_points_name",
            "value": "Points"
        }
    ]
}
```

**Status: 403 Forbidden**

```
{
    "code": "rest_forbidden_context",
    "message": "Sorry, you are not allowed access to this endpoint.",
    "data": {
        "status": 401
    }
}
```

{% endtab %}
{% endtabs %}

### GE&#x54;**:** /wp-json/loyalty-program/v1/settings/{lpfw\_option\_name} <a href="#get-wp-json-loyalty-program-v-1-dashboard" id="get-wp-json-loyalty-program-v-1-dashboard"></a>

Get value for a LPFW setting option.

{% tabs %}
{% tab title="Request" %}

| Method       | Endpoint                                                  |
| ------------ | --------------------------------------------------------- |
| GET          | /wp-json/loyalty-program/v1/settings/{lpfw\_option\_name} |
| {% endtab %} |                                                           |

{% tab title="Request Example" %}
Get value for **Price to points earned ratio** setting option.

```
GET: http://example.com/wp-json/loyalty-program/v1/settings/acfw_loyalprog_cost_points_ratio
```

{% endtab %}

{% tab title="Response Example" %}
**Status: 200 OK**

Get value for **Price to points earned ratio** setting option.

```
{
    "id": "acfw_loyalprog_cost_points_ratio",
    "value": "10"
}
```

**Status: 403 Forbidden**

```
{
    "code": "rest_forbidden_context",
    "message": "Sorry, you are not allowed access to this endpoint.",
    "data": {
        "status": 401
    }
}
```

{% endtab %}
{% endtabs %}

### PU&#x54;**:** /wp-json/loyalty-program/v1/settings/{lpfw\_option\_name} <a href="#get-wp-json-loyalty-program-v-1-dashboard" id="get-wp-json-loyalty-program-v-1-dashboard"></a>

Update value of a LPFW setting option.

{% tabs %}
{% tab title="Request" %}
**Requirements:**

* Logged-in user
* user role with `manage_woocommerce` user capability

| Method | Endpoint                                                  |
| ------ | --------------------------------------------------------- |
| PUT    | /wp-json/loyalty-program/v1/settings/{lpfw\_option\_name} |

| Query Parameters | Required | Type    | Description                                                        |
| ---------------- | -------- | ------- | ------------------------------------------------------------------ |
| value            | true     | mixed   | Value to update                                                    |
| ​type            | ​false   | ​string | <p>​Format type of value.</p><p>Default as <code>string</code></p> |
| {% endtab %}     |          |         |                                                                    |

{% tab title="Request Example" %}
Get value for **Price to points earned ratio** setting option.

```
PUT: http://example.com/wp-json/loyalty-program/v1/settings/acfw_loyalprog_cost_points_ratio

JSON Body:
{
    "value": 15,
    "type": number
}
```

Update **Points calculation options** setting

```
PUT: http://example.com/wp-json/loyalty-program/v1/settings/acfw_loyalprog_points_calculation_options

JSON Body:
{
    "value": {
        "tax": "yes", 
        "shipping": "", 
        "discounts": "yes", 
        "fees": "yes"
    }, 
    "type": "points_calculation"
}
```

Update  **Spending over a threshold (breakpoints)** setting

```
PUT:http://example.com/wp-json/loyalty-program/v1/settings/acfw_loyalprog_earn_points_amount_breakpoints

JSON Body:
{
    "value": [
        {
            "amount": "10",
            "points": 10
        },
        {
            "amount": "20.50",
            "points": 20
        },
        {
            "amount": "40.60",
            "points": 40
        }
    ],
    "type": "breakpoints"
}
```

Update  **Extra points to earn during period** setting

```
PUT: http://example.com/wp-json/loyalty-program/v1/settings/acfw_loyalprog_earn_points_order_period

JSON Body:
{
    value: [
        {
            "sdate":"04/04/2021",
            "stime":"01:38 pm",
            "edate":"04/08/2021",
            "etime":"01:38 pm",
            "points":"25"
        },{
            "sdate":"04/05/2021",
            "stime":"01:38 pm",
            "edate":"04/08/2021",
            "etime":"01:38 pm",
            "points":10
        }
    ]
    type: "order_period",
}
```

{% endtab %}

{% tab title="Response Example" %}
**Status: 200 OK**

Update value of **Price to points earned ratio** setting option to `15`.

```
{
    "id": "acfw_loyalprog_cost_points_ratio",
    "value": "10"
}
```

Update **Points calculation options** setting

```
{
    "id": "acfw_loyalprog_points_calculation_options",
    "value": {
        "tax": "yes",
        "shipping": "",
        "discounts": "yes",
        "fees": "yes"
    }
}
```

Update  **Spending over a threshold (breakpoints)** setting

```
{
    "id": "acfw_loyalprog_earn_points_amount_breakpoints",
    "value": [
        {
            "amount": "10",
            "points": 10,
            "sanitized": 10
        },
        {
            "amount": "20.5",
            "points": 20,
            "sanitized": 20.5
        },
        {
            "amount": "40.6",
            "points": 40,
            "sanitized": 40.6
        }
    ]
}
```

Update  **Extra points to earn during period** setting

```
{
    "id": "acfw_loyalprog_earn_points_order_period",
    "value": [
        {
            "sdate": "04/04/2021",
            "stime": "01:38 pm",
            "edate": "04/08/2021",
            "etime": "01:38 pm",
            "points": 25
        },
        {
            "sdate": "04/05/2021",
            "stime": "01:38 pm",
            "edate": "04/08/2021",
            "etime": "01:38 pm",
            "points": 10
        }
    ]
}
```

**Status: 403 Forbidden**

```
{
    "code": "rest_forbidden_context",
    "message": "Sorry, you are not allowed access to this endpoint.",
    "data": {
        "status": 401
    }
}
```

{% endtab %}
{% endtabs %}

### DELET&#x45;**:** /wp-json/loyalty-program/v1/settings/{lpfw\_option\_name} <a href="#get-wp-json-loyalty-program-v-1-dashboard" id="get-wp-json-loyalty-program-v-1-dashboard"></a>

Update value of a LPFW setting option.

{% tabs %}
{% tab title="Request" %}
**Requirements:**

* Logged-in user
* user role with `manage_woocommerce` user capability

| Method       | Endpoint                                                  |
| ------------ | --------------------------------------------------------- |
| DELETE       | /wp-json/loyalty-program/v1/settings/{lpfw\_option\_name} |
| {% endtab %} |                                                           |

{% tab title="Request Example" %}
Get value for **Price to points earned ratio** setting option.

```
DELETE: http://example.com/wp-json/loyalty-program/v1/settings/acfw_loyalprog_cost_points_ratio

```

{% endtab %}

{% tab title="Response Example" %}
**Status: 200 OK**

Delete **Price to points earned ratio** setting option.

```
{
    "updated": true,
    "previous": {
        "id": "acfw_loyalprog_cost_points_ratio",
        "value": "10"
    }
}
```

**Status: 403 Forbidden**

```
{
    "code": "rest_forbidden_context",
    "message": "Sorry, you are not allowed access to this endpoint.",
    "data": {
        "status": 401
    }
}
```

{% endtab %}
{% endtabs %}
