Contents
On this page

Update Currency Rules - Plugixa Multi Currency for WooCommerce

PUT /plugixa-multi-currency/v1/pro/currencies/{code}/extras

Save the Pro rules of a currency. Only the fields you send change. PUT and POST work the same way.

Needs a user with the plugixa_multi_currency_manage_settings capability (signed in with an Application Password, or the login cookie with an X-WP-Nonce header). Administrators hold it; see Capabilities.

Note. Pro only: on the free plugin this route answers 404 rest_no_route.

Request

PUT https://your-store.example/wp-json/plugixa-multi-currency/v1/pro/currencies/EUR/extras

Path parameters

Name Type Description
code string The currency’s ISO code, any case

Request body

Content type: application/json

Field Type Required Description
charm string No The price ending, for example 0.99, 9.90 or 990. Empty for none.
charm_mode string No nearest, up or down.
charm_bands object[] No Up to 10 price bands, each from (a price in this currency) and ending (empty for no ending from that price up), sorted by from.
charm_shipping boolean No Also apply the ending to shipping costs.
charm_fee boolean No Also apply the ending to fees.
gateways string[] No Payment method ids offered in this currency. Empty offers all of them.
min_order string No Smallest cart subtotal accepted in this currency, empty for none.
max_order string No Largest cart subtotal accepted in this currency, empty for none.

Amounts take a dot or a comma for decimals. A negative or zero amount, or one that is not a number, saves as empty. Unknown payment method ids are kept but match nothing: read the ids with List Payment Methods.

{
  "charm": "0.99",
  "charm_bands": [
    {
      "from": "100",
      "ending": "9"
    }
  ],
  "gateways": ["bacs", "cod"],
  "min_order": "20"
}

Responses

200 OK. data is every rule of the currency as saved.

{
  "success": true,
  "data": {
    "charm": "0.99",
    "charm_mode": "nearest",
    "charm_bands": [
      {
        "from": "100",
        "ending": "9"
      }
    ],
    "charm_shipping": false,
    "charm_fee": false,
    "gateways": ["bacs", "cod"],
    "min_order": "20",
    "max_order": ""
  }
}

Fields as in Get Currency Rules.

Errors

Status Code When
401 / 403 rest_forbidden The caller lacks the capability: Sorry, you are not allowed to do that.
404 plugixa_multi_currency_not_found The currency is not in your list: This currency is not in your list.

Plus the errors every endpoint can return.

Examples

curl -s -X PUT "https://your-store.example/wp-json/plugixa-multi-currency/v1/pro/currencies/EUR/extras" \
  -u "$WP_USER:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"charm":"0.99","charm_bands":[{"from":"100","ending":"9"}],"gateways":["bacs","cod"],"min_order":"20"}'
<?php
$ch = curl_init('https://your-store.example/wp-json/plugixa-multi-currency/v1/pro/currencies/EUR/extras');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'PUT',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS     => json_encode([
        'charm'       => '0.99',
        'charm_bands' => [
            [
                'from'   => '100',
                'ending' => '9',
            ],
        ],
        'gateways'    => ['bacs', 'cod'],
        'min_order'   => '20',
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-store.example/wp-json/plugixa-multi-currency/v1/pro/currencies/EUR/extras', {
  method: 'PUT',
  headers: {
    'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ charm: '0.99', charm_bands: [{ from: '100', ending: '9' }], gateways: ['bacs', 'cod'], min_order: '20' }),
});
const { data } = await response.json();

Quick Links

Share