-
Notifications
You must be signed in to change notification settings - Fork 73
Add promotional discount badges to payment methods in settings #11166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add promotional discount badges to payment methods in settings #11166
Conversation
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
|
Size Change: +870 B (0%) Total Size: 907 kB
ℹ️ View Unchanged
|
dmallory42
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this, @mordeth! The solution is clean and works well:
I left a few minor comments (not blocking) but I think this is good to go! 🚢
client/utils/account-fees.tsx
Outdated
| }; | ||
|
|
||
| export const getDiscountBadgeText = ( discountFee: DiscountFee ): string => { | ||
| const discountPercentage = formatFee( discountFee.discount ?? 0 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If discountFee.discount isn't set, perhaps we should just return null or an empty string? I know we do a check in the payment-method.tsx to only call this if it is set, but I'm just thinking in case this function ends up used in other places.
| const discountFee = | ||
| accountFees?.[ id ]?.discount && accountFees[ id ].discount.length > 0 | ||
| ? accountFees[ id ].discount[ 0 ] | ||
| : null; | ||
| const hasDiscount = discountFee && discountFee.discount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: I think this could be shortened a little to:
| const discountFee = | |
| accountFees?.[ id ]?.discount && accountFees[ id ].discount.length > 0 | |
| ? accountFees[ id ].discount[ 0 ] | |
| : null; | |
| const hasDiscount = discountFee && discountFee.discount; | |
| const discountFee = accountFees?.[ id ]?.discount?.[ 0 ]; | |
| const hasDiscount = discountFee?.discount; |
- Return empty string from getDiscountBadgeText/getDiscountTooltipText when discount is not set, instead of using fallback value - Simplify discountFee/hasDiscount logic using optional chaining 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Exclude docker, vendor, and build folders from Jest's module resolution to prevent duplicate module errors when WooCommerce is installed in multiple locations within the docker environment. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Document that Claude should push/pull only the current branch to avoid errors from stale local branches. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
@dmallory42, I addressed your feedback. |
Keep local Claude documentation files out of version control. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The tests expected "0% off fees" but the implementation correctly returns an empty string for falsy discount values - showing a "0% off" badge makes no sense as there's no promotion to display. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Merging this into the working branch as I addressed the review. |
d0c743f
into
add/payment-method-promotions
Fixes WOOPMNT-5461
Fixes WOOPMNT-5460
Changes proposed in this Pull Request
This PR introduces promotional discount badges for payment methods in the WooPayments settings screen. These badges highlight active promotions and provide additional details via a tooltip retrieved from the account cache.
Testing instructions
/server/wp-content/rest-api-plugins/endpoints/wcpay/service/class-fee-service.phpnpm run changelogto add a changelog file, choosepatchto leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge