Fluentcart cart checkout

From Lonsdale201/wp-agent-skills · View interactive version

Fluentcart cart checkout is an AI agent skill from the GitHub repository Lonsdale201/wp-agent-skills. Implements and audits FluentCart cart mutation, custom/ghost items, fees, coupons, checkout fields, validation, shipping recalculation, order placement, and duplicate-submit protection. Use when working with CartResource, Cart, cart_hash or fct_cart_hash, fluent_cart_checkout_routes, fluent_cart_pla

How to use this skill

Skill file

FluentCart cart and checkout

Keep the browser declarative: it may request an item, quantity, coupon, address,

and method, but the server must resolve every price and eligibility decision.

Read checkout-contract.md before adding a

custom item, fee, checkout field, or nonstandard client.

Use the actual transport

In Free 1.6.0 normal cart mutations use authenticated-by-nonce admin AJAX:

The X-WP-Nonce header is accepted for action fluentcart or wp_rest. It provides

CSRF intent, not user identity or object ownership. Anonymous checkout remains

public.

The registered REST namespace contains checkout and public product routes, but

no active core /cart/add, /cart/update, or /cart/remove route. Do not implement a

headless client from generic documentation alone.

Extend cart items safely

Prefer normal ProductVariation items. For a custom/ghost item:

  1. Resolve a server-owned offer from the requested opaque item ID.
  2. Validate availability, currency, quantity, customer eligibility, and mode.
  3. Return a complete normalized item/variation from the documented custom-item

filters.

  1. Recompute the item on every quantity/revalidation path.
  2. Never accept item_price, subtotal, discount, recurring amount, tax class,

downloadable entitlement, or product title as authoritative client values.

  1. Add a stable discriminator to prevent unrelated custom items from merging.

Relevant surfaces include fluent_cart/cart/validate_custom_item,

fluent_cart/cart_item_product_variation, and the custom-item quantity/change

hooks in Cart/CartResource. Verify the exact callback arguments at 1.6.0 before

registering.

Add fees through Cart

Use Cart::addFee() with a stable key and addon-owned source. Keep calculation

pure and deterministic for the current cart context. Use removeFee() or

removeFeesBySource() when the condition no longer applies. Amounts are integer

minor units.

Do not persist a fee by editing estimated_total or a browser fragment. Fees are

recomputed and cached during the request; avoid recursion from

fluent_cart/cart/fees and call clearFeeCache() only when the underlying context

really changes.

Validate at order placement

and return true or WP_Error.

checkout normalization.

customer rules server-side.

exception details.

Order placement serializes concurrent first submissions with a MySQL named lock

keyed by cart_hash. Do not create a parallel order outside CheckoutApi merely to

obtain an order ID; that defeats the duplicate-submit protection.

Treat cart identity correctly

authorization credential.

payloads.

Test the failure paths

Test anonymous and logged-in carts, stale hash, replayed request, two concurrent

place-order requests, zero payment, subscription-only restrictions, invalid

coupon, changed price/stock, invalid shipping method, payment create failure,

and retry after the transaction becomes failed.

Cross-references

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.