-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
Conversation
There was a problem hiding this 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' ); |
There was a problem hiding this comment.
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.
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' ); |
There was a problem hiding this comment.
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.
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.
…mmerce, woocommerce/client/admin
Testing GuidelinesHi @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:
|
📝 WalkthroughWalkthroughThe changes introduce two new parameters, Changes
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
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
Documentation and Community
|
Size Change: +56 B (0%) Total Size: 5.86 MB |
There was a problem hiding this 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
andwccomSettings.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
📒 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.
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. 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. |
There was a problem hiding this 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 👍
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…mmerce, woocommerce/client/admin
Submission Review Guidelines:
Changes proposed in this Pull Request:
Closes # .
(For Bug Fixes) Bug introduced in PR # .
Screenshots or screen recordings:
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
pnpm --filter='@woocommerce/plugin-woocommerce' build
npm run build: zip
) and replace WooCommerce in your test site with the new build or use the wp env based local development environment.wp-json/wccom-extensions/
connection
should be 1 or 0 based on the WCCOM connection status.tracking_allowed
should be 1 or 0 based on the value of the optionwoocommerce_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
Changelog Entry Details
Significance
Type
Message
Pass the WCCOM connection status of the store as a paramter in extension serch request
Changelog Entry Comment
Comment