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

Product Block Editor: Make it compatible with WooCommerce 8.6 #2249

Conversation

eason9487
Copy link
Member

@eason9487 eason9487 commented Feb 8, 2024

Changes proposed in this Pull Request:

In WooCommerce 8.6, the Product Block Editor has some breaking changes:

Before adjusting, some preprocessing makes the ProductBlocksService class easier to test:

  • 355f61d: Change to use a dedicated method as the 'init' action handler.
  • 175d53c: Change to use a dedicated method as the "woocommerce_block_template_area_{$template_area}_after_add_block_{$block_id}" action handler.

To be compatible with the above, it requires a few adjustments:

  • f054494: Remove the is_admin_page check from the conditional registration of ProductBlocksService and set the minimum support WC version to 8.6.
  • 8bbf671: Hide this extension's group from Product Block Editor for the unsupported product types.

📌 Checklist for @eason9487

  • Check if all links starting with https://github.com/woocommerce/woocommerce/blob/8.6.0/[...] point to the correct lines of code.
  • Revert 955a9a6 before merging

Screenshots:

Kapture.2024-02-08.at.17.22.06.mp4

Detailed test instructions:

📌 Prepare test environment

  1. Please refer to the test preparation in PR 2151 with Woo 8.6.0.
    • 💡 Currently, it can be tested with 8.6.0-rc.1
  2. npm install
  3. npm start

📌 Test the visibility of this extension's tab and blocks

💡 By default, the supported product types of this extension are simple, variable, and variation.

  1. Start creating a new product.
  2. The Google Listings & Ads tab should be visible.
  3. Enter product name.
  4. In the General tab, change to other product types back and forth.
    image
  5. Check if the Google Listings & Ads tab is only visible when selecting the Standard product type.
  6. Go to edit a variable product, e.g. the Hoodie imported from WC's sample products.
  7. The Google Listings & Ads tab should be visible.
  8. Switch to the Variations tab.
  9. Click one of the Edit links within the Variations section to edit a variation product.
  10. The Google Listings & Ads tab should be visible.

Changelog entry

…oocommerce_block_template_area_{$template_area}_after_add_block_{$block_id}" action handler.
…ProductBlocksService` and set its min support WC version to 8.6.

Remove `PageController::is_admin_page()` due to a breaking change in WooCommerce 8.6.
- The template of Product Block Editor is changed to be fetched via `/wc/v3/layout-templates` REST API.

Ref: woocommerce/woocommerce#43589
…rted product types.

In WooCommerce 8.6, the Product Block Editor starts supporting the grouped and
external product types but they share the same template "simple-product".
@eason9487 eason9487 self-assigned this Feb 8, 2024
@github-actions github-actions bot added the changelog: tweak Small change, that isn't actually very important. label Feb 8, 2024
Copy link

codecov bot commented Feb 8, 2024

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (c08f614) 61.5% compared to head (ef5bdb7) 63.1%.

Additional details and impacted files

Impacted file tree graph

@@                           Coverage Diff                            @@
##             feature/support-product-block-editor   #2249     +/-   ##
========================================================================
+ Coverage                                    61.5%   63.1%   +1.6%     
- Complexity                                   4185    4188      +3     
========================================================================
  Files                                         748     455    -293     
  Lines                                       21538   17823   -3715     
  Branches                                      532       0    -532     
========================================================================
- Hits                                        13244   11238   -2006     
+ Misses                                       7843    6585   -1258     
+ Partials                                      451       0    -451     
Flag Coverage Δ
js-unit-tests ?
php-unit-tests 63.1% <93.7%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/Admin/Product/ChannelVisibilityBlock.php 100.0% <ø> (ø)
src/Admin/ProductBlocksService.php 96.8% <93.7%> (ø)

... and 293 files with indirect coverage changes

@eason9487 eason9487 requested a review from a team February 8, 2024 10:08
Copy link
Contributor

@martynmjones martynmjones left a comment

Choose a reason for hiding this comment

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

Hey @eason9487, thanks for keeping this work up to date with the changes in core.

I'm seeing the Google Listings & Ads tab in the expected locations and only for the relevant product types so LGTM ✅

…0 has not been released yet."

This reverts commit 955a9a6.
@eason9487 eason9487 merged commit fc2ee13 into feature/support-product-block-editor Feb 19, 2024
11 checks passed
@eason9487 eason9487 deleted the tweak/product-block-editor-use-wc-8-6 branch February 19, 2024 03:05
@eason9487 eason9487 mentioned this pull request Feb 27, 2024
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: tweak Small change, that isn't actually very important.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants