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
Fixed-amount (dollar) coupons can be configured with different discount values per currency in the Freemius dashboard, but products/{product_id}/coupons.json only returns a single discount field (USD). Per-currency amounts are absent, so non-USD pricing uses the wrong discount.
Goal: Dollar-type coupons expose all configured currency discount amounts to the WordPress plugin (and embedded frontend scope) so discounted prices are correct for every supported currency.
Problem
When a coupon uses discount_type: dollar and has per-currency amounts configured (e.g. USD 50, EUR 40, GBP 20), the coupons API response only includes the USD value:
Confirm API contract — verify whether coupons.json is expected to return a discounts object (e.g. { "usd": 50, "eur": 40, "gbp": 20 }) or if amounts live in another field/endpoint.
If API-side gap — coordinate with Freemius platform so multi-currency dollar discounts are included in the coupons payload (percentage coupons may not need this).
If plugin-side normalization is possible — map whatever the API returns into the discounts shape in Coupon::get_by_code() before embed/apply logic runs.
Ensure embed path is complete — Coupon::to_embed_data() and frontend applyCouponDiscount() already read coupon.discounts[currency] with fallback to coupon.discount; they need populated data from steps 2–3.
Add regression tests — PHP (CouponTest) and/or JS fixtures with multi-currency dollar coupons.
Out of scope
Percentage coupons (single discount value is correct).
Checkout modal coupon application (separate from scope embed path unless the same API gap affects it).
Acceptance criteria
Coupon::get_by_code() returns per-currency discount amounts for dollar-type coupons when configured in Freemius (e.g. discounts: { usd: 50, eur: 40, gbp: 20 }).
Embedded .freemius-coupon-data JSON includes the discounts map via Coupon::to_embed_data().
Coupon::apply_discount() / applyCouponDiscount() produce correct prices for EUR and GBP (not USD fallback).
Tests cover multi-currency dollar coupon payload.
Considerations
Plugin already expects discounts:includes/class-freemius-coupon.php (apply_discount, to_embed_data) and src/util/discountedPrice.js (applyCouponDiscount) use coupon.discounts[currency] ?? coupon.discount. The gap appears to be missing data from the API, not missing consumer logic.
Related in-flight work: branch feature/discounted-price-mapping adds coupon-aware discounted price mapping and tests; likely the right place to land a fix once the API shape is confirmed.
API vs plugin ownership: if coupons.json will never expose multi-currency amounts, we need an alternate data source or a platform change — document the decision in the fix PR.
Backward compatibility: sites with only USD dollar coupons should behave unchanged (discount fallback still works).
Open questions
Does the Freemius API store per-currency dollar amounts under a different key today (e.g. nested pricing object), or is this a platform API omission?
Should discount remain the USD canonical value when discounts is present, or be deprecated in favor of the map?
Summary
Fixed-amount (dollar) coupons can be configured with different discount values per currency in the Freemius dashboard, but
products/{product_id}/coupons.jsononly returns a singlediscountfield (USD). Per-currency amounts are absent, so non-USD pricing uses the wrong discount.Goal: Dollar-type coupons expose all configured currency discount amounts to the WordPress plugin (and embedded frontend scope) so discounted prices are correct for every supported currency.
Problem
When a coupon uses
discount_type: dollarand has per-currency amounts configured (e.g. USD 50, EUR 40, GBP 20), the coupons API response only includes the USD value:[ 'code' => 'COUPON50', 'discount' => 50, 'discount_type' => 'dollar', // no `discounts` key — EUR/GBP amounts missing ]Screenshots
Repro
discount_type= dollar (not percentage).GET products/{product_id}/coupons.json?code=COUPON50(via pluginCoupon::get_by_code()or direct API).discount: 50— nodiscountsmap witheur,gbp, etc.Example response
Product
19794, couponCOUPON50:[ 'coupons' => [ [ 'entity_id' => 19794, 'code' => 'COUPON50', 'discount' => 50, 'discount_type' => 'dollar', 'has_renewals_discount' => 1, 'id' => 86595, // …other fields; no per-currency discounts ], ], ]Proposed approach
coupons.jsonis expected to return adiscountsobject (e.g.{ "usd": 50, "eur": 40, "gbp": 20 }) or if amounts live in another field/endpoint.discountsshape inCoupon::get_by_code()before embed/apply logic runs.Coupon::to_embed_data()and frontendapplyCouponDiscount()already readcoupon.discounts[currency]with fallback tocoupon.discount; they need populated data from steps 2–3.CouponTest) and/or JS fixtures with multi-currency dollar coupons.Out of scope
discountvalue is correct).Acceptance criteria
Coupon::get_by_code()returns per-currency discount amounts for dollar-type coupons when configured in Freemius (e.g.discounts: { usd: 50, eur: 40, gbp: 20 })..freemius-coupon-dataJSON includes thediscountsmap viaCoupon::to_embed_data().Coupon::apply_discount()/applyCouponDiscount()produce correct prices for EUR and GBP (not USD fallback).Considerations
discounts:includes/class-freemius-coupon.php(apply_discount,to_embed_data) andsrc/util/discountedPrice.js(applyCouponDiscount) usecoupon.discounts[currency] ?? coupon.discount. The gap appears to be missing data from the API, not missing consumer logic.feature/discounted-price-mappingadds coupon-aware discounted price mapping and tests; likely the right place to land a fix once the API shape is confirmed.coupons.jsonwill never expose multi-currency amounts, we need an alternate data source or a platform change — document the decision in the fix PR.discountfallback still works).Open questions
discountremain the USD canonical value whendiscountsis present, or be deprecated in favor of the map?Context
Coupon::get_by_code()/products/{id}/coupons.jsonresponse for couponCOUPON50on product19794.