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

Don't display WCS&T help in tasks if WCShip or WCTax is active #48703

Conversation

waclawjacek
Copy link
Contributor

@waclawjacek waclawjacek commented Jun 20, 2024

Submission Review Guidelines:

Changes proposed in this Pull Request:

Part of https://github.com/woocommerce/woocommerce-shipping/issues/187.

If the "WooCommerce Shipping" or "WooCommerce Tax" extension is active, don't recommend the incompatible "WooCommerce Shipping & Tax" extension.

This PR removes WCS&T-related help pages from the "Select your shipping options" and "Collect sales tax" tasks if either the WCShip or WCTax extension is active.

Screenshots

Screenshot 2024-06-06 at 13 54 06 Screenshot 2024-06-06 at 13 56 19

Note that despite the help items saying "WooCommerce Shipping" and "WooCommerce Tax", they actually refers to WCS&T's functionalities.

How to test the changes in this Pull Request:

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

  1. Clone this repo, check out this PR's branch, and build WooCommerce. The official instructions are in the repo README file but here's a shortcut:
    nvm use && pnpm i -g pnpm@9.1.0 && pnpm i && pnpm run build
    
  2. In your local test site's wp-content/plugins, link the WooCommerce plugin you just built.
    Let's assume you checked out the WooCommerce repo to /home/me/woocommerce.
    Note how below we aren't creating a link to /home/me/woocommerce but rather to a directory within it:
    ln -s /home/me/woocommerce/plugins/woocommerce /var/www/your-test-site/wp-content/plugins/woocommerce
    
  3. That's it for building WC Core. Now let's test the tax task:

Testing the "Collect sales tax" task

  1. In WP admin, go to WooCommerce > Home. Click the "Collect sales tax" task:
    Screenshot 2024-06-24 at 20 32 21
  2. Click the "?" icon in the top right:
    Screenshot 2024-06-24 at 20 33 05
  3. Without WCShip and/or WCTax installed, you should see this WCS&T-related help item:
    Screenshot 2024-06-06 at 13 56 19
    Note that despite the help item saying "WooCommerce Tax", it actually refers to WCS&T's tax functionality.
  4. With WCShip and/or WCTax installed, you should not see it.

