Contents
On this page
Get Product Prices - Plugixa Multi Currency for WooCommerce
GET /plugixa-multi-currency/v1/public/prices
The price HTML of products in one currency, exactly as the shop would print it, sale prices included. In cache-first mode the shop page is cached in the store currency and the browser swaps the prices in from this route. See Cache-first mode.
Public: no sign-in. The route protects itself instead, as described below. Each address can make 600 requests an hour. Only published, visible products are answered.
Note. Pro only: on the free plugin this route answers
404rest_no_route.
Request
GET https://your-store.example/wp-json/plugixa-multi-currency/v1/public/prices?currency=EUR&ids=23,24
Query parameters
| Field | Type | Required | Description |
|---|---|---|---|
currency |
string |
Yes | The code of an enabled currency. |
ids |
string |
Yes | Product or variation ids, comma separated. The first 100 are used. |
Responses
200 OK. data.prices maps each product id to its price HTML.
{
"success": true,
"data": {
"currency": "EUR",
"prices": {
"23": "<span class=\"woocommerce-Price-amount amount\"><bdi>13,79 <span class=\"woocommerce-Price-currencySymbol\" translate=\"no\" dir=\"auto\">€</span></bdi></span>",
"24": "<del aria-hidden=\"true\"><span class=\"woocommerce-Price-amount amount\"><bdi>2,76 <span class=\"woocommerce-Price-currencySymbol\" translate=\"no\" dir=\"auto\">€</span></bdi></span></del> <span class=\"screen-reader-text\">Original price was: 2,76 €.</span><ins aria-hidden=\"true\"><span class=\"woocommerce-Price-amount amount\"><bdi>1,84 <span class=\"woocommerce-Price-currencySymbol\" translate=\"no\" dir=\"auto\">€</span></bdi></span></ins><span class=\"screen-reader-text\">Current price is: 1,84 €.</span>"
}
}
}
Ids that are not found, not published or hidden from the catalogue are left out. The answer is the same for every visitor, so it is sent with Cache-Control: public, max-age=300 and a CDN may keep it for five minutes. Prices by user role do not apply here: the route has no signed-in shopper.
Errors
| Status | Code | When |
|---|---|---|
400 |
plugixa_multi_currency_unknown_currency |
The currency is not in your list or is off: This currency is not available. |
429 |
plugixa_multi_currency_rate_limited |
Too many requests from this address: Too many requests. Please wait a little while and try again. |
403 |
plugixa_multi_currency_captcha_failed |
A CAPTCHA check added with the plugixa_multi_currency_public_request_captcha filter refused the request. |
Plus the errors every endpoint can return.
Examples
curl -s "https://your-store.example/wp-json/plugixa-multi-currency/v1/public/prices?currency=EUR&ids=23,24"
<?php
$ch = curl_init('https://your-store.example/wp-json/plugixa-multi-currency/v1/public/prices?currency=EUR&ids=23,24');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-store.example/wp-json/plugixa-multi-currency/v1/public/prices?currency=EUR&ids=23,24');
const { data } = await response.json();
Quick Links
Share