Skip to content

Improve PaymentInfo for better compatibility with WooPayments and improvement performance #60257

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

Conversation

RadoslavGeorgiev
Copy link
Contributor

Changes proposed in this Pull Request:

Closes WOOPLUG-5275

(For Bug Fixes) Bug introduced in PR #52173.

All changes relate to the PaymentInfo class.

Swapped order

Until now, for WooPayments, get_wcpay_card_info() was used without calling the wc_order_payment_card_info filter. This PR swaps the order, calling the filter first. That way, WooPayments will be able to provide data first in an upcoming version.

Until WooPayments gets updated for the merchant, get_wcpay_card_info() will still be used as a fallback.

Add cache

get_wcpay_card_info() was performing external requests without caching the results, effectively slowing down checkout by 4x the duration of the request. This PR caches the data in order meta, limiting external requests to a single one.

Screenshots or screen recordings:

This PR includes no visual changes.

How to test the changes in this Pull Request:

You need both Woo Core and WooPayments active and set up.

  1. Perform a (not necessarily) simple checkout with WooPayments and a new card.
  2. Monitor the number of outgoing requests to the WooPayments server. Based on the Core and WooPayments branch, you should see a similar number of requests to the one described in Testing that has already taken place below.
    • The easiest way to do this locally is to add a breakpoint at the beginning of the WooPayments WC_Payments_API_Client->request() method (ref).
    • Alternatively, you can enable logging for WooPayments and inspect the logs in WooCommerce -> Status -> Logs.

Testing that has already taken place

This PR has been tested locally with WooPayments in both develop and Automattic/woocommerce-payments#11001

Scenario Result
trunk + any WooPayments 6 external API calls, 2 from WooPayments and 4 for get_wcpay_card_info()
this branch + WooPayments develop There are 3 external API calls, 2 from WooPayments and 1 for get_wcpay_card_info(). The rest are cached.
this branch + Automattic/woocommerce-payments#11001 Only 2 external calls, since WooPayments populated the DB with a part of one of those calls' results and the filter takes precedence.

🗒️ Note regarding unit tests: Testing most of get_wcpay_card_info would require elaborate mocks of WooPayments or the plugin itself. Avoiding both, I've only added a test that ensures the filter takes precedence.

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Cache data while preparing WooPayments card info, allow the wc_order_payment_card_info filter to take precedence over the built-in fallback.

Let the filter take precedence, and actually cache the data within `get_wcpay_card_info`.
@RadoslavGeorgiev RadoslavGeorgiev requested a review from a team August 7, 2025 14:29
Copy link
Contributor

github-actions bot commented Aug 7, 2025

Testing Guidelines

Hi @woocommerce/gamma,

Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed.

Reminder: PR reviewers are required to document testing performed. This includes:

  • 🖼️ Screenshots or screen recordings.
  • 📝 List of functionality tested / steps followed.
  • 🌐 Site details (environment attributes such as hosting type, plugins, theme, store size, store age, and relevant settings).
  • 🔍 Any analysis performed, such as assessing potential impacts on environment attributes and other plugins, conducting performance profiling, or using LLM/AI-based analysis.

⚠️ Within the testing details you provide, please ensure that no sensitive information (such as API keys, passwords, user data, etc.) is included in this public issue.

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Aug 7, 2025
Copy link
Contributor

coderabbitai bot commented Aug 7, 2025

📝 Walkthrough

Walkthrough

This change introduces performance improvements for WooPayments card information retrieval in WooCommerce. It adds caching to avoid redundant API calls, updates the filter application order to prioritize custom overrides, and adjusts related test cases. A new test verifies that the filter can override the built-in fallback mechanism.

Changes

