Skip to content

fix(checkout): load custom CSS for block forms (#1666) - #1675

Merged
superdav42 merged 2 commits into
mainfrom
bugfix/gh1666-reproduce-and-fix-checkout-custom-css-is
Jul 27, 2026
Merged

fix(checkout): load custom CSS for block forms (#1666)#1675
superdav42 merged 2 commits into
mainfrom
bugfix/gh1666-reproduce-and-fix-checkout-custom-css-is

Conversation

@superdav42

@superdav42 superdav42 commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Preserve checkout block and shortcode attributes while rendering, including the configured form slug.
  • Use that slug when compiling and attaching the form's scoped Custom CSS.
  • Add regression coverage that creates a form with Custom CSS and verifies the generated inline style.

Verification

  • vendor/bin/phpcs inc/ui/class-checkout-element.php tests/WP_Ultimo/UI/Checkout_Element_Test.php
  • vendor/bin/phpstan analyse inc/ui/class-checkout-element.php
  • vendor/bin/phpunit --filter Checkout_Element_Test

Known baseline failures

  • npm run check stops at existing JavaScript lint errors in unrelated assets.
  • npm run stan reports 526 existing errors outside the changed files.
  • npm run test completes 10,124 tests with 2 existing Site Exporter errors and 1 existing discount-code assertion failure.

Resolves #1666


aidevops.sh v3.32.188 plugin for OpenCode v1.18.5 with gpt-5.6-terra

Summary by CodeRabbit

  • Bug Fixes

    • Checkout forms now retain their configured slug when assets are registered later.
    • Custom checkout styling is applied consistently to the correct form.
  • Tests

    • Added coverage verifying slug retention and generated custom stylesheet behavior.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@superdav42, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 25db0a75-6f00-4494-9764-48ceda12bd70

📥 Commits

Reviewing files that changed from the base of the PR and between da25e67 and 71a5d4b.

📒 Files selected for processing (2)
  • inc/ui/class-checkout-element.php
  • tests/WP_Ultimo/UI/Checkout_Element_Test.php
📝 Walkthrough

Walkthrough

Checkout_Element now retains merged display attributes for later script registration, uses a default slug fallback, and includes a regression test verifying slug retention and generated custom CSS output.

Changes

Checkout custom CSS

Layer / File(s) Summary
Retain checkout attributes for script registration
inc/ui/class-checkout-element.php
display() stores merged attributes before calling the parent implementation, while register_scripts() falls back to the default checkout slug.
Verify slug-scoped custom CSS
tests/WP_Ultimo/UI/Checkout_Element_Test.php
The test verifies retained slugs and the presence of the slug-scoped custom CSS selector in registered stylesheet data.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the checkout block Custom CSS fix and matches the change set.
Linked Issues check ✅ Passed The changes preserve the checkout slug for rendering and add regression coverage for inline Custom CSS, satisfying #1666.
Out of Scope Changes check ✅ Passed The PR stays focused on checkout slug handling and Custom CSS output, with only a targeted regression test added.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/gh1666-reproduce-and-fix-checkout-custom-css-is

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

🔨 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!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@inc/ui/class-checkout-element.php`:
- Line 369: Update the slug resolution in the checkout element flow around
get_pre_loaded_attribute() so a false or unavailable pre-loaded attribute falls
back to the configured default slug before calling
wu_get_checkout_form_by_slug(). Preserve valid pre-loaded slugs, and add a
regression test covering execution without a prior display() call.

In `@tests/WP_Ultimo/UI/Checkout_Element_Test.php`:
- Around line 72-96: Update the test around the Checkout_Element singleton
mutation to save the original pre_loaded_attributes value, then wrap display and
subsequent assertions/setup in a try/finally block. In finally, remove the
wu_checkout_skip_output filter and restore the saved property value so
exceptions cannot leak shared state into later tests.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d7ab9b72-db14-45cb-aff3-c8e5b2b6a354

📥 Commits

Reviewing files that changed from the base of the PR and between 1238102 and da25e67.

📒 Files selected for processing (2)
  • inc/ui/class-checkout-element.php
  • tests/WP_Ultimo/UI/Checkout_Element_Test.php

Comment thread inc/ui/class-checkout-element.php Outdated
Comment thread tests/WP_Ultimo/UI/Checkout_Element_Test.php Outdated
@superdav42

Copy link
Copy Markdown
Collaborator Author

Addressed the review findings in 71a5d4be:

  • register_scripts() now explicitly falls back to main-form when the pre-loaded slug is unavailable.
  • Added coverage for script registration without a preceding display() call.
  • Wrapped singleton state and filter mutation in try/finally cleanup.

Verified with targeted PHPCS, PHPStan, and Checkout_Element_Test (6 tests, 29 assertions).


aidevops.sh v3.32.188 plugin for OpenCode v1.18.5 with gpt-5.6-terra

@github-actions

Copy link
Copy Markdown

🔨 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!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@github-actions

Copy link
Copy Markdown

Performance Test Results

Performance test results for 7b660c6 are in 🛎️!

@superdav42

Copy link
Copy Markdown
Collaborator Author

Maintainer Approval (cryptographically signed)

{"authority":"merge","issued_at":"2026-07-27T20:22:15Z","pr":{"base_ref":"main","base_repository":"ultimate-multisite/ultimate-multisite","head_ref":"bugfix/gh1666-reproduce-and-fix-checkout-custom-css-is","head_repository":"ultimate-multisite/ultimate-multisite","head_sha":"71a5d4be42f9ac6bb941d3a533e725f7e3ad4774"},"schema":"aidevops-approval/v2","snapshot_sha256":"dbd60531ab1d7f70b5cac81530627d3fcd4513ebadbd85b85065f04c5117f515","target":{"kind":"pr","number":1675,"repository":"ultimate-multisite/ultimate-multisite"}}
-----BEGIN SSH SIGNATURE-----
U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgKdof3sGZdCbCAvj/Jrw2UMRRFb
fQN9ihyGnfqmVwcM0AAAAQYWlkZXZvcHMtYXBwcm92ZQAAAAAAAAAGc2hhNTEyAAAAUwAA
AAtzc2gtZWQyNTUxOQAAAEB1p/Ei73sxVdrNMrN1S+0xnNo/GVu0GomqynNicarA7a35fK
qZyx8oFhL8mi3Lxur1UfoXuLgKThNe/dqGVIsN
-----END SSH SIGNATURE-----

This approval was signed with a root-protected SSH key. It cannot be forged by automation.

This conversation is now locked. To propose scope changes, open a new issue referencing this one.


aidevops.sh v3.32.188 automated scan.

@Ultimate-Multisite Ultimate-Multisite locked as resolved and limited conversation to collaborators Jul 27, 2026
@superdav42
superdav42 merged commit 65e2b97 into main Jul 27, 2026
11 checks passed
@superdav42 superdav42 added the review-feedback-scanned Merged PR already scanned for quality feedback label Jul 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

review-feedback-scanned Merged PR already scanned for quality feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Checkout Form "Custom CSS" is never applied to the page (silent failure)

1 participant