Skip to content

Conversation

@moon0326
Copy link
Contributor

@moon0326 moon0326 commented May 13, 2023

Submission Review Guidelines:

Changes proposed in this Pull Request:

Closes #38285

This PR adds woocommerce_suggest_jetpack filter to the free extensions REST endpoint to exclude Jetpack suggestion in OBW.

How to test the changes in this Pull Request:

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

  1. Download this plugin and activate it
  2. Start with a fresh site or make sure to remove Jetpack completely
  3. Start OBW
  4. Confirm Jetpack is not listed in Business Details -> Free features

@moon0326 moon0326 requested review from a team, adrianduffell and rjchow May 13, 2023 01:21
@github-actions github-actions bot added focus: react admin [team:Ghidorah] plugin: woocommerce Issues related to the WooCommerce Core plugin. labels May 13, 2023
@github-actions
Copy link
Contributor

Hi @adrianduffell, @rjchow, @woocommerce/ghidorah

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

@github-actions
Copy link
Contributor

github-actions bot commented May 13, 2023

Test Results Summary

Commit SHA: af67291

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests26700202691m 13s
E2E Tests1890010019914m 18s

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

@codecov
Copy link

codecov bot commented May 13, 2023

Codecov Report

Merging #38286 (af67291) into trunk (6ed8fb4) will increase coverage by 0.3%.
The diff coverage is 58.8%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             trunk   #38286     +/-   ##
==========================================
+ Coverage     51.2%    51.6%   +0.3%     
- Complexity   17439    17444      +5     
==========================================
  Files          440      440             
  Lines        80722    80297    -425     
==========================================
+ Hits         41346    41403     +57     
+ Misses       39376    38894    -482     
Impacted Files Coverage Δ
...ommerce/includes/abstracts/abstract-wc-product.php 88.0% <0.0%> (-0.3%) ⬇️
...ins/woocommerce/includes/class-wc-form-handler.php 5.6% <0.0%> (-<0.1%) ⬇️
...ugins/woocommerce/includes/class-wc-post-types.php 1.8% <ø> (+0.8%) ⬆️
...woocommerce/includes/class-wc-product-variable.php 75.7% <0.0%> (-0.7%) ⬇️
...ins/woocommerce/includes/wc-template-functions.php 12.2% <0.0%> (-<0.1%) ⬇️
...lugins/woocommerce/includes/class-wc-countries.php 95.4% <100.0%> (ø)
...rs/Version2/class-wc-rest-orders-v2-controller.php 94.4% <100.0%> (ø)
...llers/Version3/class-wc-rest-orders-controller.php 80.5% <100.0%> (ø)
plugins/woocommerce/includes/wc-core-functions.php 63.6% <100.0%> (ø)

... and 5 files with indirect coverage changes

@moon0326 moon0326 changed the title Add a filter to free extensions REST endpoint Add woocommerce_suggest_jetpack filter to exlude Jetpack suggestion in OBW May 15, 2023
@moon0326 moon0326 force-pushed the add/38285-add-filter-to-free-extensions-rest-endpoint branch from d1fcefe to 0cd7c09 Compare May 15, 2023 19:50
*
* @since 7.8
*/
if ( false === apply_filters( 'woocommerce_suggest_jetpack', true ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if "woocommerce_onboarding_suggest_jetpack" would be more explicit. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was my first thought as well. However, I think we plan to use woocommerce_suggest_jetpack on other pages where we also suggest Jetpack.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup we should roll this out everywhere Jetpack is suggested 👍

I'll audit wc-admin for this and create a new issue.

chihsuan
chihsuan previously approved these changes May 18, 2023
Copy link
Member

@chihsuan chihsuan left a comment

Choose a reason for hiding this comment

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

Thanks for adding the filter!

Left a two minor suggestions. Others look good! 👍

Copy link
Contributor

@adrianduffell adrianduffell left a comment

Choose a reason for hiding this comment

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

LGTM @moon0326 🚀

I left a nitpick possible improvement, but feel free to merge without addressing it.

*/
if ( false === apply_filters( 'woocommerce_suggest_jetpack', true ) ) {
foreach ( $extensions as &$extension ) {
$extension['plugins'] = array_filter(
Copy link
Contributor

@adrianduffell adrianduffell May 21, 2023

Choose a reason for hiding this comment

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

Nitpick: Should the array_filter be used on $extensions so that it outright removes the extension completely?

I think at the moment, only the jetpack plugin slug would be removed from the extension data, but the extension still remains. I think this still works, but is dependent on the consuming code having a defensive check for an empty plugin array.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adrianduffell Good point. Let's merge it for now and get back to it later. I'm not sure if the client code is checking for the extension. We need to test it further if we want to remove the list completely.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good!

@moon0326 moon0326 merged commit 6d40140 into trunk May 21, 2023
@moon0326 moon0326 deleted the add/38285-add-filter-to-free-extensions-rest-endpoint branch May 21, 2023 23:07
@github-actions github-actions bot added this to the 7.8.0 milestone May 21, 2023
return RemoteFreeExtensions::get_extensions();
$extensions = RemoteFreeExtensions::get_extensions();
/**
* Remove Jetpack when woocommerce_suggest_jetpack is false.
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a note: we use these comments to auto-generate docs, as well as lists of new filters introduced in a release. It'd be helpful in the future if the description more completely described the filter, such as "When false, Jetpack is removed from the list of suggested extensions."

No changes immediately required here, but please keep this in mind when adding these comments to future filters and when reviewing PRs that include new filters.

Copy link
Contributor

Choose a reason for hiding this comment

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

/cc @chihsuan and @adrianduffell as reviewers as well

Copy link
Contributor

Choose a reason for hiding this comment

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

@moon0326 I fixed the description used in the release post, but after some discussion, we'd still like this description improved in the code. Please create a PR to clean this up when you get a change. No need to request an exception to get it into the 7.8 cycle, but please do work toward getting it cleaned up in trunk.

Copy link
Member

Choose a reason for hiding this comment

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

Thank you! @jonathansadowski

Copy link
Member

Choose a reason for hiding this comment

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

cc @woocommerce/ghidorah for the rest of the team

Copy link
Contributor

Choose a reason for hiding this comment

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

Great callout, @jonathansadowski!

Significance: minor
Type: add

Add a filter to free extensions REST endpoint
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment here as below for the filter comment. This isn't very useful to somebody glancing over the changelog what the change entry means. Please consider the audience for the change entry. What does the filter do?

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.

Make /onboarding/free-extensions endpoint filterable

6 participants