Skip to content

Add WCCOM connection status to search request. #59658

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

Merged
merged 7 commits into from
Jul 17, 2025
Merged

Conversation

thilinah
Copy link
Contributor

@thilinah thilinah commented Jul 15, 2025

Submission Review Guidelines:

Changes proposed in this Pull Request:

Closes # .

(For Bug Fixes) Bug introduced in PR # .

Screenshots or screen recordings:

Before After

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Build assets pnpm --filter='@woocommerce/plugin-woocommerce' build
  2. Create a WooCommerce build based on this PR. (npm run build: zip) and replace WooCommerce in your test site with the new build or use the wp env based local development environment.
  3. Visit in-app extensions tab
  4. Open the dev tools network tab and filter for requests to wp-json/wccom-extensions/
  5. Notice that the search requests includes two new get parameters.
  6. connection should be 1 or 0 based on the WCCOM connection status.
  7. tracking_allowed should be 1 or 0 based on the value of the option woocommerce_allow_tracking

The search endpoint get called via backend during the onboarding flow here. But non of these paramters are applicable there.

Testing that has already taken place:

Changelog entry

  • Automatically create a changelog entry from the details below.
  • This Pull Request does not require a changelog entry. (Comment required 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

Pass the WCCOM connection status of the store as a paramter in extension serch request

Changelog Entry Comment

Comment

@thilinah thilinah self-assigned this Jul 15, 2025
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Jul 15, 2025
@thilinah thilinah requested review from Copilot, a team, mcliwanow and KokkieH and removed request for a team July 15, 2025 09:42
@thilinah thilinah marked this pull request as ready for review July 15, 2025 09:43
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds WCCOM connection status and tracking preferences to extension search requests. The changes enable the marketplace API to receive information about the store's connection status and whether tracking is allowed.

  • Adds tracking preference data to the helper admin configuration
  • Includes WCCOM connection status and tracking preference as URL parameters in search requests

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
plugins/woocommerce/includes/admin/helper/class-wc-helper-admin.php Adds tracking preference to admin configuration data
plugins/woocommerce/client/admin/client/marketplace/utils/functions.tsx Includes connection status and tracking preference as search parameters

@@ -123,6 +123,11 @@ async function fetchSearchResults(
params.set( 'locale', LOCALE.userLocale );
}

const wccomSettings = getAdminSetting( 'wccomHelper', {} );
params.set( 'connection', wccomSettings.isConnected ? '1' : '0' );
Copy link
Preview

Copilot AI Jul 15, 2025

Choose a reason for hiding this comment

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

The wccomSettings object is accessed without null/undefined checks. Consider adding a fallback for isConnected property to handle cases where the property might not exist.

Suggested change
params.set( 'connection', wccomSettings.isConnected ? '1' : '0' );
params.set( 'connection', ( wccomSettings.isConnected ?? false ) ? '1' : '0' );

Copilot uses AI. Check for mistakes.

const wccomSettings = getAdminSetting( 'wccomHelper', {} );
params.set( 'connection', wccomSettings.isConnected ? '1' : '0' );

params.set( 'tracking_allowed', wccomSettings.trackingAllowed ? '1' : '0' );
Copy link
Preview

Copilot AI Jul 15, 2025

Choose a reason for hiding this comment

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

Similar to the connection parameter, consider adding a fallback for trackingAllowed property to handle cases where the property might not exist in wccomSettings.

Suggested change
params.set( 'tracking_allowed', wccomSettings.trackingAllowed ? '1' : '0' );
params.set( 'tracking_allowed', wccomSettings.trackingAllowed !== undefined ? ( wccomSettings.trackingAllowed ? '1' : '0' ) : '0' );

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Testing Guidelines

Hi @mcliwanow @KokkieH @Copilot ,

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.

Copy link
Contributor

coderabbitai bot commented Jul 15, 2025

Caution

Review failed

The head commit changed during the review from db7f068 to 0ab7e8d.

📝 Walkthrough

Walkthrough

The changes introduce two new parameters, connection and tracking_allowed, to the WooCommerce.com extension search request. These parameters are derived from the store's connection status and tracking preference, which are now included in the marketplace settings and utilized in the client-side search utility.

Changes

File(s) Change Summary
plugins/woocommerce/changelog/59658-update-wccom-1592 Added changelog entry for passing WCCOM connection status in extension search requests.
plugins/woocommerce/includes/admin/helper/class-wc-helper-admin.php Added trackingAllowed to the wccomHelper settings array in marketplace settings.
plugins/woocommerce/client/admin/client/marketplace/utils/functions.tsx Modified fetchSearchResults to append connection and tracking_allowed parameters to URL.

Sequence Diagram(s)

sequenceDiagram
    participant AdminUI as Admin UI
    participant HelperAdmin as WC_Helper_Admin (PHP)
    participant API as WooCommerce.com API

    AdminUI->>HelperAdmin: Request marketplace settings
    HelperAdmin-->>AdminUI: Return settings (including isConnected, trackingAllowed)
    AdminUI->>API: Send extension search request with connection and tracking_allowed params
    API-->>AdminUI: Return search results
Loading

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.
    • @coderabbitai modularize this function.
  • 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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

github-actions bot commented Jul 15, 2025

Size Change: +56 B (0%)

Total Size: 5.86 MB

compressed-size-action

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: 1

♻️ Duplicate comments (1)
plugins/woocommerce/client/admin/client/marketplace/utils/functions.tsx (1)

126-129: Add defensive null/undefined checks for wccomSettings properties.

The code accesses wccomSettings.isConnected and wccomSettings.trackingAllowed without proper null/undefined checks, which could cause runtime errors if these properties don't exist.

-	const wccomSettings = getAdminSetting( 'wccomHelper', {} );
-	params.set( 'connection', wccomSettings.isConnected ? '1' : '0' );
-
-	params.set( 'tracking_allowed', wccomSettings.trackingAllowed ? '1' : '0' );
+	const wccomSettings = getAdminSetting( 'wccomHelper', {} );
+	params.set( 'connection', ( wccomSettings.isConnected ?? false ) ? '1' : '0' );
+
+	params.set( 'tracking_allowed', ( wccomSettings.trackingAllowed ?? false ) ? '1' : '0' );
🧹 Nitpick comments (1)
plugins/woocommerce/includes/admin/helper/class-wc-helper-admin.php (1)

92-92: Use WooCommerce's idiomatic boolean conversion helper.

Based on WooCommerce coding patterns, prefer using wc_string_to_bool() over direct string comparison for converting option values to boolean.

-			'trackingAllowed'            => 'yes' === get_option( 'woocommerce_allow_tracking' ),
+			'trackingAllowed'            => wc_string_to_bool( get_option( 'woocommerce_allow_tracking' ) ),
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1a5c8d6 and 5a58826.

📒 Files selected for processing (3)
  • plugins/woocommerce/changelog/59658-update-wccom-1592 (1 hunks)
  • plugins/woocommerce/client/admin/client/marketplace/utils/functions.tsx (1 hunks)
  • plugins/woocommerce/includes/admin/helper/class-wc-helper-admin.php (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{php,js,ts,jsx,tsx}

Instructions used from:

Sources:
⚙️ CodeRabbit Configuration File

🧠 Learnings (4)
📓 Common learnings
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: CR
PR: woocommerce/woocommerce#0
File: .cursor/rules/generate-pr-description.mdc:0-0
Timestamp: 2025-06-30T09:26:55.361Z
Learning: Provide clear, step-by-step instructions for how to test the changes in the PR description.
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: opr
PR: woocommerce/woocommerce#0
File: :0-0
Timestamp: 2025-06-20T17:38:16.565Z
Learning: WooCommerce legacy JavaScript files in plugins/woocommerce/client/legacy/js/ must use older JavaScript syntax and cannot use modern features like optional chaining (?.) due to browser compatibility requirements. Explicit null checking with && operators should be used instead.
Learnt from: triple0t
PR: woocommerce/woocommerce#59186
File: packages/js/email-editor/src/store/initial-state.ts:9-10
Timestamp: 2025-06-26T12:13:32.062Z
Learning: In WooCommerce email editor store initialization (packages/js/email-editor/src/store/initial-state.ts), the current_post_id and current_post_type from window.WooCommerceEmailEditor are required parameters that should cause explicit errors if missing, rather than using fallback values or optional chaining. The design preference is to fail fast when critical initialization data is unavailable.
plugins/woocommerce/changelog/59658-update-wccom-1592 (3)
Learnt from: opr
PR: woocommerce/woocommerce#0
File: :0-0
Timestamp: 2025-06-20T17:38:16.565Z
Learning: WooCommerce legacy JavaScript files in plugins/woocommerce/client/legacy/js/ must use older JavaScript syntax and cannot use modern features like optional chaining (?.) due to browser compatibility requirements. Explicit null checking with && operators should be used instead.
Learnt from: prettyboymp
PR: woocommerce/woocommerce#59048
File: .github/workflows/cherry-pick-milestoned-prs.yml:60-83
Timestamp: 2025-06-26T12:45:40.709Z
Learning: WooCommerce uses WordPress versioning conventions where minor versions in X.Y.Z format are constrained to 0-9 (Y cannot exceed 9). This means version increment logic should reset minor to 0 and increment major when minor reaches 9, rather than allowing two-digit minor versions like 9.10 or 9.11.
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.
plugins/woocommerce/includes/admin/helper/class-wc-helper-admin.php (3)
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: 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#58784
File: plugins/woocommerce/src/Internal/Admin/Settings/PaymentsProviders/Paytrail.php:29-35
Timestamp: 2025-06-18T09:58:10.616Z
Learning: In WooCommerce codebase, prefer using `wc_string_to_bool()` over `filter_var($value, FILTER_VALIDATE_BOOLEAN)` when converting option values (especially 'yes'/'no' style flags) to boolean. The WooCommerce helper function is more idiomatic and handles the conversion consistently with core WooCommerce patterns.
plugins/woocommerce/client/admin/client/marketplace/utils/functions.tsx (3)
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: opr
PR: woocommerce/woocommerce#0
File: :0-0
Timestamp: 2025-06-20T17:38:16.565Z
Learning: WooCommerce legacy JavaScript files in plugins/woocommerce/client/legacy/js/ must use older JavaScript syntax and cannot use modern features like optional chaining (?.) due to browser compatibility requirements. Explicit null checking with && operators should be used instead.
Learnt from: samueljseay
PR: woocommerce/woocommerce#59051
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-footer-block/index.tsx:66-70
Timestamp: 2025-06-23T05:47:52.696Z
Learning: For WooCommerce mini-cart blocks in plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/, the standardized conditional pattern for experimental features should be `if ( isExperimentalMiniCartEnabled() ) { blockSettings.save = () => <InnerBlocks.Content />; }` - defaulting to the traditional Save component and only overriding when the experimental feature is enabled.

Copy link
Contributor

github-actions bot commented Jul 15, 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

@mcliwanow mcliwanow left a comment

Choose a reason for hiding this comment

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

Tested on my dev site. I have correct values for both params for In-App search requests 👍

thilinah and others added 3 commits July 17, 2025 14:43
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@thilinah thilinah merged commit f583a03 into trunk Jul 17, 2025
40 checks passed
@thilinah thilinah deleted the update/wccom-1592 branch July 17, 2025 23:52
@github-actions github-actions bot added this to the 10.1.0 milestone Jul 17, 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