WOOCS bietet REST-API-Funktionalität zum programmatischen Abrufen von Währungsdaten und Produktpreisen.
Verfügbare Endpunkte:
1. Alle Währungen abrufen
- Methode: GET
- Endpunkt:
/wp-json/woocs/v3/currency
- Beschreibung: Gibt eine Liste aller verfügbaren Währungen mit deren Einstellungen und Wechselkursen zurück.
2. Einzelnen Produktpreis abrufen
- Methode: GET
- Endpunkt:
/wp-json/woocs/v3/product-price/{product_id}?currency={currency_code}
- Beispiel:
/wp-json/woocs/v3/product-price/59?currency=GBP&format=raw
- Beschreibung: Ruft den Preis eines bestimmten Produkts in der angeforderten Währung ab.
- Parameter:
product_id (erforderlich) - WooCommerce-Produkt-ID
currency (optional) - Währungscode (z. B. GBP, EUR, USD)
format (optional) - Antwortformat: html oder raw (Standard: html)
3. Preise mehrerer Produkte abrufen
- Methode: POST
- Endpunkt:
/wp-json/woocs/v3/products-prices
- Inhaltstyp:
application/json
- Beschreibung: Ruft Preise für mehrere Produkte in einer angegebenen Währung ab.
- Anforderungstext:
{
"product_ids": [59, 62, 50],
"currency": "GBP",
"format": "html"
}
- Parameter:
product_ids (erforderlich) - Array von Produkt-IDs
currency (optional) - Währungscode
format (optional) - Antwortformat: html oder raw
Beispiel mit cURL:
curl -X POST https://your-site.com/wp-json/woocs/v3/products-prices \
-H "Content-Type: application/json" \
-d '{
"product_ids": [59, 62, 50],
"currency": "GBP"
}'