{"slug":"fluentcart-coupons-discounts","title":"fluentcart-coupons-discounts","summary":"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_ap","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-09-16T14:51:44.421314Z","repo":{"url":"https://github.com/Lonsdale201/wp-agent-skills","stars":22,"forks":2,"license":"MIT","updatedAt":"2026-09-26T23:03:36Z"},"bodyHtml":"<hr>\n<h2>name: fluentcart-coupons-discounts\ndescription: &gt;-\nImplements and audits FluentCart coupon creation, fixed/percentage\ncalculation, eligibility conditions, stacking/priority, usage limits,\nrecurring discounts, order snapshots, and virtual coupon resolution. Use\nwhen working with CouponResource, DiscountService, fct_coupons,\nfct_applied_coupons, fluent_cart/coupon/resolve_coupons, can_use_coupon,\nwill_skip_item, discount/pre_apply, custom promotion codes, or investigating\nrounding, double application, and per-customer usage errors.\nmetadata:\nwp-skills-author: \"Soczó Kristóf\"\nwp-skills-contact: \"mailto:lonsdale201@hotmail.com\"\nwp-skills-plugin: \"fluent-cart\"\nwp-skills-plugin-version-tested: \"1.6.0\"\nwp-skills-wp-version-tested: \"7.0.2\"\nwp-skills-php-min: \"7.4\"\nwp-skills-last-updated: \"2026-08-06\"</h2>\n<h1>FluentCart coupons and discounts</h1>\n<p>Extend the calculation pipeline instead of altering displayed totals. Revalidate\nevery coupon against current server-owned cart data.</p>\n<p>Read <a href=\"references/coupon-pipeline.md\">coupon-pipeline.md</a> before implementing a\nvirtual coupon, new rule, custom type, or recurring discount.</p>\n<h2>Use the canonical model</h2>\n<p>Coupon stores code, type, amount, priority, status, stackable,\nshow_on_checkout, dates, use_count, and JSON conditions. AppliedCoupon stores\nthe order-time snapshot. Never reconstruct historical discounts from the\ncurrently editable Coupon.</p>\n<p>Use CouponResource for admin CRUD because it validates and converts fixed\namounts/limits. In 1.6.0:</p>\n<ul>\n<li>fixed amount uses integer minor units after formatting;</li>\n<li>percentage amount is a percentage value from 0 through 100;</li>\n<li>lower numeric priority applies first;</li>\n<li>multiple coupons survive together only under the stackability rules.</li>\n</ul>\n<h2>Extend eligibility</h2>\n<ul>\n<li>fluent_cart/coupon/can_use_coupon: reject the whole coupon with false or\nWP_Error.</li>\n<li>fluent_cart/coupon/will_skip_item: exclude one item.</li>\n<li>fluent_cart/discount/pre_apply: transform candidate cart items before\napplication; preserve complete shape and avoid price trust.</li>\n<li>fluent_cart/coupon/per_customer_usage_query: add legitimate usage scoping.</li>\n<li>fluent_cart/coupon/validating_coupon: normalize/admin-order validation code.</li>\n</ul>\n<p>Keep eligibility callbacks pure. Coupon recalculation runs after cart/address/\nshipping/tax changes and may run repeatedly.</p>\n<h2>Implement virtual coupons carefully</h2>\n<p>fluent_cart/coupon/resolve_coupons receives the database-found collection,\nrequested codes, and cart context. Append an unsaved Coupon model for an\naddon-owned code only after server-side lookup and authorization.</p>\n<pre><code>add_filter(\n    'fluent_cart/coupon/resolve_coupons',\n    static function ($coupons, array $codes, array $context) {\n        // Resolve only this addon's opaque code from server-owned state.\n        // Append a fully populated unsaved Coupon model.\n        return $coupons;\n    },\n    10,\n    3\n);\n</code></pre>\n<p>Give the virtual coupon a stable normalized code, supported type, integer amount\nwhere applicable, status, priority, stackable flag, and full conditions. It is\nnot persisted in fct_coupons, so build separate atomic redemption accounting if\nit represents a finite balance or single-use right.</p>\n<h2>Do not assume every accepted type is calculated</h2>\n<p>CouponRequest 1.6.0 accepts fixed, percentage, free_shipping, and buy_x_get_y.\nThe active DiscountService calculation path is source-confirmed for fixed and\npercentage; it does not contain equivalent type branches for free_shipping or\nbuy_x_get_y. Do not ship those types, or a new custom type, based only on the\nrequest enum. Implement and test all validation, allocation, recurring, order\nsnapshot, refund, reporting, and UI behavior or keep the type unavailable.</p>\n<h2>Preserve calculation invariants</h2>\n<ul>\n<li>Recalculate from item subtotal/server price; never discount a browser total.</li>\n<li>Apply included/excluded product variation IDs and product-category term IDs\nin their correct namespaces.</li>\n<li>Treat email wildcards and per-customer limits as authorization-sensitive.</li>\n<li>Respect min_amount_basis: new coupons default to subtotal, while legacy\nmissing values preserve total behavior.</li>\n<li>Cap line discount at the eligible line amount.</li>\n<li>Correct fixed-discount rounding deterministically across eligible items.</li>\n<li>Record per-coupon allocation so removal, tax, refund, and order snapshots\nremain explainable.</li>\n<li>Treat recurring discount separately from initial/trial/signup amounts.</li>\n</ul>\n<h2>Test matrix</h2>\n<p>Test case-normalized duplicate code, schedule boundaries in GMT, fixed and\npercentage rounding, 0/100 percent, min/max spend basis, category/product\ninclude/exclude, locked line, anonymous/email restriction, per-customer/global\nlimits under concurrency, stacking order, remove/reapply, tax-inclusive cart,\nshipping/fee change, trial/setup/renewal, virtual redemption replay, refund, and\nmanual order editing.</p>\n<h2>Cross-references</h2>\n<ul>\n<li>Use fluentcart-cart-checkout for cart revalidation.</li>\n<li>Use fluentcart-orders-transactions for immutable order snapshots/refunds.</li>\n<li>Use fluentcart-subscriptions-renewals for recurring discounts.</li>\n</ul>\n<h2>References</h2>\n<ul>\n<li>Official product/coupon hooks: <a href=\"https://dev.fluentcart.com/hooks/actions/products-coupons/\">https://dev.fluentcart.com/hooks/actions/products-coupons/</a></li>\n<li>Verified Free source paths:\n<ul>\n<li>fluent-cart/app/Models/Coupon.php</li>\n<li>fluent-cart/app/Models/AppliedCoupon.php</li>\n<li>fluent-cart/api/Resource/CouponResource.php</li>\n<li>fluent-cart/app/Http/Requests/CouponRequest.php</li>\n<li>fluent-cart/app/Services/Coupon/DiscountService.php</li>\n<li>fluent-cart/app/Services/Coupon/Concerns/</li>\n<li>fluent-cart/app/Models/Cart.php</li>\n</ul>\n</li>\n</ul>\n","files":[{"path":"agents/openai.yaml","sizeBytes":311,"isText":true},{"path":"references/coupon-pipeline.md","sizeBytes":2075,"isText":true},{"path":"SKILL.md","sizeBytes":5532,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-09-16T14:55:19.639058Z","sha256":"035FFF009EF39F4F3C1014832FE605D0099BAAD837580862992ABFA73969C073","sizeBytes":3964},"review":null,"source":{"repositoryUrl":"https://github.com/Lonsdale201/wp-agent-skills","path":"fluentcart/fluentcart-coupons-discounts","license":"MIT","commit":"c51b571a259f0c4b5f5c0a3bc50ed580c6851f98","subtreeSha":"9A7B9A685392091FD5EA2285F878135F72ED6CF9EE49A24806E27AB70D646E76","lastSyncedAt":"2026-09-29T23:33:03.303675Z"},"reviewedAt":"2026-09-16T15:10:08.894634Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/Lonsdale201/wp-agent-skills/tree/main/fluentcart/fluentcart-coupons-discounts"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install lonsdale201-wp-agent-skills@llmmart"},{"target":"git","command":"git clone https://github.com/Lonsdale201/wp-agent-skills.git"}]}