Cohort / File(s) Change Summary
Changelog Entry
plugins/woocommerce/changelog/60257-wooplug-5275-avoid-multiple-card-info-retrieval-calls-for-woopayments
Added a changelog entry describing the patch update, highlighting caching for WooPayments card info and filter order changes for performance improvements.
Payment Info Logic
plugins/woocommerce/src/Internal/Orders/PaymentInfo.php
Refactored get_card_info to always apply the filter first and fall back to WooPayments retrieval if needed. Introduced caching using a specific meta key, removed Jetpack constants, and updated caching logic.
Payment Info Tests
plugins/woocommerce/tests/php/src/Internal/Orders/PaymentInfoTest.php
Updated tests to use the new caching meta key, removed Jetpack constant dependency, and added a new test to verify that the filter can override card info retrieval.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant PaymentInfo
    participant WC_Order
    participant WooPayments_API

    Caller->>PaymentInfo: get_card_info(order)
    PaymentInfo->>PaymentInfo: apply 'wc_order_payment_card_info' filter
    alt Filter returns array
        PaymentInfo-->>Caller: return filtered card info
    else Filter returns empty/non-array
        PaymentInfo->>WC_Order: get payment method
        alt Payment method is 'woocommerce_payments'
            PaymentInfo->>WC_Order: get _wcpay_raw_payment_method_details meta
            alt Meta exists
                PaymentInfo-->>Caller: return cached card info
            else Meta missing
                PaymentInfo->>WooPayments_API: fetch card info
                PaymentInfo->>WC_Order: cache card info in meta
                PaymentInfo-->>Caller: return fetched card info
            end
        else Other payment method
            PaymentInfo-->>Caller: return empty array
        end
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0be3ee3 and 41d1e8a.

