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

Do not disable "Used for variations" checkbox #39502

Merged
merged 8 commits into from Aug 1, 2023

Conversation

mattsherman
Copy link
Contributor

@mattsherman mattsherman commented Jul 31, 2023

Submission Review Guidelines:

Changes proposed in this Pull Request:

This PR makes a few changes related to the "Used for variations" checkbox:

  • The "Used for variations" checkbox is never disabled. I've reverted the behavior that disabled the checkbox when the product type was not variable.
    • This returns the behavior of the checkbox to what it was in WooCommerce 7.8.
    • I have determined that there would not be a way to implement disabling the checkbox without potentially breaking extensions, such as WooCommerce Subscriptions. If we were to add such a feature in the future we would need to be careful to proactively let extensions know that this change would be coming and provide them with a clear way to modify the behavior.
  • The woocommerce_added_attribute trigger has been restored. This is needed by extensions such as WooCommerce Subscriptions in order to re-show the "Used for variations" checkbox when it is hidden.
  • The requesting and generation of the empty attribute form has been moved from when the product edit screen loads to when the "Attributes" tab is shown. This allows for the scenario where the product type is changed from "simple" to something else before clicking the "Attributes" tab. The "Used for variations" checkbox will now be correctly defaulted to checked when on a variable product and unchecked for all other product types. This change will also partially address the lingering issue Do not show "Adding new attribute failed" when no attributes are set (on a classic theme) #39377.

Fixes #39490.
Fixes #39338 (this was closed previously even though it was not fixed)
Fixes #39502 (this was closed previously even though it was not fixed)

How to test the changes in this Pull Request:

  1. Perform general regression testing by creating and editing Simple products, Variable products, etc.
    • The "Used for variations" checkbox should be checked by default for Variable products.
    • The "Used for variations" checkbox should be hidden for all other product types (unless an extension has re-shown it, which is actually what WooCommerce Subscriptions is doing to get it to appear).
  2. Install WooCommerce Subscriptions 5.2.0 and create and edit Subscriptions and Variable Subscriptions.
    • WooCommerce Subscriptions 5.2.0 does not contain any fixes to handle the issues fixed by this PR, so it is a good test of an extension that was experiencing problems.
    • The "Used for variations" checkbox should be unchecked by default for Variable Subscription products.
    • The "Used for variations" checkbox should be hidden for Subscription products.
    • (In other words, WooCommerce Subscriptions 5.2.0 should work with this fix)
  3. Install WooCommerce Subscriptions 5.3.1 and verify that the fixes in that version still work with the fixes in this PR.
    • The "Used for variations" checkbox should be unchecked by default for Variable Subscription products.
    • The "Used for variations" checkbox should be hidden for Subscription products.

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

Comment

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Jul 31, 2023
@mattsherman mattsherman changed the title Fix/used for variations checkbox disabled Do not disable "Used for variations" checkbox Jul 31, 2023
@github-actions
Copy link
Contributor

Test Results Summary

Commit SHA: 144606f

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

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.

@mattsherman mattsherman self-assigned this Jul 31, 2023
@mattsherman mattsherman marked this pull request as ready for review July 31, 2023 23:43
@mattsherman mattsherman requested a review from a team July 31, 2023 23:43
@github-actions
Copy link
Contributor

Hi , @woocommerce/mothra

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

@AnnaMag
Copy link
Contributor

AnnaMag commented Aug 1, 2023

Fixes #39338 (this was closed previously even though it was not fixed)

@mattsherman any related issues were closed in favor of #39490 during triage.

Copy link
Contributor

@AnnaMag AnnaMag 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 working on this @mattsherman.

Tested as described. Approving, pending a fix to the failing test.

@@ -619,7 +621,13 @@ public static function add_attribute() {
$attribute->set_name( sanitize_text_field( wp_unslash( $_POST['taxonomy'] ) ) );
/* phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment */
$attribute->set_visible( apply_filters( 'woocommerce_attribute_default_visibility', 1 ) );
$attribute->set_variation( apply_filters( 'woocommerce_attribute_default_is_variation', 1 ) );
$attribute->set_variation(
apply_filters(
Copy link
Contributor

Choose a reason for hiding this comment

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

Would reverting to the previous functionality be sufficient?

Copy link
Contributor

Choose a reason for hiding this comment

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

This would also fix the test-- setting a simple product as the default could create more edge cases in the future 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AnnaMag I don't see any failing test. What test are you referring to?

I'd prefer not to revert to the previous functionality, since Jarek has been quite set that this change will help prevent confusion based on his user research.

@mattsherman mattsherman merged commit 85e3773 into trunk Aug 1, 2023
25 of 26 checks passed
@mattsherman mattsherman deleted the fix/used-for-variations-checkbox-disabled branch August 1, 2023 14:01
@github-actions github-actions bot added this to the 8.1.0 milestone Aug 1, 2023
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Aug 1, 2023
@jonathansadowski jonathansadowski modified the milestones: 8.1.0, 8.0.0 Aug 1, 2023
jonathansadowski pushed a commit that referenced this pull request Aug 1, 2023
* Do not disable "Used for variations" checkbox (#39502)

* Prep for cherry pick 39502

---------

Co-authored-by: Matt Sherman <matt.sherman@automattic.com>
Co-authored-by: WooCommerce Bot <no-reply@woocommerce.com>
@alopezari alopezari removed the needs: analysis Indicates if the PR requires a PR testing scrub session. label Aug 2, 2023
@alopezari alopezari added the needs: internal testing Indicates if the PR requires further testing conducted by Solaris label Aug 2, 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.
Projects
None yet
4 participants