GT Extensions for FluentCart REST API Reference

  • JNext lesson
  • KPrevious lesson
  • FSearch lessons
  • EscClear search

GT Extensions registers several REST API endpoints under the gt-extensions-fluentcart/v1 namespace. Write endpoints for variation data require the manage_options capability (WordPress administrator). A few read endpoints that power the storefront, like the sold-count badge, the currency selector, and the external-product resolver, are public by design.

GT Extensions exposes its per-variation data over REST under the gt-extensions-fluentcart/v1 namespace so deployment scripts and management tools can read and write configuration without screen-scraping wp-admin, while the storefront widgets hydrate from the small public read endpoints.

Base URL

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

Authentication

Use WordPress application passwords or cookie-based authentication for the admin endpoints; they check for the manage_options capability. The public read endpoints (sold count, currency context and switch, external-product resolve) need no authentication.

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, and is empty when the count is below the configured minimum
  • This endpoint is public; it powers the storefront badge and exposes nothing beyond what the badge already shows

Get Currency Context

GET /currency

Returns the current currency context for the Multi-Currency Checkout storefront selector: enabled currencies, the active currency, and selector state. Public, sent with no-store cache headers so cached pages never become the source of truth for guest currency state.

Parameters:

  • cart_hash (string, optional), Binds the read to an exact Fluent Cart checkout cart; returns a 404 if that cart is gone

Switch Cart Currency

POST /currency

Switches the active cart currency. The server reprices the cart, revalidates coupons, and clears currency-dependent shipping, tax, and fee state before the storefront reloads. Public, because guests switch currency too; the currency must be one of the enabled currencies.

Parameters:

  • currency (string, required), The currency code (e.g., “EUR”)
  • cart_hash (string, optional), The exact checkout cart to reprice

Response:

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

Variation Currency Prices (Price Book)

GET /variation/{variation_id}/prices
POST /variation/{variation_id}/prices
DELETE /variation/{variation_id}/prices

Reads, saves, or removes exact price-book entries for a variation. Requires manage_options. GET returns the manual entries plus the resolved price for every enabled currency. POST saves an exact price; DELETE returns the currency to automatic conversion.

POST parameters:

  • currency (string, required), An enabled non-base currency code
  • item_price (decimal), Exact selling price
  • compare_price (decimal), Compare-at price
  • signup_fee (decimal), Subscription signup fee

Amounts are accepted as decimals and stored as integer minor units in the wp_gtfc_currency_prices table.


Refresh Exchange Rates

POST /rates/refresh

Forces an immediate exchange-rate refresh from the configured provider. Requires manage_options. This is what the “Refresh rates now” button on the settings page calls.


Resolve External Products

GET /external-products/resolve

Bounded, read-only resolver used by the External Product frontend script to handle standalone Add to Cart and Buy Now blocks. Public, but it only returns settings for published, enabled external products with a valid URL.

Parameters:

  • product_ids (string), Comma-separated product IDs, at most 50 per request
  • variation_ids (string), Comma-separated variation IDs, at most 50 per request

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

Quick answers to common questions:

What can I do through the REST API?

Read and write per-variation data programmatically: quantity limits, button text, and currency price-book entries, plus trigger exchange-rate refreshes. It’s the same data the admin widgets edit, accessible to scripts.

How do I authenticate against the endpoints?

WordPress application passwords over HTTPS, with a user holding manage_options, for the admin endpoints. A few storefront read endpoints (sold count, currency context and switch, external-product resolve) are public by design and expose only what the storefront already renders.