📒 Files selected for processing (1)
  • plugins/woocommerce/src/Internal/Orders/PaymentInfo.php (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/woocommerce/src/Internal/Orders/PaymentInfo.php
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: Metrics - @woocommerce/plugin-woocommerce [performance]
  • GitHub Check: PHP: 7.4 WP: latest - 1 [WP 6.7.3] 1/2 - @woocommerce/plugin-woocommerce [unit:php]
  • GitHub Check: Core e2e tests 5/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core e2e tests 3/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core e2e tests 2/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core API tests - @woocommerce/plugin-woocommerce [api]
  • GitHub Check: Core e2e tests 6/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core e2e tests 1/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core e2e tests 4/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: PHP: 8.4 WP: latest [WP latest] 2/2 - @woocommerce/plugin-woocommerce [unit:php]
  • GitHub Check: PHP: 7.4 WP: latest - 1 [WP 6.7.3] 2/2 - @woocommerce/plugin-woocommerce [unit:php]
  • GitHub Check: PHP: 8.4 WP: latest [WP latest] 1/2 - @woocommerce/plugin-woocommerce [unit:php]
  • GitHub Check: Lint - @woocommerce/plugin-woocommerce
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch wooplug-5275-avoid-multiple-card-info-retrieval-calls-for-woopayments

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
plugins/woocommerce/src/Internal/Orders/PaymentInfo.php (1)

102-141: LGTM! Caching implementation improves performance effectively.

The caching mechanism properly reduces redundant API calls by:

  • Using a WooCommerce-specific meta key for cached data
  • Checking cache before making external requests
  • Persisting cache with save_meta_data()
  • Maintaining existing error handling

Consider implementing cache invalidation when payment details might change (e.g., refunds, partial captures) to ensure data consistency.

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0aa1eb3 and a010904.

📒 Files selected for processing (3)
  • plugins/woocommerce/changelog/60257-wooplug-5275-avoid-multiple-card-info-retrieval-calls-for-woopayments (1 hunks)
  • plugins/woocommerce/src/Internal/Orders/PaymentInfo.php (3 hunks)
  • plugins/woocommerce/tests/php/src/Internal/Orders/PaymentInfoTest.php (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{php,js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/code-quality.mdc)

**/*.{php,js,jsx,ts,tsx}: Guard against unexpected inputs
Sanitize and validate any potentially dangerous inputs
Ensure code is backwards compatible
Write code that is readable and intuitive
Ensure code has unit or E2E tests where applicable

Files:

  • plugins/woocommerce/tests/php/src/Internal/Orders/PaymentInfoTest.php
  • plugins/woocommerce/src/Internal/Orders/PaymentInfo.php
**/*.{php,js,ts,jsx,tsx}

⚙️ CodeRabbit Configuration File

**/*.{php,js,ts,jsx,tsx}: Don't trust that extension developers will follow the best practices, make sure the code:

  • Guards against unexpected inputs.
  • Sanitizes and validates any potentially dangerous inputs.
  • Is backwards compatible.
  • Is readable and intuitive.
  • Has unit or E2E tests where applicable.

Files:

  • plugins/woocommerce/tests/php/src/Internal/Orders/PaymentInfoTest.php
  • plugins/woocommerce/src/Internal/Orders/PaymentInfo.php
🧠 Learnings (15)
📓 Common learnings
Learnt from: ralucaStan
PR: woocommerce/woocommerce#58782
File: plugins/woocommerce/client/blocks/assets/js/base/utils/render-frontend.tsx:0-0
Timestamp: 2025-06-16T16:12:12.148Z
Learning: For WooCommerce checkout blocks, lazy loading was removed in favor of direct imports to prevent sequential "popping" effects during component loading. This approach prioritizes user experience over code splitting, with minimal bundle size impact and improved performance (1.7s to 1.1s speed score improvement). The checkout flow benefits from having all components load together rather than incrementally.
Learnt from: jorgeatorres
PR: woocommerce/woocommerce#59675
File: .github/workflows/release-bump-as-requirement.yml:48-65
Timestamp: 2025-07-15T15:39:21.856Z
Learning: In WooCommerce core repository, changelog entries for all PRs live in `plugins/woocommerce/changelog/` directory and are processed during releases, not at the repository root level.
Learnt from: samueljseay
PR: woocommerce/woocommerce#58716
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts:83-101
Timestamp: 2025-06-17T07:07:53.443Z
Learning: In WooCommerce blocks, when porting existing code patterns that have known issues (like parseInt truncating decimal money values), maintain consistency with existing implementation rather than making isolated fixes. The preference is for systematic refactoring approaches (like broader Dinero adoption) over piecemeal changes.
Learnt from: vladolaru
PR: woocommerce/woocommerce#58784
File: plugins/woocommerce/client/admin/client/settings-payments/components/other-payment-gateways/other-payment-gateways.tsx:43-50
Timestamp: 2025-06-18T07:56:06.961Z
Learning: In plugins/woocommerce/client/admin/client/settings-payments/components/other-payment-gateways/other-payment-gateways.tsx, the user vladolaru prefers to keep the current setUpPlugin function signature with optional positional context parameter rather than refactoring to an options object or making context required.
Learnt from: vladolaru
PR: woocommerce/woocommerce#58784
File: plugins/woocommerce/src/Internal/Admin/Settings/Payments.php:431-439
Timestamp: 2025-06-17T14:19:30.933Z
Learning: In plugins/woocommerce/src/Internal/Admin/Settings/Payments.php, the process_payment_provider_states() method intentionally filters out payment providers that don't have a _suggestion_id. This is by design to only track state changes for gateways from partner extensions, not core WooCommerce gateways or other installed gateways.
Learnt from: vladolaru
PR: woocommerce/woocommerce#59486
File: plugins/woocommerce/src/Internal/Admin/Settings/PaymentsProviders/WooPayments/WooPaymentsService.php:1544-1544
Timestamp: 2025-07-08T11:18:07.871Z
Learning: WooCommerce has polyfills for newer PHP functions (like str_starts_with() from PHP 8.0+), so these functions can be safely used even though WooCommerce supports PHP 7.4+. No need to suggest PHP 7.4 compatible alternatives when polyfills are available.
Learnt from: nerrad
PR: woocommerce/woocommerce#60176
File: plugins/woocommerce/client/legacy/css/admin.scss:9088-9105
Timestamp: 2025-08-04T00:21:51.440Z
Learning: WooCommerce is currently in the midst of an admin redesign project, so temporary/short-term CSS solutions for admin pages are preferred over long-term refactoring when addressing immediate needs.
Learnt from: vladolaru
PR: woocommerce/woocommerce#58784
File: plugins/woocommerce/src/Internal/Admin/Settings/Payments.php:484-488
Timestamp: 2025-06-17T11:30:23.806Z
Learning: In the WooCommerce Payments settings provider state tracking system (plugins/woocommerce/src/Internal/Admin/Settings/Payments.php), when an extension is deactivated and its snapshot key disappears, only the 'extension_active' flag should be set to false while keeping other state flags like 'account_connected', 'needs_setup', 'test_mode', etc. unchanged. This is intentional behavior to preserve historical state information.
Learnt from: gigitux
PR: woocommerce/woocommerce#58846
File: plugins/woocommerce/client/blocks/tests/e2e/tests/all-products/all-products.block_theme.spec.ts:41-52
Timestamp: 2025-06-16T09:20:22.981Z
Learning: In WooCommerce E2E tests, the database is reset to the initial state for each test, so there's no need to manually restore global template changes (like clearing the header template) as the test infrastructure handles cleanup automatically.
Learnt from: vladolaru
PR: woocommerce/woocommerce#59160
File: plugins/woocommerce/client/admin/client/settings-payments/onboarding/providers/woopayments/steps/payment-methods-selection/index.tsx:0-0
Timestamp: 2025-06-26T14:56:54.917Z
Learning: In WooCommerce payments onboarding components (like plugins/woocommerce/client/admin/client/settings-payments/onboarding/providers/woopayments/steps/payment-methods-selection/index.tsx), when updating local React state based on API calls, the local state should only be updated after the API call succeeds to prevent inconsistent state if the save operation fails. The pattern is to move setPaymentMethodsState calls inside the .then() callback of the API promise.
Learnt from: vladolaru
PR: woocommerce/woocommerce#58784
File: plugins/woocommerce/src/Internal/Admin/Settings/PaymentsProviders/Monei.php:27-33
Timestamp: 2025-06-18T10:01:09.421Z
Learning: In WooCommerce payment gateway provider classes, prefer using `is_callable()` over `method_exists()` when checking for method availability, as it properly accounts for method visibility (public/private/protected) rather than just existence.
Learnt from: NeosinneR
PR: woocommerce/woocommerce#60129
File: plugins/woocommerce/includes/wc-coupon-functions.php:145-154
Timestamp: 2025-07-31T11:18:02.478Z
Learning: In WooCommerce codebase, when table names are hardcoded (like `$wpdb->prefix . 'wc_order_coupon_lookup'`), the preference is to maintain consistency with existing patterns throughout the codebase rather than making isolated security improvements when the risk is minimal (since $wpdb->prefix is controlled by WordPress and table names are hardcoded constants).
📚 Learning: for woocommerce checkout blocks, lazy loading was removed in favor of direct imports to prevent sequ...
Learnt from: ralucaStan
PR: woocommerce/woocommerce#58782
File: plugins/woocommerce/client/blocks/assets/js/base/utils/render-frontend.tsx:0-0
Timestamp: 2025-06-16T16:12:12.148Z
Learning: For WooCommerce checkout blocks, lazy loading was removed in favor of direct imports to prevent sequential "popping" effects during component loading. This approach prioritizes user experience over code splitting, with minimal bundle size impact and improved performance (1.7s to 1.1s speed score improvement). The checkout flow benefits from having all components load together rather than incrementally.

Applied to files:

  • plugins/woocommerce/changelog/60257-wooplug-5275-avoid-multiple-card-info-retrieval-calls-for-woopayments
📚 Learning: in woocommerce core repository, changelog entries for all prs live in `plugins/woocommerce/changelog...
Learnt from: jorgeatorres
PR: woocommerce/woocommerce#59675
File: .github/workflows/release-bump-as-requirement.yml:48-65
Timestamp: 2025-07-15T15:39:21.856Z
Learning: In WooCommerce core repository, changelog entries for all PRs live in `plugins/woocommerce/changelog/` directory and are processed during releases, not at the repository root level.

Applied to files:

  • plugins/woocommerce/changelog/60257-wooplug-5275-avoid-multiple-card-info-retrieval-calls-for-woopayments
📚 Learning: in plugins/woocommerce/src/internal/admin/settings/payments.php, the process_payment_provider_states...
Learnt from: vladolaru
PR: woocommerce/woocommerce#58784
File: plugins/woocommerce/src/Internal/Admin/Settings/Payments.php:431-439
Timestamp: 2025-06-17T14:19:30.933Z
Learning: In plugins/woocommerce/src/Internal/Admin/Settings/Payments.php, the process_payment_provider_states() method intentionally filters out payment providers that don't have a _suggestion_id. This is by design to only track state changes for gateways from partner extensions, not core WooCommerce gateways or other installed gateways.

Applied to files:

  • plugins/woocommerce/changelog/60257-wooplug-5275-avoid-multiple-card-info-retrieval-calls-for-woopayments
  • plugins/woocommerce/tests/php/src/Internal/Orders/PaymentInfoTest.php
  • plugins/woocommerce/src/Internal/Orders/PaymentInfo.php
📚 Learning: in woocommerce release workflows, the version variable used in changelog generation comes from the `...
Learnt from: jorgeatorres
PR: woocommerce/woocommerce#60250
File: .github/workflows/release-compile-changelog.yml:165-166
Timestamp: 2025-08-07T10:34:27.702Z
Learning: In WooCommerce release workflows, the VERSION variable used in changelog generation comes from the `validate-selected-branch-version` step, which extracts the version from `plugins/woocommerce/woocommerce.php` using `grep -oP '(?<=Version: )(.+)'` and validates it matches the input version. This ensures the version is always in the correct format by the time it reaches the changelog generation step, making additional error handling for version format validation unnecessary.

Applied to files:

  • plugins/woocommerce/changelog/60257-wooplug-5275-avoid-multiple-card-info-retrieval-calls-for-woopayments
📚 Learning: in plugins/woocommerce/client/admin/client/settings-payments/components/other-payment-gateways/other...
Learnt from: vladolaru
PR: woocommerce/woocommerce#58784
File: plugins/woocommerce/client/admin/client/settings-payments/components/other-payment-gateways/other-payment-gateways.tsx:43-50
Timestamp: 2025-06-18T07:56:06.961Z
Learning: In plugins/woocommerce/client/admin/client/settings-payments/components/other-payment-gateways/other-payment-gateways.tsx, the user vladolaru prefers to keep the current setUpPlugin function signature with optional positional context parameter rather than refactoring to an options object or making context required.

Applied to files:

  • plugins/woocommerce/changelog/60257-wooplug-5275-avoid-multiple-card-info-retrieval-calls-for-woopayments
📚 Learning: in woocommerce blocks, when porting existing code patterns that have known issues (like parseint tru...
Learnt from: samueljseay
PR: woocommerce/woocommerce#58716
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts:83-101
Timestamp: 2025-06-17T07:07:53.443Z
Learning: In WooCommerce blocks, when porting existing code patterns that have known issues (like parseInt truncating decimal money values), maintain consistency with existing implementation rather than making isolated fixes. The preference is for systematic refactoring approaches (like broader Dinero adoption) over piecemeal changes.

Applied to files:

  • plugins/woocommerce/changelog/60257-wooplug-5275-avoid-multiple-card-info-retrieval-calls-for-woopayments
📚 Learning: woocommerce has polyfills for newer php functions (like str_starts_with() from php 8.0+), so these f...
Learnt from: vladolaru
PR: woocommerce/woocommerce#59486
File: plugins/woocommerce/src/Internal/Admin/Settings/PaymentsProviders/WooPayments/WooPaymentsService.php:1544-1544
Timestamp: 2025-07-08T11:18:07.871Z
Learning: WooCommerce has polyfills for newer PHP functions (like str_starts_with() from PHP 8.0+), so these functions can be safely used even though WooCommerce supports PHP 7.4+. No need to suggest PHP 7.4 compatible alternatives when polyfills are available.

Applied to files:

  • plugins/woocommerce/changelog/60257-wooplug-5275-avoid-multiple-card-info-retrieval-calls-for-woopayments
📚 Learning: for woocommerce payments onboarding step tracking in useeffect hooks, only include the active step i...
Learnt from: vladolaru
PR: woocommerce/woocommerce#58784
File: plugins/woocommerce/client/admin/client/settings-payments/onboarding/components/stepper/index.tsx:57-67
Timestamp: 2025-06-20T13:08:44.017Z
Learning: For WooCommerce Payments onboarding step tracking in useEffect hooks, only include the active step in the dependency array, not the context object. The sessionEntryPoint is static throughout the onboarding session and tracking should only fire on actual step navigation, not context changes.

Applied to files:

  • plugins/woocommerce/changelog/60257-wooplug-5275-avoid-multiple-card-info-retrieval-calls-for-woopayments
📚 Learning: woocommerce is currently in the midst of an admin redesign project, so temporary/short-term css solu...
Learnt from: nerrad
PR: woocommerce/woocommerce#60176
File: plugins/woocommerce/client/legacy/css/admin.scss:9088-9105
Timestamp: 2025-08-04T00:21:51.440Z
Learning: WooCommerce is currently in the midst of an admin redesign project, so temporary/short-term CSS solutions for admin pages are preferred over long-term refactoring when addressing immediate needs.

Applied to files:

  • plugins/woocommerce/changelog/60257-wooplug-5275-avoid-multiple-card-info-retrieval-calls-for-woopayments
📚 Learning: in woocommerce payment gateway provider classes, prefer using `is_callable()` over `method_exists()`...
Learnt from: vladolaru
PR: woocommerce/woocommerce#58784
File: plugins/woocommerce/src/Internal/Admin/Settings/PaymentsProviders/Monei.php:27-33
Timestamp: 2025-06-18T10:01:09.421Z
Learning: In WooCommerce payment gateway provider classes, prefer using `is_callable()` over `method_exists()` when checking for method availability, as it properly accounts for method visibility (public/private/protected) rather than just existence.

Applied to files:

  • plugins/woocommerce/tests/php/src/Internal/Orders/PaymentInfoTest.php
  • plugins/woocommerce/src/Internal/Orders/PaymentInfo.php
📚 Learning: in the woocommerce payments settings provider state tracking system (plugins/woocommerce/src/interna...
Learnt from: vladolaru
PR: woocommerce/woocommerce#58784
File: plugins/woocommerce/src/Internal/Admin/Settings/Payments.php:484-488
Timestamp: 2025-06-17T11:30:23.806Z
Learning: In the WooCommerce Payments settings provider state tracking system (plugins/woocommerce/src/Internal/Admin/Settings/Payments.php), when an extension is deactivated and its snapshot key disappears, only the 'extension_active' flag should be set to false while keeping other state flags like 'account_connected', 'needs_setup', 'test_mode', etc. unchanged. This is intentional behavior to preserve historical state information.

Applied to files:

  • plugins/woocommerce/tests/php/src/Internal/Orders/PaymentInfoTest.php
📚 Learning: in woocommerce e2e tests, the database is reset to the initial state for each test, so there's no ne...
Learnt from: gigitux
PR: woocommerce/woocommerce#58846
File: plugins/woocommerce/client/blocks/tests/e2e/tests/all-products/all-products.block_theme.spec.ts:41-52
Timestamp: 2025-06-16T09:20:22.981Z
Learning: In WooCommerce E2E tests, the database is reset to the initial state for each test, so there's no need to manually restore global template changes (like clearing the header template) as the test infrastructure handles cleanup automatically.

Applied to files:

  • plugins/woocommerce/tests/php/src/Internal/Orders/PaymentInfoTest.php
📚 Learning: in woocommerce codebase, when table names are hardcoded (like `$wpdb->prefix . 'wc_order_coupon_look...
Learnt from: NeosinneR
PR: woocommerce/woocommerce#60129
File: plugins/woocommerce/includes/wc-coupon-functions.php:145-154
Timestamp: 2025-07-31T11:18:02.478Z
Learning: In WooCommerce codebase, when table names are hardcoded (like `$wpdb->prefix . 'wc_order_coupon_lookup'`), the preference is to maintain consistency with existing patterns throughout the codebase rather than making isolated security improvements when the risk is minimal (since $wpdb->prefix is controlled by WordPress and table names are hardcoded constants).

Applied to files:

  • plugins/woocommerce/src/Internal/Orders/PaymentInfo.php
📚 Learning: in woocommerce's cartschema::get_item_response() method, when called in the context of blocksshareds...
Learnt from: mreishus
PR: woocommerce/woocommerce#58891
File: plugins/woocommerce/src/Blocks/Utils/BlocksSharedState.php:0-0
Timestamp: 2025-06-16T21:59:26.255Z
Learning: In WooCommerce's CartSchema::get_item_response() method, when called in the context of BlocksSharedState::register_cart_interactivity(), the method returns a plain array rather than a WP_REST_Response object, making it directly suitable for wp_interactivity_state() without needing to call ->get_data().

Applied to files:

  • plugins/woocommerce/src/Internal/Orders/PaymentInfo.php
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: Core e2e tests 6/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Metrics - @woocommerce/plugin-woocommerce [performance]
  • GitHub Check: Core e2e tests 3/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core e2e tests 5/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core e2e tests 4/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: PHP: 7.4 WP: latest - 1 [WP 6.7.3] 1/2 - @woocommerce/plugin-woocommerce [unit:php]
  • GitHub Check: PHP: 7.4 WP: latest - 1 [WP 6.7.3] 2/2 - @woocommerce/plugin-woocommerce [unit:php]
  • GitHub Check: Core e2e tests 1/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core API tests - @woocommerce/plugin-woocommerce [api]
  • GitHub Check: Core e2e tests 2/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Lint - @woocommerce/plugin-woocommerce
  • GitHub Check: PHP: 8.4 WP: latest [WP latest] 2/2 - @woocommerce/plugin-woocommerce [unit:php]
  • GitHub Check: PHP: 8.4 WP: latest [WP latest] 1/2 - @woocommerce/plugin-woocommerce [unit:php]
  • GitHub Check: build
🔇 Additional comments (4)
plugins/woocommerce/src/Internal/Orders/PaymentInfo.php (1)

37-51: LGTM! Filter precedence implementation is correct.

The reordering of filter application logic properly allows the wc_order_payment_card_info filter to take precedence over the built-in WooPayments fallback. The type checking with is_array() guards against unexpected filter return values, and the fallback logic is preserved when the filter returns empty data.

plugins/woocommerce/changelog/60257-wooplug-5275-avoid-multiple-card-info-retrieval-calls-for-woopayments (1)

1-4: LGTM! Changelog entry accurately describes the changes.

The changelog properly categorizes this as a patch-level performance improvement and clearly describes both key changes: caching implementation and filter precedence modification.

plugins/woocommerce/tests/php/src/Internal/Orders/PaymentInfoTest.php (2)

26-27: LGTM! Test updated to match new caching implementation.

The meta key change to _wcpay_raw_payment_method_details correctly aligns with the updated caching mechanism in the PaymentInfo class.


45-67: LGTM! Test comprehensively validates filter precedence.

The new test effectively verifies that the wc_order_payment_card_info filter takes precedence over cached meta data by:

  • Setting up fallback WooPayments data in order meta
  • Adding a filter that returns different data
  • Asserting the filter result is returned
  • Properly cleaning up to avoid side effects

This provides essential coverage for the filter precedence changes.

Copy link
Contributor

github-actions bot commented Aug 7, 2025

Test using WordPress Playground

The changes in this pull request can be previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Test this pull request with WordPress Playground.

Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit.

Copy link
Contributor

@marcinbot marcinbot left a comment

Choose a reason for hiding this comment

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

Looks good and works well! :shipit:

@RadoslavGeorgiev RadoslavGeorgiev merged commit 8455e49 into trunk Aug 7, 2025
47 of 49 checks passed
@RadoslavGeorgiev RadoslavGeorgiev deleted the wooplug-5275-avoid-multiple-card-info-retrieval-calls-for-woopayments branch August 7, 2025 16:18
@github-actions github-actions bot added this to the 10.2.0 milestone Aug 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: woocommerce Issues related to the WooCommerce Core plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants