Dahu Avoir
Transforme les coupons en un petit système d'avoirs
by Hugo Vial-Jaime · github.com/epilouptique/dahu-avoir · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/epilouptique/dahu-avoir/archive/refs/heads/main.zipA WooCommerce plugin that keeps unused store-credit balance on fixed-cart coupons instead of losing it.
Description
By default, WooCommerce fully consumes a fixed_cart coupon even when the order total is lower than the coupon amount. For stores that use coupons as a store-credit ("avoir") system, this means customers lose the remaining balance.
Dahu Avoir lets you flag specific fixed_cart coupons as store credit. After an order is paid (status processing, with completed as a safety net), the plugin computes the actually consumed amount and:
- Updates the coupon with the remaining balance if any, resetting its usage so the customer can reuse the same code.
- Leaves the coupon untouched (fully consumed) if the whole amount was used.
- Restores the consumed amount back to the coupon if the order is later cancelled or refunded.
All other coupons keep the native WooCommerce behavior.
Features
- Opt-in per coupon via a checkbox in the coupon's General tab.
- Automatic partial-balance carry-over after payment, with usage reset (usage count, used-by list).
- Automatic restoration on order cancellation/refund.
- Optional expiry-date extension (in days) applied on each partial use.
- Read-only admin table listing all store-credit coupons (code, balance, expiry, email restriction).
- Per-coupon history log (date, order, amount consumed, new balance) shown on the coupon edit screen.
- Full HPOS (High-Performance Order Storage) compatibility.
Installation
- Upload the plugin folder to
/wp-content/plugins/, or install the zip via the WordPress admin. - Activate the plugin through the "Plugins" menu in WordPress.
- Make sure WooCommerce is installed and active.
Configuration
- Edit a
fixed_cartcoupon and check "Avoir client (solde reportable)" in the General tab. - Go to WooCommerce → Dahu Avoir to enable/disable the feature globally and set an optional expiry extension (in days).
- The same screen lists all coupons currently flagged as store credit, along with their live balance.
Changelog
1.0.4
- Fix: the "Settings" plugin action link now also shows the version number, and the plugin row meta links point to the correct site URL, per the required admin plugin-list format.
1.0.3
- Change: the plugin no longer forces
usage_limit/usage_limit_per_userto 1 on a coupon after a partial use — these stay untouched (unlimited by default), matching the requested workflow.
1.0.2
- Fix: the pending-order reservation query used unprefixed order statuses (
pending,on-hold) whichwc_get_orders()did not match, so the concurrent-overspend cap introduced in 1.0.1 never actually triggered. Statuses are now correctly prefixed (wc-pending,wc-on-hold), with an additionalhas_status()safety check.
1.0.1
- Fix: prevent concurrent unpaid orders from jointly overspending the same store-credit balance by dynamically capping the coupon amount against orders still pending/on-hold at cart-validation time.
- Add diagnostic order notes and WooCommerce logger entries to trace processing decisions.
1.0.0
- Initial release: partial balance carry-over, restoration on cancel/refund, settings page, coupon history.
License
GPL v2 or later — https://www.gnu.org/licenses/gpl-2.0.html