Fluentcart coupons discounts

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

Fluentcart coupons discounts is an AI agent skill from the GitHub repository Lonsdale201/wp-agent-skills. Implements and audits FluentCart coupon creation, fixed/percentage calculation, eligibility conditions, stacking/priority, usage limits, recurring discounts, order snapshots, and virtual coupon resolution. Use when working with CouponResource, DiscountService, fct_coupons, fct_applied_coupons, fluen

How to use this skill

Skill file

FluentCart coupons and discounts

Extend the calculation pipeline instead of altering displayed totals. Revalidate

every coupon against current server-owned cart data.

Read coupon-pipeline.md before implementing a

virtual coupon, new rule, custom type, or recurring discount.

Use the canonical model

Coupon stores code, type, amount, priority, status, stackable,

show_on_checkout, dates, use_count, and JSON conditions. AppliedCoupon stores

the order-time snapshot. Never reconstruct historical discounts from the

currently editable Coupon.

Use CouponResource for admin CRUD because it validates and converts fixed

amounts/limits. In 1.6.0:

Extend eligibility

WP_Error.

application; preserve complete shape and avoid price trust.

Keep eligibility callbacks pure. Coupon recalculation runs after cart/address/

shipping/tax changes and may run repeatedly.

Implement virtual coupons carefully

fluent_cart/coupon/resolve_coupons receives the database-found collection,

requested codes, and cart context. Append an unsaved Coupon model for an

addon-owned code only after server-side lookup and authorization.

~~~php

add_filter(

'fluent_cart/coupon/resolve_coupons',

static function ($coupons, array $codes, array $context) {

// Resolve only this addon's opaque code from server-owned state.

// Append a fully populated unsaved Coupon model.

return $coupons;

},

10,

3

);

~~~

Give the virtual coupon a stable normalized code, supported type, integer amount

where applicable, status, priority, stackable flag, and full conditions. It is

not persisted in fct_coupons, so build separate atomic redemption accounting if

it represents a finite balance or single-use right.

Do not assume every accepted type is calculated

CouponRequest 1.6.0 accepts fixed, percentage, free_shipping, and buy_x_get_y.

The active DiscountService calculation path is source-confirmed for fixed and

percentage; it does not contain equivalent type branches for free_shipping or

buy_x_get_y. Do not ship those types, or a new custom type, based only on the

request enum. Implement and test all validation, allocation, recurring, order

snapshot, refund, reporting, and UI behavior or keep the type unavailable.

Preserve calculation invariants

in their correct namespaces.

missing values preserve total behavior.

remain explainable.

Test matrix

Test case-normalized duplicate code, schedule boundaries in GMT, fixed and

percentage rounding, 0/100 percent, min/max spend basis, category/product

include/exclude, locked line, anonymous/email restriction, per-customer/global

limits under concurrency, stacking order, remove/reapply, tax-inclusive cart,

shipping/fee change, trial/setup/renewal, virtual redemption replay, refund, and

manual order editing.

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.