Contents
On this page

Switch App On or Off - Plugixa Multi Currency for WooCommerce

POST /plugixa-multi-currency/v1/apps

Switch one app on or off, like the switch on its card in the App manager. An app that is off registers no screens, routes or hooks: its Pro routes answer 404 rest_no_route.

Needs manage_options: a site administrator (signed in with an Application Password, or the login cookie with an X-WP-Nonce header). Switching parts of the plugin on and off is kept for administrators on purpose.

Request

POST https://your-store.example/wp-json/plugixa-multi-currency/v1/apps

Request body

Content type: application/json

Field Type Required Description
id string Yes The app’s id, from List Apps.
enabled boolean Yes true to switch it on, false to switch it off.
{
  "id": "rates",
  "enabled": false
}

Responses

200 OK. data is the whole grid after the change.

{
  "success": true,
  "data": {
    "apps": [
      {
        "id": "rates",
        "order": 4,
        "category": "operations",
        "core": false,
        "deps": ["currencies"],
        "default": true,
        "icon": "sync",
        "label_key": "app_rates",
        "desc_key": "app_rates_desc",
        "flag": true,
        "enabled": false,
        "can_toggle": true,
        "blocker": null,
        "usage": []
      },
      "..."
    ],
    "categories": ["core", "operations", "insight", "configuration", "tools"]
  }
}

Switching off an app stops its scheduled jobs. The plugixa_multi_currency_app_toggled action runs with the id and the new state.

Errors

Status Code When
401 / 403 plugixa_multi_currency_forbidden The caller lacks the capability.
404 plugixa_multi_currency_unknown_app There is no such app.
400 plugixa_multi_currency_core_app This app is part of the core and cannot be switched off.
409 plugixa_multi_currency_app_blocked Something stops the change; the message says what
409 plugixa_multi_currency_app_dependency An app it needs is off: Switch these on first: rates, with app ids. data.deps lists them

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-store.example/wp-json/plugixa-multi-currency/v1/apps" \
  -u "$WP_USER:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"id":"rates","enabled":false}'
<?php
$ch = curl_init('https://your-store.example/wp-json/plugixa-multi-currency/v1/apps');
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([
        'id'      => 'rates',
        'enabled' => false,
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-store.example/wp-json/plugixa-multi-currency/v1/apps', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ id: 'rates', enabled: false }),
});
const { data } = await response.json();

Quick Links

Share