fix: skip PayPal button branding when checkout does not require payment#783
Conversation
The PayPal branding script applied yellow PayPal styling to the submit button whenever the gateway data property was 'paypal-rest', regardless of whether payment was actually needed. This caused free plans, 100% discount codes, and other zero-total carts to show a PayPal-branded submit button even though the payment section was hidden. Now checks order.should_collect_payment before applying branding, and re-evaluates on every form update (product change, coupon, etc.).
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA single JavaScript file was modified to refactor PayPal branding logic. The change decouples gateway selection from payment requirement validation, introducing conditional application of PayPal branding only when both conditions are met, with automatic refresh triggers when order conditions change. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
Summary
Changes
Testing
Merged via PR #783 to main. aidevops.sh v3.6.235 spent 6m on this as a headless bash routine. |
|
Performance Test Results Performance test results for 57c2c7a are in 🛎️! Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown. URL:
|
Summary
paypal-rest, not whether payment was actually requiredorder.should_collect_paymentbefore applying branding, and re-evaluates whenever the form updates (product change, coupon applied, plan switch, etc.)Changes
assets/js/gateways/paypal-rest.js:orderRequiresPayment()— reads the sameshould_collect_paymentflag that the payment methods template uses to show/hide the gateway selectorwu_on_form_updatedhook listener to re-evaluate branding when the order changes (e.g. switching from paid to free plan)Testing
Summary by CodeRabbit