Testing the "Select your shipping options" task

  1. To force the task to show up and guide us to the wizard, we have to tweak the code a little. Apply the following patch:
    diff --git a/plugins/woocommerce/src/Admin/Features/OnboardingTasks/Tasks/Shipping.php b/plugins/woocommerce/src/Admin/Features/OnboardingTasks/Tasks/Shipping.php
    index f06534b87c..649d0a7f87 100644
    --- a/plugins/woocommerce/src/Admin/Features/OnboardingTasks/Tasks/Shipping.php
    +++ b/plugins/woocommerce/src/Admin/Features/OnboardingTasks/Tasks/Shipping.php
    @@ -84,6 +84,7 @@ class Shipping extends Task {
     	 * @return bool
     	 */
     	public function can_view() {
    +		return true;
     		if ( Features::is_enabled( 'shipping-smart-defaults' ) ) {
     			if ( 'yes' === get_option( 'woocommerce_admin_created_default_shipping_zones' ) ) {
     				// If the user has already created a default shipping zone, we don't need to show the task.
    @@ -128,6 +129,7 @@ class Shipping extends Task {
     	 * @return string
     	 */
     	public function get_action_url() {
    +		return null;
     		return self::has_shipping_zones()
     			? admin_url( 'admin.php?page=wc-settings&tab=shipping' )
     			: null;
    
  2. In WP admin, go to WooCommerce > Home. Click the "Select your shipping options" task:
    Screenshot 2024-06-06 at 13 54 06
  3. Click the "?" icon in the top right.
  4. Without WCShip and/or WCTax installed, you should see this WCS&T-related help item:
    Screenshot 2024-06-06 at 13 54 06
    Note that despite the help item saying "WooCommerce Shipping", it actually refers to WCS&T's shipping functionality.
  5. With WCShip and/or WCTax installed, you should not see it.

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

Changelog Entry Comment

Comment

If either the upcoming WooCommerce Shipping or WooCommerce Tax extension is active, don't display information about setting up WooCommerce Shipping & Tax in the task steppers for "Collect sales tax" and "Select your shipping options".

The changes in this PR only adjust the help items merchants see.

@waclawjacek waclawjacek self-assigned this Jun 20, 2024
Copy link
Contributor

github-actions bot commented Jun 20, 2024

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

github-actions bot commented Jun 20, 2024

Size Change: -183 B (-0.01%)

Total Size: 2.49 MB

Filename Size Change
./plugins/woocommerce-blocks/build/legacy-template.js 8.04 kB -183 B (-2.22%)

compressed-size-action

@waclawjacek waclawjacek marked this pull request as ready for review June 21, 2024 20:12
@waclawjacek waclawjacek requested review from a team and samnajian and removed request for a team June 21, 2024 20:12
Copy link
Contributor

Hi @samnajian,

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

@waclawjacek waclawjacek changed the base branch from trunk to tweak/dont-recommend-wcservices-in-tax-task-with-wcship-or-wctax-active June 24, 2024 18:16
@waclawjacek waclawjacek force-pushed the tweak/dont-display-wcservices-help-if-wcship-or-wctax-is-active branch from 07eb4f5 to 83fb7e7 Compare June 24, 2024 18:26
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Jun 24, 2024
Base automatically changed from tweak/dont-recommend-wcservices-in-tax-task-with-wcship-or-wctax-active to trunk June 25, 2024 12:23
@samnajian
Copy link

With WCShip and/or WCTax installed, you should not see it.

@waclawjacek
When WCShip or WCTax are installed but not active, I still can see the VBXvM9.png and this line is also checking among the active plugins, shouldn't this PR check among the installed plugins as well?

@waclawjacek
Copy link
Contributor Author

waclawjacek commented Jun 25, 2024

Thanks for the review! Yep, that's expected - the checks are for "active", not for "installed".

Using "active" allowed me to duplicate the existing logic, incl. writing checks identical to some existing ones just with different plugin slugs/class names, and using the plugins_activated rule in the rule evaluator.

We can change it from "is WCShip/WCTax active?" to "is WCShip/WCTax installed?" but this would require input from @MatthiasReinholz and/or @kloon. If we don't care about it too much, I'd say let's leave it as it is so the scope of changes is a little bit smaller.

@waclawjacek waclawjacek force-pushed the tweak/dont-display-wcservices-help-if-wcship-or-wctax-is-active branch from 5415a58 to 8468643 Compare June 25, 2024 19:22
@github-actions github-actions bot added the package: @woocommerce/data issues related to @woocommerce/data label Jun 25, 2024
@waclawjacek
Copy link
Contributor Author

Force-pushed because the base branch this PR was built on top of has since been merged to trunk.

@github-actions github-actions bot removed the package: @woocommerce/data issues related to @woocommerce/data label Jun 26, 2024
@MatthiasReinholz
Copy link
Member

Thanks for the ping @waclawjacek ,
I'm wondering if we even need this task list entry at all? Is there a reason for us to keep the WCS&T task under these conditions? Wouldn't we want all users to migrate to WooCommerce Shipping / WooCommerce Tax?

Copy link

@samnajian samnajian left a comment

Choose a reason for hiding this comment

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

Based on this Slack thread p1719388812098259-slack-C04KWSNPSE5 it's fine to rely on plugin activation for this PR, with this condition, this PR works as expected.

LGTM, :shipit:

@waclawjacek
Copy link
Contributor Author

Is there a reason for us to keep the WCS&T task under these conditions? Wouldn't we want all users to migrate to WooCommerce Shipping / WooCommerce Tax?

Ultimately, I believe that's the goal. But for the time being, we're only taking care to not recommend WCS&T if it'd lead to a conflict with the WCShip/WCTax extensions.

@waclawjacek waclawjacek merged commit f0b9a91 into trunk Jun 27, 2024
37 of 38 checks passed
@waclawjacek waclawjacek deleted the tweak/dont-display-wcservices-help-if-wcship-or-wctax-is-active branch June 27, 2024 13:35
@github-actions github-actions bot added this to the 9.2.0 milestone Jun 27, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Jun 27, 2024
@nigeljamesstevenson nigeljamesstevenson added needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. 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 Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. 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