Skip to content

feat: add discounted price mapping field#61

Draft
evrpress wants to merge 4 commits into
developfrom
feature/discounted-price-mapping
Draft

feat: add discounted price mapping field#61
evrpress wants to merge 4 commits into
developfrom
feature/discounted-price-mapping

Conversation

@evrpress

@evrpress evrpress commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

Adds a "Discounted price" mapping option for paragraph, heading, and button blocks that applies the scope coupon discount to the current plan price.

Fetches coupon metadata from the Freemius API (products/{id}/coupons.json?code=...) in the block editor via a new useCoupon hook, and embeds coupon discount data in page output for frontend modifier updates. Shared JS/PHP helpers apply percentage or fixed-amount discounts (including multi-currency discounts). When no coupon is configured in scope, the field shows an editor error and renders empty on the frontend. Main files: src/hooks/useMapping.js, src/scope/MappingSettings.js, src/blocks/modifier/view.js, includes/class-freemius-scope.php, new src/util/discountedPrice.js.

Site owners can now display coupon-adjusted prices alongside regular pricing blocks without duplicating amounts manually.

Open WordPress Playground Preview

evrpress added 2 commits June 28, 2026 11:43
Adds a "Discounted price" mapping option for paragraph, heading, and button blocks that applies the scope coupon discount to the current plan price.

Fetches coupon metadata from the Freemius API (`products/{id}/coupons.json?code=...`) in the block editor via a new `useCoupon` hook, and embeds coupon discount data in page output for frontend modifier updates. Shared JS/PHP helpers apply percentage or fixed-amount discounts (including multi-currency `discounts`). When no coupon is configured in scope, the field shows an editor error and renders empty on the frontend. Main files: `src/hooks/useMapping.js`, `src/scope/MappingSettings.js`, `src/blocks/modifier/view.js`, `includes/class-freemius-scope.php`, new `src/util/discountedPrice.js`.

Site owners can now display coupon-adjusted prices alongside regular pricing blocks without duplicating amounts manually.
Updated the `applies_to_plan` method in the Coupon class to utilize a new `normalize_plan_ids` method for improved handling of plan restrictions. This change allows for better normalization of plan IDs from various input formats. Additionally, the JavaScript utility function `normalizePlanIds` was added to mirror this functionality on the client side. New tests were introduced to ensure correct behavior when plans are provided as an array. This refactor improves code maintainability and consistency across PHP and JavaScript implementations.
evrpress and others added 2 commits June 29, 2026 12:42
Keep Cursor config in a local nested repo under .cursor/ and ignore
it in the plugin repository so it is not pushed to origin.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant