Skip to content

Trigger fetching product suggestions data on WC-Admin page views #59726

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 4 commits into from
Jul 21, 2025

Conversation

KokkieH
Copy link
Contributor

@KokkieH KokkieH commented Jul 17, 2025

  • This ensures new users will already see suggestions the first time they land on the empty orders screen

Submission Review Guidelines:

Changes proposed in this Pull Request:

We use an async process to fetch product recommendations shown in the editor and empty orders screen. This process is only triggered once either of those pages are viewed, with the result that a first-time visitor won't see any recommendations.

We're adding a function that triggers just fetching recommendations (without loading all the JS needed for rendering them) on any WC-Admin page view. That way new users will already see recommendations the first time they visit the screens where those are displayed.

Closes WCCOM-1618

How to test the changes in this Pull Request:

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

  1. Check out this branch, go to cd plugins/woocommerce and run pnpm watch:build
  2. Start your environment with pnpm env:start
  3. To ensure you don't have any cached recommendations, run pnpm -- wp-env run cli wp option delete woocommerce_marketplace_suggestions
  4. Visit any WP-Admin page
  5. Go to http://localhost:8888/wp-admin/tools.php?page=action-scheduler&s=woocommerce_update_marketplace_suggestions&bulk_action=Apply&paged=1 and confirm there's no pending job scheduled.
  6. Visit WooCommerce->Home, then refresh the Scheduled Actions page. Now you should see a pending action.
  7. Run the action and go to WooCommerce ->Orders. If you don't have any orders you should see the suggestions populated.
  8. Visit any WC admin page again or open the product editor. Then refresh Scheduled Actions again. You shouldn't see any pending action this time, as suggestions should be cached now.
  9. Please test around this issue.

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

Check if product suggestions should be fetched whenever someone views a WC Admin page.

Changelog Entry Comment

Comment

- This ensures new users will already see suggestions the first time they land on the empty orders screen
@KokkieH KokkieH self-assigned this Jul 17, 2025
@KokkieH KokkieH added Desire Woo Marketing and WooCommerce.com customer experience team: Desire labels Jul 17, 2025
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Jul 17, 2025
@KokkieH KokkieH marked this pull request as ready for review July 17, 2025 09:37
@KokkieH KokkieH requested review from a team, mcliwanow and raicem and removed request for a team July 17, 2025 09:37
Copy link
Contributor

github-actions bot commented Jul 17, 2025

Testing Guidelines

Hi @mcliwanow @raicem ,

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 17, 2025

📝 Walkthrough

Walkthrough

A changelog entry was added for a WooCommerce update that introduces a new check to determine if product suggestions should be fetched when viewing WooCommerce Admin pages. The core logic update registers a new action hook, triggering a suggestions fetch specifically when the WooCommerce admin dashboard is accessed.

Changes

File(s) Change Summary
plugins/woocommerce/changelog/59726-update-WCCOM-1618-improve-fetching-suggestions Added changelog entry for update 59726 describing improved suggestion fetching on admin pages.
plugins/woocommerce/includes/admin/marketplace-suggestions/class-wc-marketplace-suggestions.php Added action hook and new static method to trigger suggestions fetch on WooCommerce admin screen.

Sequence Diagram(s)

sequenceDiagram
    participant AdminUser as Admin User
    participant WP as WordPress
    participant WCMS as WC_Marketplace_Suggestions

    AdminUser->>WP: Accesses WooCommerce Admin Dashboard
    WP->>WCMS: Fires 'current_screen' action
    WCMS->>WCMS: maybe_trigger_suggestions_fetch()
    WCMS->>WCMS: Checks if current screen is 'woocommerce_page_wc-admin'
    alt Suggestions allowed
        WCMS->>WCMS: get_suggestions_api_data()
    end
Loading

Estimated code review effort

  • plugins/woocommerce/changelog/59726-update-WCCOM-1618-improve-fetching-suggestions: 1 (<30 minutes)
  • plugins/woocommerce/includes/admin/marketplace-suggestions/class-wc-marketplace-suggestions.php: 2 (30–90 minutes)

📜 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 382a140 and 39f8266.

📒 Files selected for processing (1)
  • plugins/woocommerce/includes/admin/marketplace-suggestions/class-wc-marketplace-suggestions.php (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/woocommerce/includes/admin/marketplace-suggestions/class-wc-marketplace-suggestions.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). (24)
  • GitHub Check: Blocks e2e tests 8/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 2/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 10/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 9/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 1/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 5/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 4/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 6/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 3/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 7/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: PHP: 7.4 WP: latest - 1 [WP 6.7.2] 2/2 - @woocommerce/plugin-woocommerce [unit:php]
  • GitHub Check: Metrics - @woocommerce/plugin-woocommerce [performance]
  • GitHub Check: Core e2e tests 5/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core API tests - @woocommerce/plugin-woocommerce [api]
  • GitHub Check: Core e2e tests 4/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core e2e tests 2/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core e2e tests 6/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core e2e tests 3/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.2] 1/2 - @woocommerce/plugin-woocommerce [unit:php]
  • GitHub Check: Core e2e tests 1/6 - @woocommerce/plugin-woocommerce [e2e]
  • 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

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

@thilinah thilinah left a comment

Choose a reason for hiding this comment

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

Thanks @KokkieH. LGTM and works as expected.

@KokkieH KokkieH enabled auto-merge (squash) July 21, 2025 05:59
@KokkieH KokkieH merged commit b6b024d into trunk Jul 21, 2025
66 of 68 checks passed
@KokkieH KokkieH deleted the update/WCCOM-1618-improve-fetching-suggestions branch July 21, 2025 06:41
@github-actions github-actions bot added this to the 10.1.0 milestone Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Desire Woo Marketing and WooCommerce.com customer experience plugin: woocommerce Issues related to the WooCommerce Core plugin. team: Desire
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants