plugin-icon

DeftCoders – Discount & Fee Rules for WooCommerce

Automatically add fees and apply discounts in WooCommerce based on cart, payment method, user role, date, time, and location. No coupon codes needed.
Version
1.0.0
Last updated
Mar 15, 2026
DeftCoders – Discount & Fee Rules for WooCommerce

DeftCoders – Discount & Fee Rules is a condition-driven pricing engine for WooCommerce. You build rules, each rule has conditions (when it fires) and an action (what it does). When a customer visits the cart or checkout, every active rule is evaluated automatically — fees and discounts are applied without any coupon codes or manual work.

Rules run in priority order. A “Stop Further Rules” flag lets any rule break the chain once it fires, giving you full control over stacking and exclusivity.

What You Can Do: Real Examples

  • Add a $3.00 handling fee on orders under $50 — with a custom message telling the customer how to avoid it
  • Charge a 2% surcharge when Cash on Delivery is selected at checkout
  • Apply 10% off automatically every Saturday and Sunday
  • Give users with the “wholesale” role 15% off every order
  • Run a tiered bulk deal: 5–9 items get 10% off, 10–19 get 15% off, 20+ get 20% off
  • Activate a flash sale between two specific dates without touching any code
  • Add an international processing fee for customers in certain countries

5 Action Types

Fee Rules add charges to the cart:

  • Fixed Fee — a flat currency amount (e.g. $3.00). Optional taxable toggle. Optional custom message shown at checkout explaining the fee.
  • Percentage Fee — calculated as a percentage of the cart subtotal (e.g. 2%). Optional taxable toggle.

Discount Rules reduce what the customer pays:

  • Percentage Discount — percentage off the cart subtotal (e.g. 10%). Can apply to the full cart or product subtotal only. Stackable or non-stackable mode.
  • Fixed Discount — flat currency amount off (e.g. $5.00). Always capped at the cart total to prevent a negative balance.
  • Tiered Discount — a different percentage for each quantity bracket (e.g. 5–9 items: 10%, 10–19 items: 15%, 20+ items: 20%). The matching tier label displays in the cart.

14 Condition Types

All conditions on a rule must match simultaneously (AND logic). Combine as many as needed.

Cart & Order

  • Cart Total — equals, not equals, greater than, greater than or equal, less than, less than or equal
  • Cart Subtotal — same operators; evaluates before fees are applied
  • Cart Quantity — total item count; same numeric operators

Customer & Checkout

  • Payment Method — equals, not equals, contains, does not contain
  • Shipping Method — equals, not equals, contains, does not contain
  • User Role — is one of / is not one of; “Guest” is supported for logged-out shoppers
  • Country — equals, not equals, contains, does not contain (shipping country, falls back to billing)
  • State / Province — same operators (shipping state, falls back to billing)
  • Coupon Applied — is one of / is not one of

Products

  • Product — is one of / is not one of; matches product ID and variation ID
  • Product Category — is one of / is not one of; uses a single batched query for all cart items

Date & Time (all use your WordPress site timezone)

  • Day of Week — is one of / is not one of; Monday through Sunday
  • Time Range — active between a start time and end time (HH:MM format)
  • Date Range — active between a start date and end date (YYYY-MM-DD format)

Per-Rule Settings

  • Priority — integer from 1 to 9999; lower number runs first. Drag rows in the rules list to reorder without typing.
  • Status — Active or Inactive; toggle without deleting. Pre-build rules and switch them on when ready.
  • Stop Further Rules — when this rule fires, no lower-priority rules are evaluated at all.
  • Optional Label — overrides the cart line-item label shown to the customer (defaults to the rule name).

Admin Dashboard

The rules list page shows 8 live stat cards at the top: Total Rules, Active Rules, Inactive Rules, Discount Rules, Fee Rules, Fee Revenue this month, Discounts Given this month, and all-time Net Impact (fee revenue minus discounts). The revenue figures come from completed and processing orders tracked automatically.

The rules table shows 10 rules per page with full pagination. Each row shows the rule name, type badge, conditions summary, fee/discount amount, priority number, a live status toggle, and Edit/Delete buttons. Drag any row to reorder priority. A search box filters by rule name in real time. Two dropdowns filter the list by condition type or rule type.

Bulk actions at the bottom let you Activate, Deactivate, Delete, or Export any selection of rules in one click.

Rule Simulator

Test any combination of your rules without touching a real cart. Enter a simulated cart — subtotal, item count, payment method, shipping method, user role, country, coupon code, date, and time — then click Run. The results panel shows every active rule, whether it matched, which conditions were satisfied (or which one failed), the calculated amount, and a complete cart summary: subtotal, total fees, total discounts, and final total. Nothing is written to any real session or order.

Debug Tools

Preview Mode — enable in Settings to run the full rule evaluation engine on every real cart request, but apply nothing to any actual cart. Safe to use on a live production store.

Debug Mode — writes timestamped log entries to wp-content/uploads/wcdpdr-logs/. One file per day. Each entry shows the cart state at evaluation time, every rule evaluated (conditions met or not, amount applied), any Stop Further Rules trigger, and any execution error. Logs are viewable from the Debug Logs admin page and can be cleared with one click. The log directory is protected from direct browser access by a .htaccess file written automatically on first use.

Import / Export

Export all rules — or a selected subset via bulk export — to a JSON file. Import on any site. Every rule is validated before saving and all fields are sanitised. The 5-rule free limit is respected automatically; imports are trimmed to available slots.

Clean Uninstall

When you delete the plugin via the WordPress admin, it removes everything it created: both database tables, all plugin options, all transients, and the entire log directory. On Multisite, cleanup runs for every sub-site.

Performance

Active rules are cached in a 60-second WordPress transient; no database query fires on each cart recalculation. The cache busts immediately whenever a rule is saved, deleted, or its status toggled. Product category conditions use a single batched query across all cart products rather than one query per line item.

Compatibility

  • WooCommerce HPOS — full compatibility declared via FeaturesUtil::declare_compatibility(); all order reads/writes use the WooCommerce order object API
  • Multisite — clean uninstall handles every sub-site
  • WPML — detected automatically; status shown on the Settings page
  • PHP 8.x — tested on PHP 8.0, 8.1, and 8.2
  • Tax-inclusive stores — discount and fee bases use the tax-inclusive subtotal when your store displays prices with tax; tax-exclusive stores use the subtotal without tax
  • All amounts normalised via wc_format_decimal() and rounded with wc_round_tax_total()
Freeon paid plans
Tested up to
WordPress 6.9.4
This plugin is available for download for your site.