fix(checkout): harden step validation scoping#1336
Conversation
|
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 (3)
📝 WalkthroughWalkthroughCheckout validation for multi-step forms now filters rules per-step: the backend maps rule keys per step (including type-specific rules like ChangesMulti-step checkout validation step-scoping
Sequence DiagramsequenceDiagram
participant Guest as Guest User
participant Account as Account Step
participant Template as Template Step
participant Checkout as Checkout (PHP)
participant Validator as validate_client_side (JS)
Guest->>Account: Fill email, username, password
Account->>Validator: Submit form
Validator->>Checkout: Request step_fields map
Checkout->>Validator: Return {account: [email_address, username, ...], template: [site_title, template_id, ...]}
Validator->>Validator: Validate only account fields (rendered in form)
Validator->>Template: Advance to template step
Guest->>Template: Select template
Template->>Validator: Submit form (email/username/password no longer rendered)
Validator->>Checkout: Validate step_fields for template step
Validator->>Validator: Fallback: extract rendered fields from DOM
Validator->>Validator: Validate only {site_title, template_id, ...} (no account fields)
Validator->>Guest: Success - advance to payment
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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: |
738671a to
9ab69ff
Compare
|
MERGE_SUMMARY Updated Evidence:
Branch evidence:
|
🔨 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
wu_checkout.step_fieldsfalls back to fields rendered on the current form step instead of validating every global rule.step_fieldsfor checkout field types whose rendered/value key differs from the builder field id (template_selection→template_id,pricing_table→products).Issue verification
v2.12.0(git tag --contains a3a6f7c...returnedv2.12.0), so the issue body's release-status note was incorrect.errors: []; the exact email/username/password client errors were not reproducible on currentv2.12.0code.template_selectionfield id instep_fields, while the JS validation rule key istemplate_id; this PR fixes that mismatch and adds a defensive fallback for stale step maps.Verification
vendor/bin/phpunit --filter Checkout_Step_Fields_Test— passes (2 tests, 31 assertions; existing PHP 8.4 deprecation notices emitted by dependencies)vendor/bin/phpcs inc/checkout/class-checkout.php tests/unit/Checkout_Step_Fields_Test.php— passesnode_modules/.bin/eslint assets/js/checkout.js --ignore-pattern '*.min.js'— passes (Browserslist age warning only)git diff --check— passesResolves #1332
Summary by CodeRabbit
Bug Fixes
Tests