You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WooCommerce coupons are now synced to Fungies on every "Sync Now" (and on the existing hourly cron). Each WC coupon (percent, fixed_cart, fixed_product) is mirrored as a Fungies discount with the same code, amount, amount type, expiration date, and usage limit. The Sync panel in WooCommerce → Settings → Fungies now shows a third row, "Coupons → Fungies", with created / updated / error counts.
Mapping is workspace-scoped (sandbox vs production) via _fungies_pushed_discount_id__<workspace-hash> post meta on each shop_coupon, so toggling Sandbox Mode does not orphan the link.
Idempotent: re-running Sync skips coupons that already match remote state.
Compatibility / robustness fixes shipped together
Use the WooCommerce coupon's actual date_created Unix timestamp for validFrom (the Fungies API accepts but mishandles 0 on non-UTC servers).
Omit purchaseLimit from the create payload when no usage limit is set (Fungies create schema does not accept null).
Inject id into the body of PATCH /v0/discounts/{id}/update — the Fungies update validator requires it in the body, not just the URL path.
Tolerate transient GET /v0/discounts/list 500s by falling back to a row-by-row walk and primarily relying on local post-meta mapping to decide between create vs. update.
Self-heal stale mappings: if an update_discount call returns not found (the Fungies row was archived/deleted manually), the plugin clears the local mapping and creates a fresh row on next sync.
Fix coupon diff for fixed-amount discounts: Fungies stores fixed amounts in currency minor units (e.g. 1 USD → "100"). The plugin now normalizes via wc_get_price_decimals() before comparing, and converts validUntil from milliseconds to seconds. No more spurious "updated" reports on every sync.
Upgrade notes
No DB migrations. New post meta is created on demand per coupon.
No new permissions or capabilities.
No changes to product sync, checkout flow, webhook handler, or order sync.