Skip to content
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

Omit WooCommerce plugin from the list of Woo extensions in Helper #40549

Merged
merged 2 commits into from Oct 3, 2023

Conversation

andfinally
Copy link
Contributor

@andfinally andfinally commented Oct 2, 2023

Submission Review Guidelines:

Changes proposed in this Pull Request:

p1696252501678409-slack-C03Q87XT1QF

  • Woo Express relied on the woocommerce_show_addons_page to hide the current addons page. The filter was removed in an earlier PR. This PR restores it: if the filter returns false, we won't add the addons page.
  • The Woo release team uses the product 18734002369816 to distribute the WooCommerce weekly release to Atomic sites. (See pcShBQ-14K-p2). To do this, the plugin needs a Woo: header in the bootstrap file. This means that Helper identifies it as a Woo extension. It's then listed as a plugin which doesn't have a corresponding WooCommerce.com subscription. To hide it in the Helper list, I've added a condition which omits the plugin if (1) it has a Woo: header (2) its name is WooCommerce.
  • During the transition to a React-based marketplace, we're temporarily hiding an extra submenu item using JS. This PR uses a better method of hiding the item, borrowed from Jetpack.

How to test the changes in this Pull Request:

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

Reproducing the problem

  1. Instead of trying this in your local WooCommerce wp-env environment, create a JN or other test WordPress site and install a WooCommerce weekly release like this one:
    woocommerce-8.2.0.2.zip (You can also download this from https://woocommerce.com/my-account/downloads/: it's listed as WooCommerce (weekly release).)
  2. Go to wp-admin/admin.php?page=wc-addons&path&section=helper and connect your test site to your WooCommerce.com account, by clicking on the "Connect" button in the screen shown below. When connected, the page will refresh to show a list of your Woo extensions. Notice that WooCommerce is listed as a "Woo extension" without a subscription, like in the other screenshot below.
  3. Deactivate and delete that version of the WooCommerce plugin.

Testing the fix for the WooCommerce plugin

  1. Check out this branch.
  2. When run locally, the zip build doesn't have enough RAM to generate the translation files. Comment out these two lines in plugins/woocommerce/bin/build-zip.sh to skip that step:
Index: plugins/woocommerce/bin/build-zip.sh
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/plugins/woocommerce/bin/build-zip.sh b/plugins/woocommerce/bin/build-zip.sh
--- a/plugins/woocommerce/bin/build-zip.sh	(revision ceafa7da30b0211621222792bfe679b21e8a8c3c)
+++ b/plugins/woocommerce/bin/build-zip.sh	(date 1696261507943)
@@ -18,8 +18,8 @@
 pnpm -w run build --filter=woocommerce || exit "$?"
 echo "Cleaning up PHP dependencies..."
 composer install --no-dev || exit "$?"
-echo "Run makepot..."
-pnpm -r --filter=woocommerce run makepot || exit "$?"
+#echo "Run makepot..."
+#pnpm -r --filter=woocommerce run makepot || exit "$?"
 echo "Syncing files..."
 rsync -rc --exclude-from="$PROJECT_PATH/.distignore" "$PROJECT_PATH/" "$DEST_PATH/" --delete --delete-excluded
  1. Now edit plugins/woocommerce/woocommerce.php and add the Woo header * Woo: 18734002369816:624a1b9ba2fe66bb06d84bcdd401c6a6 to the plugin header. The header should look like this. (Don't worry about the version number, it's isn't important here.)
/**
 * Plugin Name: WooCommerce
 * Plugin URI: https://woocommerce.com/
 * Description: An eCommerce toolkit that helps you sell anything. Beautifully.
 * Version: 8.2.0.2
 * Author: Automattic
 * Author URI: https://woocommerce.com
 * Text Domain: woocommerce
 * Domain Path: /i18n/languages/
 * Requires at least: 6.2
 * Requires PHP: 7.4
 *
 * Woo: 18734002369816:624a1b9ba2fe66bb06d84bcdd401c6a6
 *
 * @package WooCommerce
 */
  1. Build the zip file so you can install this branch: cd plugins/woocommerce && ./bin/build-zip.sh.
  2. Upload the zip file from plugins/woocommerce to your test site and enable the plugin.
  3. Go back to the helper page. Notice that WooCommerce is no longer listed.

Testing the hidden submenu item

Inspect the HTML after the Extensions submenu item in the WooCommerce menu. There should be a hidden item with the hide-if-js class.

image

If you don't see this item, with the new marketplace UI, enable the Marketplace feature in WooCommerce > Settings > Advanced > Features.

Changelog entry

  • Automatically create a changelog entry from the details below.

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

Adds condition to ensure WooCommerce is not listed as a Woo extension in the Helper list. Restores the woocommerce_show_addons_page filter as a means of controlling whether the addons page is added as a WooCommerce submenu item. Hides a temporary extra addons submenu item using a better method borrowed from Jetpack.

Comment

Screenshots

image

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Oct 2, 2023
@andfinally andfinally marked this pull request as draft October 2, 2023 15:00
@github-actions
Copy link
Contributor

github-actions bot commented Oct 2, 2023

Test Results Summary

Commit SHA: 9bcef3a

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 54s
E2E Tests212007021919m 4s

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.

@andfinally andfinally marked this pull request as ready for review October 2, 2023 16:32
@andfinally andfinally requested review from a team, Dan-Q, kdevnel and jonathansadowski and removed request for a team October 2, 2023 16:32
@andfinally andfinally added the needs: developer feedback Issues that need feedback from one of the WooCommerce Core developers. label Oct 2, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 2, 2023

Hi @Dan-Q, @jonathansadowski, @xristos3490,

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

Copy link
Contributor

@kdevnel kdevnel 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 this!

@andfinally andfinally force-pushed the update/helper-skip-woo-af-plugin branch from ceafa7d to 552e22a Compare October 3, 2023 09:30
@xristos3490 xristos3490 self-requested a review October 3, 2023 12:51
Copy link
Member

@xristos3490 xristos3490 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! Re-adding the woocommerce_show_addons_page hook can assist WX and other third-party developers who were previously using this filter!

Added a minor comment! Pre-approving!

if ( apply_filters( 'woocommerce_show_addons_page', true ) ) {
if ( FeaturesUtil::feature_is_enabled( 'marketplace' ) ) {
$container = wc_get_container();
$container->get( Marketplace::class );
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

…ist of Woo extensions. The Woo release team uses this product to distribute the Woo AF release (pcShBQ-14K).

Restored `woocommerce_show_addons_page` filter, which is used to add or not add the Extensions menu item.

Changed the method we use to hide the extra Extensions submenu item we add to WooCommerce as a temporary measure, to ensure the My Subscriptions page still works. Using the superior `hide_submenu_page` method borrowed from Jetpack.
@andfinally andfinally force-pushed the update/helper-skip-woo-af-plugin branch from 780a3f1 to db8dede Compare October 3, 2023 14:10
@andfinally andfinally merged commit b3cd93e into trunk Oct 3, 2023
26 checks passed
@andfinally andfinally deleted the update/helper-skip-woo-af-plugin branch October 3, 2023 15:42
@github-actions github-actions bot added this to the 8.3.0 milestone Oct 3, 2023
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Oct 3, 2023
@andfinally andfinally removed the needs: developer feedback Issues that need feedback from one of the WooCommerce Core developers. label Oct 3, 2023
@alopezari alopezari added needs: internal testing Indicates if the PR requires further testing conducted by Solaris status: analysis complete Indicates if a PR has been analysed by Solaris and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: internal testing Indicates if the PR requires further testing conducted by Solaris plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants