REST API Reference

Keyboard shortcuts
  • JNext lesson
  • KPrevious lesson
  • /Search lessons
  • EscClear search

GT Extensions registers several REST API endpoints under the gt-extensions-fluentcart/v1 namespace. All endpoints require manage_options capability (WordPress administrator).

Base URL

https://yoursite.com/wp-json/gt-extensions-fluentcart/v1/

Authentication

Use WordPress application passwords or cookie-based authentication. All endpoints check for the manage_options capability.

Endpoints

Get Sold Count

GET /sold-count/{product_id}

Returns the total number of completed and processing orders for a product, along with the pre-rendered badge HTML.

Parameters:

  • product_id (int, required) — The Fluent Cart product ID (in the URL path)

Response:

{
    "product_id": 123,
    "sold_count": 247,
    "badge_html": "<span class=\"gtfc-sold-count\">🔥 247 sold</span>"
}

Notes:

  • The count includes orders with completed and processing status
  • Returns 0 if the product has no orders
  • Badge HTML respects the configured badge text template

Get Available Currencies

GET /currencies

Returns the list of enabled currencies for the Multi-Currency Variations module.

Response:

{
    "currencies": {
        "USD": {"code": "USD", "sign": "$"},
        "EUR": {"code": "EUR", "sign": "€"},
        "GBP": {"code": "GBP", "sign": "£"}
    },
    "defaultCurrency": "USD"
}

Notes:

  • Only returns currencies enabled in the module settings
  • The defaultCurrency is the store’s base currency from Fluent Cart settings

Update Variation Currency

POST /variation/{variation_id}/currency

Sets the currency for a specific product variation.

Parameters:

  • variation_id (int, required) — The variation ID (in the URL path)
  • currency (string, required) — The currency code (e.g., “EUR”)

Response:

{
    "success": true,
    "currency": "EUR"
}

Notes:

  • The currency must be one of the enabled currencies in module settings
  • Currency is stored in the variation’s other_info['currency'] field

Update Variation Quantity Limits

POST /variation/{variation_id}/quantity-limits

Sets minimum, maximum, and step quantities for a specific variation.

Parameters:

  • variation_id (int, required) — The variation ID (in the URL path)
  • min_quantity (int) — Minimum purchase quantity
  • max_quantity (int) — Maximum purchase quantity (0 = no limit)
  • quantity_step (int) — Quantity increment step

Response:

{
    "success": true,
    "limits": {
        "min_quantity": 5,
        "max_quantity": 50,
        "quantity_step": 5
    }
}

Update Variation Button Text

POST /variation/{variation_id}/button-text

Sets custom Add to Cart and Buy Now text for a specific variation.

Parameters:

  • variation_id (int, required) — The variation ID (in the URL path)
  • add_to_cart_text (string) — Custom Add to Cart button text
  • buy_now_text (string) — Custom Buy Now button text

Response:

{
    "success": true,
    "data": {
        "add_to_cart_text": "Subscribe Now",
        "buy_now_text": "Subscribe & Pay"
    }
}

Notes:

  • Requires the Custom Add to Cart Text module with per-variation enabled
  • Text is stored in the variation’s other_info field

Error Handling

All endpoints return standard WordPress REST API error responses:

{
    "code": "rest_forbidden",
    "message": "Sorry, you are not allowed to do that.",
    "data": {
        "status": 403
    }
}

Common error codes:

  • rest_forbidden (403) — User doesn’t have manage_options capability
  • rest_no_route (404) — Invalid endpoint or variation/product ID not found
  • rest_invalid_param (400) — Missing or invalid parameters