From d8296d16986f8a058e61f3303f6ed22218b420ae Mon Sep 17 00:00:00 2001 From: github-actions Date: Tue, 16 Nov 2021 02:14:17 +0000 Subject: [PATCH 01/44] Empty commit for release pull request From 3d2f37896d9a5962efa25d544955f0bb1d2f8453 Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Tue, 16 Nov 2021 09:54:00 +0700 Subject: [PATCH 02/44] Update readme.txt with release changelog --- readme.txt | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/readme.txt b/readme.txt index c843b3aaaaf..cbd87e22f3e 100644 --- a/readme.txt +++ b/readme.txt @@ -85,6 +85,40 @@ Release and roadmap notes available on the [WooCommerce Developers Blog](https:/ == Changelog == += 6.3.0 - 2021-11-16 = + +#### Enhancements + +- Add placeholder text when modifying product search input in the editor. ([5122](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5122)) +- Improve readability of terms and condition text by not displaying the text justified. ([5120](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5120)) +- Improve accessibility by using selfexplaining edit button titles. ([5113](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5113)) +- Improve rendering performance for Single Product block. ([5107](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5107)) +- FSE: Remove the `do_action( 'woocommerce_sidebar' );` action from the `LegacyTemplate.php` block. ([5097](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5097)) +- FSE: Add basic taxonomy block templates. ([5063](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5063)) +- FSE: Add single product block template. ([5054](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5054)) +- FSE: Add basic product archive block template. ([5049](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5049)) +- Fix duplicate queries in product grids #4695. ([5002](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5002)) +- Introduce `cartItemClass` filter for cart items in Cart and Checkout blocks. ([4992](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4992)) +- FSE: Add abstract block legacy template for core PHP templates. ([4991](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4991)) +- FSE: Add render logic to BlockTemplateController. ([4984](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4984)) +- Improve the product images placeholder display by adding a light gray border to it. ([4950](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4950)) +- Deprecate the __experimental_woocommerce_blocks_checkout_update_order_meta action in favour of woocommerce_blocks_checkout_update_order_meta. ([5017](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5017)) +- Deprecate the __experimental_woocommerce_blocks_checkout_update_order_from_request action in favour of woocommerce_blocks_checkout_update_order_from_request. ([5015](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5015)) +- Deprecate the __experimental_woocommerce_blocks_checkout_order_processed action in favour of woocommerce_blocks_checkout_order_processed. ([5014](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5014)) + +#### Bug Fixes + +- Fixed an issue that was causing an error when updating the address in the Cart block's shipping calculator. ([5115](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5115)) +- Fix label alignment of the product search in the editor. ([5072](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5072)) +- FSE: Fix missing `is_custom` property for WooCommerce block template objects. ([5067](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5067)) +- Fix sale badge alignment on smaller screen. ([5061](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5061)) +- Scripts using `wc-settings` or script that depend on it would be enqueued in the footer if they're enqueued in the header. ([5059](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5059)) +- Replace incorrect with correct text domain. ([5020](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5020)) +- Fix button style of Mini Cart block for small screens. ([4907](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4907)) +- Make order note block removable ([5139](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5139)) +- Fix state validation to compare state codes, and only validate if a country is given ([5132](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5132)) +- Fix 'Country is required' error on the Cart block when updating shipping address ([5129](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5129)) + = 6.2.0 - 2021-10-26 = #### Enhancements From 286d5fbf9accf8a4585bd8c10388a12f87fa7212 Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Tue, 16 Nov 2021 16:14:14 +0700 Subject: [PATCH 03/44] Add testing instructions for 6.3.0 release --- docs/testing/releases/630.md | 223 ++++++++++++++++++++++++++++++++ docs/testing/releases/README.md | 2 +- 2 files changed, 224 insertions(+), 1 deletion(-) create mode 100644 docs/testing/releases/630.md diff --git a/docs/testing/releases/630.md b/docs/testing/releases/630.md new file mode 100644 index 00000000000..6f81744f538 --- /dev/null +++ b/docs/testing/releases/630.md @@ -0,0 +1,223 @@ +## Testing notes and ZIP for release 6.2.0 + +Zip file for testing: [woocommerce-gutenberg-products-block.zip](https://github.com/woocommerce/woocommerce-gutenberg-products-block/files/7543045/woocommerce-gutenberg-products-block.zip) + +## Feature Plugin + +### Improve readability of terms and condition text by not displaying the text justified. ([5120](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5120)) + +1. Create a test page, add the checkout block and save the page. +2. Add a short custom text to the terms and conditions section. +3. Verify that the terms and conditions text is left-aligned and contains even spacing between the words. + +### Introduce `cartItemClass` filter for cart items in Cart and Checkout blocks. ([4992](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4992)) + +1. Install [the Simple Custom CSS and JS plugin](https://wordpress.org/plugins/custom-css-js/). +2. Add the following custom JS code and load it in the frontend in the footer: + +``` +const { __experimentalRegisterCheckoutFilters } = window.wc.blocksCheckout; +__experimentalRegisterCheckoutFilters( 'my-hypothetical-deposit-plugin', { + cartItemClass: () => 'my-class', +} ); +``` + +3. Create a test page, add the cart block to it and save it. +4. Go to the frontend and add a product to the cart. +5. Go to the cart page and ensure that cart item has the CSS class `my-class`. +6. Go to the checkout page and ensure that the cart item has the CSS class `my-class`. + +Example of a cart item with the CSS class `my-class`: + +![](https://user-images.githubusercontent.com/3323310/141903888-ecdf5884-77bc-4709-a4ac-bebe5dd962f1.png) + +### Fix incorrect text domain. ([5020](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5020)) + +1. Set the site language to Spanish. +2. Download the translation files via Dashboard → Updates. +3. Create a test page, add the checkout block and save the page. +4. Verify that all texts of the checkout block are available in Spanish in the editor. + +⚠️ Please note that some strings are not translated in the frontend. This problem will be addressed with ([5112](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5112)). + +### Fix ‘Country is required’ error on the Cart block when updating shipping address ([5129](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5129)) + +1. Add a product to the cart and go to the cart page. +2. Provide a shipping address in the shipping calculator and click the `Update` button. +3. Provide a shipping address from a different country and click the `Update` button again. +4. Verify that the new shipping address is visible. +5. Verify that the error `Country is required` is not visible. +6. Go to the checkout page and verify that the new shipping address is visible. +7. Finalize the order and verify that the new shipping address is visible on the order details. + +### Fix button style of Mini Cart block for small screens. ([4907](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4907)) + +1. Create a test page, add the columns block and save the page. +2. Add the mini cart block to one of the columns. +3. Verify that the mini card block contains the total, the number of items and the cart icon on a large screen (>= 768px). +4. Verify that the mini card block only contains the number of items and the cart icon on a small screen (< 768px). + +| large screen | Small screen | +| ———————————————————————————————————————————————————— | ———————————————————————————————————————————————————— | +| ![](https://user-images.githubusercontent.com/3323310/141926396-82eb319f-502f-4c3b-9aba-c9a3be9fe4e3.png) | ![](https://user-images.githubusercontent.com/3323310/141926415-dbcf8133-ea26-4e08-a806-aee7923f83d2.png) | + +### Make order note block removable ([5139](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5139)) + +1. Create a test page, add the Checkout block and save the page. +2. Remove the order note block and verify that it will not be added again. +3. Go to the frontend and verify that the order note block is not visible. + +### Deprecate the \_\_experimental_woocommerce_blocks_checkout_order_processed action in favor of woocommerce_blocks_checkout_order_processed. ([5014](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5014)) + +1. Install [the Code Snippets plugin](https://wordpress.org/plugins/code-snippets/). +2. Add the following PHP snippet: + +``` +add_action( '__experimental_woocommerce_blocks_checkout_order_processed', function( $order ) { return; }, 10, 1 ); + +// For testing purposes, update the order date using the new hook. +add_action( 'woocommerce_blocks_checkout_order_processed', function( $order ) { + $order->set_date_created( '2000-05-08' ); + $order->save(); +} ); +``` + +3. Install [the WP Debugging plugin](https://wordpress.org/plugins/wp-debugging/). +4. Add a product to your cart and check out using the Checkout block. Ensure it goes through correctly. +5. Check the `debug.log` file and ensure there’s a deprecation message logged for `__experimental_woocommerce_blocks_checkout_order_processed`. +6. Ensure the order creation date is May 8th, 2000. + +ℹ️ https://tastewp.com/ allows spinning up a free WordPress test site and downloading the `debug.log` file via the dashboard. + +### Deprecate the \_\_experimental_woocommerce_blocks_checkout_update_order_from_request action in favor of woocommerce_blocks_checkout_update_order_from_request. ([5015](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5015)) + +1. Install [the Code Snippets plugin](https://wordpress.org/plugins/code-snippets/). +2. Add the following PHP snippet: + +``` +add_action( '__experimental_woocommerce_blocks_checkout_update_order_from_request', function( $order, $request ) { return; }, 10, 2 ); + +add_action( 'woocommerce_blocks_checkout_update_order_from_request', function( $order, $request ) { + // For testing purposes, set the customer note to the user-agent from the request. + $order->set_customer_note( $request->get_header('User-agent') ); + $order->save(); +}, 10, 2 ); +``` + +3. Install [the WP Debugging plugin](https://wordpress.org/plugins/wp-debugging/). +4. Add a product to your cart and check out using the Checkout block. Ensure it goes through correctly. +5. Check the `debug.log` file and ensure there’s a deprecation message logged for `__experimental_woocommerce_blocks_checkout_update_order_from_request`. +6. Ensure the order creation date is May 8th, 2000. + +ℹ️ https://tastewp.com/ allows spinning up a free WordPress test site and downloading the `debug.log` file via the dashboard. + +### Deprecate the \_\_experimental_woocommerce_blocks_checkout_update_order_meta action in favor of woocommerce_blocks_checkout_update_order_meta. ([5017](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5017)) + +1. Install [the Code Snippets plugin](https://wordpress.org/plugins/code-snippets/). +2. Add the following PHP snippet: + +``` +add_action( '__experimental_woocommerce_blocks_checkout_update_order_meta', function( $order ) { return; }, 10, 1 ); + +// For testing purposes, update the order date using the new hook. +add_action( 'woocommerce_blocks_checkout_update_order_meta', function( $order ) { + $order->set_date_created( '2000-05-08' ); + $order->save(); +} ); +``` + +3. Install [the WP Debugging plugin](https://wordpress.org/plugins/wp-debugging/). +4. Add a product to your cart and check out using the Checkout block. Ensure it goes through correctly. +5. Check the `debug.log` file and ensure there’s a deprecation message logged for `__experimental_woocommerce_blocks_checkout_update_order_meta`. +6. Ensure the order creation date is May 8th, 2000. + +ℹ️ https://tastewp.com/ allows spinning up a free WordPress test site and downloading the `debug.log` file via the dashboard. + +## Feature plugin and package inclusion in WooCommerce + +### FSE: Add basic taxonomy block templates. ([5063](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5063)) + +1. Install and activate [the Gutenberg plugin](https://wordpress.org/plugins/gutenberg/) (not the latest built version of `trunk` from the repo). +2. Install and activate a FSE enabled theme, such as [the Tove theme](https://wordpress.org/themes/tove/). +3. Load the Site Editor (Appearance → Editor) and select the `Product Category Page` template from the `General templates` section. +4. Confirm you can load the template, and it looks as expected in large/small viewports. +5. Confirm the behavior on the frontend on a category page, e.g. `/product-category/clothing/` is identical to the behavior the same page without this PR applied. +6. Repeat steps 3-5 for the `Product Tag Page` template (e.g. `/product-tag/merch/`). + +### FSE: Add single product block template. ([5054](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5054)) + +1. Install and activate [the Gutenberg plugin](https://wordpress.org/plugins/gutenberg/) (not the latest built version of `trunk` from the repo). +2. Install and activate a FSE enabled theme, such as [the Tove theme](https://wordpress.org/themes/tove/). +3. Load the Site Editor (Appearance → Editor) and select the `Single Product Page` template from the `General templates` section. +4. Confirm you can load the template. It will have a temporary placeholder block. This SVG will be replaced in a future PR. +5. Confirm the behavior on the frontend product page is identical to the behavior on the product page without this PR applied. + +### FSE: Add basic product archive block template. ([5049](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5049)) + +1. Install and activate [the Gutenberg plugin](https://wordpress.org/plugins/gutenberg/) (not the latest built version of `trunk` from the repo). +2. Install and activate a FSE enabled theme, such as [the Tove theme](https://wordpress.org/themes/tove/). +3. Load the Site Editor (Appearance → Editor) and select the `Product Archive Page` template from the `General templates` section. +4. Confirm you can load the template, and it looks as expected in large/small viewports as per the screenshots above. +5. Confirm the behavior on the Frontend on `/shop` is identical to the behavior on `/shop` without this PR applied. + +### Add placeholder text when modifying product search input in the editor. ([5122](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5122)) + +1. Add the Product Search block to any page in the editor. +2. Delete the “Search Products…” value from the Search input. +3. “Enter search placeholder text” should be displayed in the input as a placeholder. +4. The text should disappear as you start typing. + +### Improve the product images placeholder display by adding a light gray border to it. ([4950](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4950)) + +1. Create a product with no product image. +2. Create a test page and add the Newest Products block. +3. Verify that the placeholder image has a visible border. + +### Improve accessibility by using self-explaining edit button titles. ([5113](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5113)) + +1. Create a test page and add the following blocks to it: + - Featured Category block + - Featured Product block + - Hand-picked Products block + - Products by Category block + - Products by Attribute block + - Reviews by Product block + - Reviews by Category block + - Products by Tag block + - All products block + - Single Product block +2. Click on the `edit` button of each block and verify that the button text corresponds to the value of the following table: + +| Block | Expected button text | +| —————————— | ———————————— | +| Featured Category | Edit selected category | +| Featured Product | Edit selected product | +| Hand-picked Products | Edit selected products | +| Products by Category | Edit selected categories | +| Products by Attribute | Edit selected attributes | +| Reviews by Product | Edit selected product | +| Reviews by Category | Edit selected categories | +| Products by Tag | Edit selected tags | +| All products | Rearrange inner blocks | +| Single Product | Edit selected product | + +Example of button text for the Hand-picked Products block: + +![](https://user-images.githubusercontent.com/3323310/141891543-5ef2d0d5-fba7-407a-a731-daee53b9a70d.png) + +### Fix label alignment of the product search in the editor. ([5072](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5072)) + +1. Create a test page, add the Product Search block and save the page. +2. Verify if the search label is vertically aligned with the search input field and that the block looks equal in the editor and on the frontend. + +### Fix duplicate queries in product grids #4695. ([5002](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5002)) + +1. Add multiple product grid blocks to a page, e.g. `Products by Category` and `Products by Category`. +2. Ensure there are some variable products visible. +3. Check the product grid blocks render correctly on the frontend. + +### Fix sale badge alignment on smaller screen. ([5061](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5061)) + +1. Create a test page, add the All Products block and save the page. +2. Simulate a screen that has a width between 480px and 600px. +3. Verify that the sale badge is aligned on the right. diff --git a/docs/testing/releases/README.md b/docs/testing/releases/README.md index 6a13e0f2b3c..8546cef553c 100644 --- a/docs/testing/releases/README.md +++ b/docs/testing/releases/README.md @@ -47,4 +47,4 @@ Every release includes specific testing instructions for new features and bug fi - [6.0.0](./600.md) - [6.1.0](./610.md) - [6.2.0](./620.md) - +- [6.3.0](./630.md) From 12a5468afb784333c311bb3e84ec61dfb8901189 Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Tue, 16 Nov 2021 16:25:16 +0700 Subject: [PATCH 04/44] Update testing instructions as MD tables didn't work --- docs/testing/releases/630.md | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/docs/testing/releases/630.md b/docs/testing/releases/630.md index 6f81744f538..50c9167b772 100644 --- a/docs/testing/releases/630.md +++ b/docs/testing/releases/630.md @@ -57,9 +57,13 @@ Example of a cart item with the CSS class `my-class`: 3. Verify that the mini card block contains the total, the number of items and the cart icon on a large screen (>= 768px). 4. Verify that the mini card block only contains the number of items and the cart icon on a small screen (< 768px). -| large screen | Small screen | -| ———————————————————————————————————————————————————— | ———————————————————————————————————————————————————— | -| ![](https://user-images.githubusercontent.com/3323310/141926396-82eb319f-502f-4c3b-9aba-c9a3be9fe4e3.png) | ![](https://user-images.githubusercontent.com/3323310/141926415-dbcf8133-ea26-4e08-a806-aee7923f83d2.png) | +Large screen: + +![](https://user-images.githubusercontent.com/3323310/141926396-82eb319f-502f-4c3b-9aba-c9a3be9fe4e3.png) + +Small screen: + +![](https://user-images.githubusercontent.com/3323310/141926415-dbcf8133-ea26-4e08-a806-aee7923f83d2.png) ### Make order note block removable ([5139](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5139)) @@ -186,20 +190,18 @@ add_action( 'woocommerce_blocks_checkout_update_order_meta', function( $order ) - Products by Tag block - All products block - Single Product block -2. Click on the `edit` button of each block and verify that the button text corresponds to the value of the following table: - -| Block | Expected button text | -| —————————— | ———————————— | -| Featured Category | Edit selected category | -| Featured Product | Edit selected product | -| Hand-picked Products | Edit selected products | -| Products by Category | Edit selected categories | -| Products by Attribute | Edit selected attributes | -| Reviews by Product | Edit selected product | -| Reviews by Category | Edit selected categories | -| Products by Tag | Edit selected tags | -| All products | Rearrange inner blocks | -| Single Product | Edit selected product | +2. Click on the `edit` button of each block and verify that the button text corresponds to the value of the following list: + +- Featured Category: Edit selected category +- Featured Product: Edit selected product +- Hand-picked Products: Edit selected products +- Products by Category: Edit selected categories +- Products by Attribute: Edit selected attributes +- Reviews by Product: Edit selected product +- Reviews by Category: Edit selected categories +- Products by Tag: Edit selected tags +- All products: Rearrange inner blocks +- Single Product: Edit selected product Example of button text for the Hand-picked Products block: From 0a22a3cc74861479f52f9a313026cbb9df537a1e Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Tue, 16 Nov 2021 16:30:08 +0700 Subject: [PATCH 05/44] Update testing instructions --- docs/testing/releases/630.md | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/docs/testing/releases/630.md b/docs/testing/releases/630.md index 50c9167b772..fee197a8e64 100644 --- a/docs/testing/releases/630.md +++ b/docs/testing/releases/630.md @@ -111,7 +111,7 @@ add_action( 'woocommerce_blocks_checkout_update_order_from_request', function( $ 3. Install [the WP Debugging plugin](https://wordpress.org/plugins/wp-debugging/). 4. Add a product to your cart and check out using the Checkout block. Ensure it goes through correctly. 5. Check the `debug.log` file and ensure there’s a deprecation message logged for `__experimental_woocommerce_blocks_checkout_update_order_from_request`. -6. Ensure the order creation date is May 8th, 2000. +6. Ensure the order contains a customer note that is your browser's user agent. ℹ️ https://tastewp.com/ allows spinning up a free WordPress test site and downloading the `debug.log` file via the dashboard. @@ -191,17 +191,16 @@ add_action( 'woocommerce_blocks_checkout_update_order_meta', function( $order ) - All products block - Single Product block 2. Click on the `edit` button of each block and verify that the button text corresponds to the value of the following list: - -- Featured Category: Edit selected category -- Featured Product: Edit selected product -- Hand-picked Products: Edit selected products -- Products by Category: Edit selected categories -- Products by Attribute: Edit selected attributes -- Reviews by Product: Edit selected product -- Reviews by Category: Edit selected categories -- Products by Tag: Edit selected tags -- All products: Rearrange inner blocks -- Single Product: Edit selected product + - Featured Category: Edit selected category + - Featured Product: Edit selected product + - Hand-picked Products: Edit selected products + - Products by Category: Edit selected categories + - Products by Attribute: Edit selected attributes + - Reviews by Product: Edit selected product + - Reviews by Category: Edit selected categories + - Products by Tag: Edit selected tags + - All products: Rearrange inner blocks + - Single Product: Edit selected product Example of button text for the Hand-picked Products block: From b334ecd1e1a0eb3a25c419a1cb4464032f9f3897 Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Tue, 16 Nov 2021 16:38:48 +0700 Subject: [PATCH 06/44] Update testing instructions --- docs/testing/releases/630.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/testing/releases/630.md b/docs/testing/releases/630.md index fee197a8e64..30b955e6cf1 100644 --- a/docs/testing/releases/630.md +++ b/docs/testing/releases/630.md @@ -93,6 +93,8 @@ add_action( 'woocommerce_blocks_checkout_order_processed', function( $order ) { ℹ️ https://tastewp.com/ allows spinning up a free WordPress test site and downloading the `debug.log` file via the dashboard. +⚠️ Please note that testing this case requires the [WooCommerce Subscriptions](https://woocommerce.com/products/woocommerce-subscriptions/) extension. + ### Deprecate the \_\_experimental_woocommerce_blocks_checkout_update_order_from_request action in favor of woocommerce_blocks_checkout_update_order_from_request. ([5015](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5015)) 1. Install [the Code Snippets plugin](https://wordpress.org/plugins/code-snippets/). @@ -137,6 +139,8 @@ add_action( 'woocommerce_blocks_checkout_update_order_meta', function( $order ) ℹ️ https://tastewp.com/ allows spinning up a free WordPress test site and downloading the `debug.log` file via the dashboard. +⚠️ Please note that testing this case requires the [WooCommerce Subscriptions](https://woocommerce.com/products/woocommerce-subscriptions/) extension. + ## Feature plugin and package inclusion in WooCommerce ### FSE: Add basic taxonomy block templates. ([5063](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5063)) From 2af5c631c753ed74fda4916b17506ead4cf078d2 Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Tue, 16 Nov 2021 16:39:16 +0700 Subject: [PATCH 07/44] Update testing instructions --- docs/testing/releases/630.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/testing/releases/630.md b/docs/testing/releases/630.md index 30b955e6cf1..777e332d1a6 100644 --- a/docs/testing/releases/630.md +++ b/docs/testing/releases/630.md @@ -1,4 +1,4 @@ -## Testing notes and ZIP for release 6.2.0 +## Testing notes and ZIP for release 6.3.0 Zip file for testing: [woocommerce-gutenberg-products-block.zip](https://github.com/woocommerce/woocommerce-gutenberg-products-block/files/7543045/woocommerce-gutenberg-products-block.zip) From 6287e25d0d1924716897ec9846efc61d6e171398 Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Tue, 16 Nov 2021 18:43:26 +0700 Subject: [PATCH 08/44] Update readme.txt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Albert Juhé Lluveras --- readme.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/readme.txt b/readme.txt index cbd87e22f3e..4c3e08e1221 100644 --- a/readme.txt +++ b/readme.txt @@ -114,7 +114,6 @@ Release and roadmap notes available on the [WooCommerce Developers Blog](https:/ - Fix sale badge alignment on smaller screen. ([5061](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5061)) - Scripts using `wc-settings` or script that depend on it would be enqueued in the footer if they're enqueued in the header. ([5059](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5059)) - Replace incorrect with correct text domain. ([5020](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5020)) -- Fix button style of Mini Cart block for small screens. ([4907](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4907)) - Make order note block removable ([5139](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5139)) - Fix state validation to compare state codes, and only validate if a country is given ([5132](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5132)) - Fix 'Country is required' error on the Cart block when updating shipping address ([5129](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5129)) From 70a918cdb72ec1ed7213ff597f9e434307dea90f Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Tue, 16 Nov 2021 18:43:38 +0700 Subject: [PATCH 09/44] Update docs/testing/releases/630.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Albert Juhé Lluveras --- docs/testing/releases/630.md | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/docs/testing/releases/630.md b/docs/testing/releases/630.md index 777e332d1a6..1bb38021ba7 100644 --- a/docs/testing/releases/630.md +++ b/docs/testing/releases/630.md @@ -50,21 +50,6 @@ Example of a cart item with the CSS class `my-class`: 6. Go to the checkout page and verify that the new shipping address is visible. 7. Finalize the order and verify that the new shipping address is visible on the order details. -### Fix button style of Mini Cart block for small screens. ([4907](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4907)) - -1. Create a test page, add the columns block and save the page. -2. Add the mini cart block to one of the columns. -3. Verify that the mini card block contains the total, the number of items and the cart icon on a large screen (>= 768px). -4. Verify that the mini card block only contains the number of items and the cart icon on a small screen (< 768px). - -Large screen: - -![](https://user-images.githubusercontent.com/3323310/141926396-82eb319f-502f-4c3b-9aba-c9a3be9fe4e3.png) - -Small screen: - -![](https://user-images.githubusercontent.com/3323310/141926415-dbcf8133-ea26-4e08-a806-aee7923f83d2.png) - ### Make order note block removable ([5139](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5139)) 1. Create a test page, add the Checkout block and save the page. From d192480b32020d78fad800a15db4ed2868a159d9 Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Tue, 16 Nov 2021 19:36:43 +0700 Subject: [PATCH 10/44] Update readme.txt --- readme.txt | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/readme.txt b/readme.txt index 4c3e08e1221..5e4caeeb9ba 100644 --- a/readme.txt +++ b/readme.txt @@ -90,33 +90,32 @@ Release and roadmap notes available on the [WooCommerce Developers Blog](https:/ #### Enhancements - Add placeholder text when modifying product search input in the editor. ([5122](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5122)) -- Improve readability of terms and condition text by not displaying the text justified. ([5120](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5120)) -- Improve accessibility by using selfexplaining edit button titles. ([5113](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5113)) -- Improve rendering performance for Single Product block. ([5107](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5107)) -- FSE: Remove the `do_action( 'woocommerce_sidebar' );` action from the `LegacyTemplate.php` block. ([5097](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5097)) +- FSE: Add basic product archive block template. ([5049](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5049)) - FSE: Add basic taxonomy block templates. ([5063](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5063)) - FSE: Add single product block template. ([5054](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5054)) -- FSE: Add basic product archive block template. ([5049](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5049)) +- FSE: Remove the `do_action( 'woocommerce_sidebar' );` action from the `LegacyTemplate.php` block. ([5097](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5097)) - Fix duplicate queries in product grids #4695. ([5002](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5002)) -- Introduce `cartItemClass` filter for cart items in Cart and Checkout blocks. ([4992](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4992)) - FSE: Add abstract block legacy template for core PHP templates. ([4991](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4991)) - FSE: Add render logic to BlockTemplateController. ([4984](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4984)) +- Improve accessibility by using self-explaining edit button titles. ([5113](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5113)) +- Improve readability of terms and condition text by not displaying the text justified. ([5120](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5120)) +- Improve rendering performance for Single Product block. ([5107](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5107)) - Improve the product images placeholder display by adding a light gray border to it. ([4950](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4950)) -- Deprecate the __experimental_woocommerce_blocks_checkout_update_order_meta action in favour of woocommerce_blocks_checkout_update_order_meta. ([5017](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5017)) +- Introduce `cartItemClass` filter for cart items in Cart and Checkout blocks. ([4992](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4992)) - Deprecate the __experimental_woocommerce_blocks_checkout_update_order_from_request action in favour of woocommerce_blocks_checkout_update_order_from_request. ([5015](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5015)) +- Deprecate the __experimental_woocommerce_blocks_checkout_update_order_meta action in favour of woocommerce_blocks_checkout_update_order_meta. ([5017](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5017)) - Deprecate the __experimental_woocommerce_blocks_checkout_order_processed action in favour of woocommerce_blocks_checkout_order_processed. ([5014](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5014)) #### Bug Fixes -- Fixed an issue that was causing an error when updating the address in the Cart block's shipping calculator. ([5115](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5115)) +- Fix 'Country is required' error on the Cart block when updating shipping address ([5129](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5129)) - Fix label alignment of the product search in the editor. ([5072](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5072)) -- FSE: Fix missing `is_custom` property for WooCommerce block template objects. ([5067](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5067)) - Fix sale badge alignment on smaller screen. ([5061](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5061)) -- Scripts using `wc-settings` or script that depend on it would be enqueued in the footer if they're enqueued in the header. ([5059](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5059)) -- Replace incorrect with correct text domain. ([5020](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5020)) -- Make order note block removable ([5139](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5139)) - Fix state validation to compare state codes, and only validate if a country is given ([5132](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5132)) -- Fix 'Country is required' error on the Cart block when updating shipping address ([5129](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5129)) +- FSE: Fix missing `is_custom` property for WooCommerce block template objects. ([5067](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5067)) +- Make order note block removable ([5139](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5139)) +- Replace incorrect with correct text domain. ([5020](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5020)) +- Scripts using `wc-settings` or script that depend on it would be enqueued in the footer if they're enqueued in the header. ([5059](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5059)) = 6.2.0 - 2021-10-26 = From 9dccdeec5c7472143e88ee80136d62347d21cf49 Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Tue, 16 Nov 2021 20:49:38 +0700 Subject: [PATCH 11/44] Update release zip in testing note --- docs/testing/releases/630.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/testing/releases/630.md b/docs/testing/releases/630.md index 1bb38021ba7..cbf265e994f 100644 --- a/docs/testing/releases/630.md +++ b/docs/testing/releases/630.md @@ -1,6 +1,6 @@ ## Testing notes and ZIP for release 6.3.0 -Zip file for testing: [woocommerce-gutenberg-products-block.zip](https://github.com/woocommerce/woocommerce-gutenberg-products-block/files/7543045/woocommerce-gutenberg-products-block.zip) +Zip file for testing: [woocommerce-gutenberg-products-block.zip](https://github.com/woocommerce/woocommerce-gutenberg-products-block/files/7546650/woocommerce-gutenberg-products-block.zip) ## Feature Plugin From 633ad1af28ce35cfbdb5ebe95a10a1b1ec646fc9 Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Tue, 16 Nov 2021 21:56:00 +0700 Subject: [PATCH 12/44] Update testing instructions --- docs/testing/releases/630.md | 74 +----------------------------------- 1 file changed, 2 insertions(+), 72 deletions(-) diff --git a/docs/testing/releases/630.md b/docs/testing/releases/630.md index cbf265e994f..71e9958fef9 100644 --- a/docs/testing/releases/630.md +++ b/docs/testing/releases/630.md @@ -31,7 +31,7 @@ Example of a cart item with the CSS class `my-class`: ![](https://user-images.githubusercontent.com/3323310/141903888-ecdf5884-77bc-4709-a4ac-bebe5dd962f1.png) -### Fix incorrect text domain. ([5020](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5020)) +### Partially fix missing translations in the Checkout block. ([5020](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5020)) 1. Set the site language to Spanish. 2. Download the translation files via Dashboard → Updates. @@ -56,76 +56,6 @@ Example of a cart item with the CSS class `my-class`: 2. Remove the order note block and verify that it will not be added again. 3. Go to the frontend and verify that the order note block is not visible. -### Deprecate the \_\_experimental_woocommerce_blocks_checkout_order_processed action in favor of woocommerce_blocks_checkout_order_processed. ([5014](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5014)) - -1. Install [the Code Snippets plugin](https://wordpress.org/plugins/code-snippets/). -2. Add the following PHP snippet: - -``` -add_action( '__experimental_woocommerce_blocks_checkout_order_processed', function( $order ) { return; }, 10, 1 ); - -// For testing purposes, update the order date using the new hook. -add_action( 'woocommerce_blocks_checkout_order_processed', function( $order ) { - $order->set_date_created( '2000-05-08' ); - $order->save(); -} ); -``` - -3. Install [the WP Debugging plugin](https://wordpress.org/plugins/wp-debugging/). -4. Add a product to your cart and check out using the Checkout block. Ensure it goes through correctly. -5. Check the `debug.log` file and ensure there’s a deprecation message logged for `__experimental_woocommerce_blocks_checkout_order_processed`. -6. Ensure the order creation date is May 8th, 2000. - -ℹ️ https://tastewp.com/ allows spinning up a free WordPress test site and downloading the `debug.log` file via the dashboard. - -⚠️ Please note that testing this case requires the [WooCommerce Subscriptions](https://woocommerce.com/products/woocommerce-subscriptions/) extension. - -### Deprecate the \_\_experimental_woocommerce_blocks_checkout_update_order_from_request action in favor of woocommerce_blocks_checkout_update_order_from_request. ([5015](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5015)) - -1. Install [the Code Snippets plugin](https://wordpress.org/plugins/code-snippets/). -2. Add the following PHP snippet: - -``` -add_action( '__experimental_woocommerce_blocks_checkout_update_order_from_request', function( $order, $request ) { return; }, 10, 2 ); - -add_action( 'woocommerce_blocks_checkout_update_order_from_request', function( $order, $request ) { - // For testing purposes, set the customer note to the user-agent from the request. - $order->set_customer_note( $request->get_header('User-agent') ); - $order->save(); -}, 10, 2 ); -``` - -3. Install [the WP Debugging plugin](https://wordpress.org/plugins/wp-debugging/). -4. Add a product to your cart and check out using the Checkout block. Ensure it goes through correctly. -5. Check the `debug.log` file and ensure there’s a deprecation message logged for `__experimental_woocommerce_blocks_checkout_update_order_from_request`. -6. Ensure the order contains a customer note that is your browser's user agent. - -ℹ️ https://tastewp.com/ allows spinning up a free WordPress test site and downloading the `debug.log` file via the dashboard. - -### Deprecate the \_\_experimental_woocommerce_blocks_checkout_update_order_meta action in favor of woocommerce_blocks_checkout_update_order_meta. ([5017](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5017)) - -1. Install [the Code Snippets plugin](https://wordpress.org/plugins/code-snippets/). -2. Add the following PHP snippet: - -``` -add_action( '__experimental_woocommerce_blocks_checkout_update_order_meta', function( $order ) { return; }, 10, 1 ); - -// For testing purposes, update the order date using the new hook. -add_action( 'woocommerce_blocks_checkout_update_order_meta', function( $order ) { - $order->set_date_created( '2000-05-08' ); - $order->save(); -} ); -``` - -3. Install [the WP Debugging plugin](https://wordpress.org/plugins/wp-debugging/). -4. Add a product to your cart and check out using the Checkout block. Ensure it goes through correctly. -5. Check the `debug.log` file and ensure there’s a deprecation message logged for `__experimental_woocommerce_blocks_checkout_update_order_meta`. -6. Ensure the order creation date is May 8th, 2000. - -ℹ️ https://tastewp.com/ allows spinning up a free WordPress test site and downloading the `debug.log` file via the dashboard. - -⚠️ Please note that testing this case requires the [WooCommerce Subscriptions](https://woocommerce.com/products/woocommerce-subscriptions/) extension. - ## Feature plugin and package inclusion in WooCommerce ### FSE: Add basic taxonomy block templates. ([5063](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5063)) @@ -163,7 +93,7 @@ add_action( 'woocommerce_blocks_checkout_update_order_meta', function( $order ) ### Improve the product images placeholder display by adding a light gray border to it. ([4950](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4950)) 1. Create a product with no product image. -2. Create a test page and add the Newest Products block. +2. Create a test page and add the Newest Products block.Ftext 3. Verify that the placeholder image has a visible border. ### Improve accessibility by using self-explaining edit button titles. ([5113](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5113)) From 24ff0f12047c219ae7dbc8dc784e6da46c1585b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Juh=C3=A9=20Lluveras?= Date: Tue, 16 Nov 2021 17:55:08 +0100 Subject: [PATCH 13/44] Remove feature gate condition for Legacy Template block (#5158) --- assets/js/blocks/legacy-template/index.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/assets/js/blocks/legacy-template/index.tsx b/assets/js/blocks/legacy-template/index.tsx index 3da6fefaea0..4a43612e02e 100644 --- a/assets/js/blocks/legacy-template/index.tsx +++ b/assets/js/blocks/legacy-template/index.tsx @@ -1,10 +1,8 @@ /** * External dependencies */ -import { - registerExperimentalBlockType, - WC_BLOCKS_IMAGE_URL, -} from '@woocommerce/block-settings'; +import { registerBlockType } from '@wordpress/blocks'; +import { WC_BLOCKS_IMAGE_URL } from '@woocommerce/block-settings'; import { useBlockProps } from '@wordpress/block-editor'; import { Placeholder } from '@wordpress/components'; import { __, sprintf } from '@wordpress/i18n'; @@ -57,7 +55,7 @@ const Edit = ( { attributes }: Props ) => { ); }; -registerExperimentalBlockType( 'woocommerce/legacy-template', { +registerBlockType( 'woocommerce/legacy-template', { title: __( 'WooCommerce Legacy Template', 'woo-gutenberg-products-block' ), category: 'woocommerce', apiVersion: 2, From ec0ebd2ee3a1e724e99bd07f200628dff473f8ad Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Wed, 17 Nov 2021 11:10:02 +0700 Subject: [PATCH 14/44] Update testing instructions --- docs/testing/releases/630.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/testing/releases/630.md b/docs/testing/releases/630.md index 71e9958fef9..98846ad443a 100644 --- a/docs/testing/releases/630.md +++ b/docs/testing/releases/630.md @@ -108,7 +108,6 @@ Example of a cart item with the CSS class `my-class`: - Reviews by Category block - Products by Tag block - All products block - - Single Product block 2. Click on the `edit` button of each block and verify that the button text corresponds to the value of the following list: - Featured Category: Edit selected category - Featured Product: Edit selected product @@ -119,7 +118,6 @@ Example of a cart item with the CSS class `my-class`: - Reviews by Category: Edit selected categories - Products by Tag: Edit selected tags - All products: Rearrange inner blocks - - Single Product: Edit selected product Example of button text for the Hand-picked Products block: From 9e9f1a79bb191f1efae82a1bb21602a930aa475f Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Wed, 17 Nov 2021 11:16:59 +0700 Subject: [PATCH 15/44] Update testing instructions --- docs/testing/releases/630.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/testing/releases/630.md b/docs/testing/releases/630.md index 98846ad443a..9bc8d2cc82b 100644 --- a/docs/testing/releases/630.md +++ b/docs/testing/releases/630.md @@ -117,7 +117,7 @@ Example of a cart item with the CSS class `my-class`: - Reviews by Product: Edit selected product - Reviews by Category: Edit selected categories - Products by Tag: Edit selected tags - - All products: Rearrange inner blocks + - All products: Edit inner product layout Example of button text for the Hand-picked Products block: From 02519f4cee00cd981d8bc3f8fec4482abf0b2a5b Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Wed, 17 Nov 2021 11:50:58 +0700 Subject: [PATCH 16/44] Update testing instructions --- docs/testing/releases/630.md | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/docs/testing/releases/630.md b/docs/testing/releases/630.md index 9bc8d2cc82b..02f310f09c8 100644 --- a/docs/testing/releases/630.md +++ b/docs/testing/releases/630.md @@ -10,27 +10,6 @@ Zip file for testing: [woocommerce-gutenberg-products-block.zip](https://github. 2. Add a short custom text to the terms and conditions section. 3. Verify that the terms and conditions text is left-aligned and contains even spacing between the words. -### Introduce `cartItemClass` filter for cart items in Cart and Checkout blocks. ([4992](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4992)) - -1. Install [the Simple Custom CSS and JS plugin](https://wordpress.org/plugins/custom-css-js/). -2. Add the following custom JS code and load it in the frontend in the footer: - -``` -const { __experimentalRegisterCheckoutFilters } = window.wc.blocksCheckout; -__experimentalRegisterCheckoutFilters( 'my-hypothetical-deposit-plugin', { - cartItemClass: () => 'my-class', -} ); -``` - -3. Create a test page, add the cart block to it and save it. -4. Go to the frontend and add a product to the cart. -5. Go to the cart page and ensure that cart item has the CSS class `my-class`. -6. Go to the checkout page and ensure that the cart item has the CSS class `my-class`. - -Example of a cart item with the CSS class `my-class`: - -![](https://user-images.githubusercontent.com/3323310/141903888-ecdf5884-77bc-4709-a4ac-bebe5dd962f1.png) - ### Partially fix missing translations in the Checkout block. ([5020](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5020)) 1. Set the site language to Spanish. From 3de327c0448541b62563eb23285486cb8d28c663 Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Wed, 17 Nov 2021 11:51:59 +0700 Subject: [PATCH 17/44] Update readme.txt --- readme.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/readme.txt b/readme.txt index 5e4caeeb9ba..a8cc3993a8b 100644 --- a/readme.txt +++ b/readme.txt @@ -101,7 +101,6 @@ Release and roadmap notes available on the [WooCommerce Developers Blog](https:/ - Improve readability of terms and condition text by not displaying the text justified. ([5120](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5120)) - Improve rendering performance for Single Product block. ([5107](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5107)) - Improve the product images placeholder display by adding a light gray border to it. ([4950](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4950)) -- Introduce `cartItemClass` filter for cart items in Cart and Checkout blocks. ([4992](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4992)) - Deprecate the __experimental_woocommerce_blocks_checkout_update_order_from_request action in favour of woocommerce_blocks_checkout_update_order_from_request. ([5015](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5015)) - Deprecate the __experimental_woocommerce_blocks_checkout_update_order_meta action in favour of woocommerce_blocks_checkout_update_order_meta. ([5017](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5017)) - Deprecate the __experimental_woocommerce_blocks_checkout_order_processed action in favour of woocommerce_blocks_checkout_order_processed. ([5014](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5014)) From 8008e27d24e283c33f80b47dff85c7f8835a92fa Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Wed, 17 Nov 2021 12:14:57 +0700 Subject: [PATCH 18/44] Update testing instructions --- docs/testing/releases/630.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/testing/releases/630.md b/docs/testing/releases/630.md index 02f310f09c8..4b89534759d 100644 --- a/docs/testing/releases/630.md +++ b/docs/testing/releases/630.md @@ -72,7 +72,7 @@ Zip file for testing: [woocommerce-gutenberg-products-block.zip](https://github. ### Improve the product images placeholder display by adding a light gray border to it. ([4950](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4950)) 1. Create a product with no product image. -2. Create a test page and add the Newest Products block.Ftext +2. Create a test page and add the Newest Products block. 3. Verify that the placeholder image has a visible border. ### Improve accessibility by using self-explaining edit button titles. ([5113](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5113)) From a8791ef5e1ad359623f5e28f941b7c998cec6e53 Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Wed, 17 Nov 2021 12:40:28 +0700 Subject: [PATCH 19/44] Update testing instructions --- docs/testing/releases/630.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/testing/releases/630.md b/docs/testing/releases/630.md index 4b89534759d..a63a294ab42 100644 --- a/docs/testing/releases/630.md +++ b/docs/testing/releases/630.md @@ -107,7 +107,7 @@ Example of button text for the Hand-picked Products block: 1. Create a test page, add the Product Search block and save the page. 2. Verify if the search label is vertically aligned with the search input field and that the block looks equal in the editor and on the frontend. -### Fix duplicate queries in product grids #4695. ([5002](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5002)) +### Fix duplicate queries in product grids. ([5002](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5002)) 1. Add multiple product grid blocks to a page, e.g. `Products by Category` and `Products by Category`. 2. Ensure there are some variable products visible. From 99880087f30dd260cc3f5d012cf8bec463d2e979 Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Wed, 17 Nov 2021 13:39:20 +0700 Subject: [PATCH 20/44] Update release zip in testing note --- docs/testing/releases/630.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/testing/releases/630.md b/docs/testing/releases/630.md index a63a294ab42..b27c581a82e 100644 --- a/docs/testing/releases/630.md +++ b/docs/testing/releases/630.md @@ -1,6 +1,6 @@ ## Testing notes and ZIP for release 6.3.0 -Zip file for testing: [woocommerce-gutenberg-products-block.zip](https://github.com/woocommerce/woocommerce-gutenberg-products-block/files/7546650/woocommerce-gutenberg-products-block.zip) +Zip file for testing: [woocommerce-gutenberg-products-block.zip](https://github.com/woocommerce/woocommerce-gutenberg-products-block/files/7552325/woocommerce-gutenberg-products-block.zip) ## Feature Plugin From ddcde989e4b2d9b7e3f2a74d83e8299f27bc3915 Mon Sep 17 00:00:00 2001 From: "Michael P. Pfeiffer" Date: Wed, 17 Nov 2021 08:13:19 +0100 Subject: [PATCH 21/44] Update testing instructions for SE templates --- docs/testing/releases/630.md | 39 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/docs/testing/releases/630.md b/docs/testing/releases/630.md index b27c581a82e..548ba0c5732 100644 --- a/docs/testing/releases/630.md +++ b/docs/testing/releases/630.md @@ -37,30 +37,31 @@ Zip file for testing: [woocommerce-gutenberg-products-block.zip](https://github. ## Feature plugin and package inclusion in WooCommerce -### FSE: Add basic taxonomy block templates. ([5063](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5063)) +### FSE: Add basic single product block template. ([5054](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5054)) -1. Install and activate [the Gutenberg plugin](https://wordpress.org/plugins/gutenberg/) (not the latest built version of `trunk` from the repo). -2. Install and activate a FSE enabled theme, such as [the Tove theme](https://wordpress.org/themes/tove/). -3. Load the Site Editor (Appearance → Editor) and select the `Product Category Page` template from the `General templates` section. -4. Confirm you can load the template, and it looks as expected in large/small viewports. -5. Confirm the behavior on the frontend on a category page, e.g. `/product-category/clothing/` is identical to the behavior the same page without this PR applied. -6. Repeat steps 3-5 for the `Product Tag Page` template (e.g. `/product-tag/merch/`). +1. Install and activate version 11.9.1 of [the Gutenberg plugin](https://wordpress.org/plugins/gutenberg/). +2. Install and activate a FSE enabled theme, such as [the TT1 Blocks theme](https://wordpress.org/themes/tt1-blocks/). +3. Load the Site Editor (Appearance → Editor). Open the left editor sidebar navigation by clicking the WordPress logo in the top left. In the Templates > General Templates section select the `Single Product Page` template. +4. Confirm you can load the template in the editor and it looks as expected in large/small viewports. +5. Confirm you can add blocks to the template and saving works as expected. +6. Load a single product page (e.g. `/product/album/`) on the Frontend of your store. Confirm the template is loaded and your modifications from the previous step are visible. -### FSE: Add single product block template. ([5054](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5054)) +### FSE: Add basic product archive block template. ([5049](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5049)) -1. Install and activate [the Gutenberg plugin](https://wordpress.org/plugins/gutenberg/) (not the latest built version of `trunk` from the repo). -2. Install and activate a FSE enabled theme, such as [the Tove theme](https://wordpress.org/themes/tove/). -3. Load the Site Editor (Appearance → Editor) and select the `Single Product Page` template from the `General templates` section. -4. Confirm you can load the template. It will have a temporary placeholder block. This SVG will be replaced in a future PR. -5. Confirm the behavior on the frontend product page is identical to the behavior on the product page without this PR applied. +1. Install and activate version 11.9.1 of [the Gutenberg plugin](https://wordpress.org/plugins/gutenberg/). +2. Install and activate a FSE enabled theme, such as [the TT1 Blocks theme](https://wordpress.org/themes/tt1-blocks/). +3. Load the Site Editor (Appearance → Editor). Open the left editor sidebar navigation by clicking the WordPress logo in the top left. In the Templates > General Templates section select the `Product Archive Page` template. +4. Confirm you can load the template in the editor and it looks as expected in large/small viewports. +5. Confirm you can add blocks to the template and saving works as expected. -### FSE: Add basic product archive block template. ([5049](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5049)) +### FSE: Add basic taxonomy block templates. ([5063](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5063)) -1. Install and activate [the Gutenberg plugin](https://wordpress.org/plugins/gutenberg/) (not the latest built version of `trunk` from the repo). -2. Install and activate a FSE enabled theme, such as [the Tove theme](https://wordpress.org/themes/tove/). -3. Load the Site Editor (Appearance → Editor) and select the `Product Archive Page` template from the `General templates` section. -4. Confirm you can load the template, and it looks as expected in large/small viewports as per the screenshots above. -5. Confirm the behavior on the Frontend on `/shop` is identical to the behavior on `/shop` without this PR applied. +1. Install and activate version 11.9.1 of [the Gutenberg plugin](https://wordpress.org/plugins/gutenberg/). +2. Install and activate a FSE enabled theme, such as [the TT1 Blocks theme](https://wordpress.org/themes/tt1-blocks/). +3. Load the Site Editor (Appearance → Editor). Open the left editor sidebar navigation by clicking the WordPress logo in the top left. In the Templates > General Templates section select the `Product Category Page` template. +4. Confirm you can load the template in the editor and it looks as expected in large/small viewports. +5. Confirm you can add blocks to the template and saving works as expected. +6. Repeat steps 3-5 for the `Product Tag Page` template (e.g. `/product-tag/merch/`). ### Add placeholder text when modifying product search input in the editor. ([5122](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5122)) From 18cbe705af425ca1ac8cd7a064ecd5300a5ca514 Mon Sep 17 00:00:00 2001 From: "Michael P. Pfeiffer" Date: Wed, 17 Nov 2021 08:14:25 +0100 Subject: [PATCH 22/44] Update testing instructions for SE templates II --- docs/testing/releases/630.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/testing/releases/630.md b/docs/testing/releases/630.md index 548ba0c5732..9aa6111f998 100644 --- a/docs/testing/releases/630.md +++ b/docs/testing/releases/630.md @@ -61,7 +61,7 @@ Zip file for testing: [woocommerce-gutenberg-products-block.zip](https://github. 3. Load the Site Editor (Appearance → Editor). Open the left editor sidebar navigation by clicking the WordPress logo in the top left. In the Templates > General Templates section select the `Product Category Page` template. 4. Confirm you can load the template in the editor and it looks as expected in large/small viewports. 5. Confirm you can add blocks to the template and saving works as expected. -6. Repeat steps 3-5 for the `Product Tag Page` template (e.g. `/product-tag/merch/`). +6. Repeat steps 3-5 for the `Product Tag Page` template. ### Add placeholder text when modifying product search input in the editor. ([5122](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5122)) From 331395080349d766098a3960d188870dc0f98274 Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Wed, 17 Nov 2021 17:09:16 +0700 Subject: [PATCH 23/44] Update testing instructions --- docs/testing/releases/630.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/testing/releases/630.md b/docs/testing/releases/630.md index 9aa6111f998..c7b108aca9d 100644 --- a/docs/testing/releases/630.md +++ b/docs/testing/releases/630.md @@ -106,7 +106,8 @@ Example of button text for the Hand-picked Products block: ### Fix label alignment of the product search in the editor. ([5072](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5072)) 1. Create a test page, add the Product Search block and save the page. -2. Verify if the search label is vertically aligned with the search input field and that the block looks equal in the editor and on the frontend. +2. Verify that the search label is vertically aligned with the search input field in the editor side and in the frontend side. +3. Verify that the right button is aligned with the input field. ### Fix duplicate queries in product grids. ([5002](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5002)) From 4c8d74f6481e3325e1f278d8952d7d1a83c2650c Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Wed, 17 Nov 2021 18:53:34 +0700 Subject: [PATCH 24/44] Bumping version strings to new version. --- package.json | 2 +- readme.txt | 2 +- src/Package.php | 2 +- woocommerce-gutenberg-products-block.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index dbafbe5d7bd..6200bfc6984 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@woocommerce/block-library", "title": "WooCommerce Blocks", "author": "Automattic", - "version": "6.3.0-dev", + "version": "6.3.0", "description": "WooCommerce blocks for the Gutenberg editor.", "homepage": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/", "keywords": [ diff --git a/readme.txt b/readme.txt index a8cc3993a8b..bca6f22a681 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: gutenberg, woocommerce, woo commerce, products, blocks, woocommerce blocks Requires at least: 5.8 Tested up to: 5.8 Requires PHP: 7.0 -Stable tag: 6.3.0-dev +Stable tag: 6.3.0 License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.html diff --git a/src/Package.php b/src/Package.php index 2684974cd8a..b4d383078fe 100644 --- a/src/Package.php +++ b/src/Package.php @@ -106,7 +106,7 @@ public static function container( $reset = false ) { NewPackage::class, function ( $container ) { // leave for automated version bumping. - $version = '6.3.0-dev'; + $version = '6.3.0'; return new NewPackage( $version, dirname( __DIR__ ), diff --git a/woocommerce-gutenberg-products-block.php b/woocommerce-gutenberg-products-block.php index 2b14e524635..11f06368c85 100644 --- a/woocommerce-gutenberg-products-block.php +++ b/woocommerce-gutenberg-products-block.php @@ -3,7 +3,7 @@ * Plugin Name: WooCommerce Blocks * Plugin URI: https://github.com/woocommerce/woocommerce-gutenberg-products-block * Description: WooCommerce blocks for the Gutenberg editor. - * Version: 6.3.0-dev + * Version: 6.3.0 * Author: Automattic * Author URI: https://woocommerce.com * Text Domain: woo-gutenberg-products-block From 1d9ca4b9c2fa99d0df56eed8c9bb0a4ad93338ce Mon Sep 17 00:00:00 2001 From: github-actions Date: Wed, 17 Nov 2021 13:28:01 +0000 Subject: [PATCH 25/44] Empty commit for release pull request From a6c4fd0578455c303c8610249f491a3915b27442 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 16 Nov 2021 11:19:56 +0000 Subject: [PATCH 26/44] Fix state validation to compare state codes, and only validate if a country is given (#5132) * Only get valid states from wc if there is a country * Shared validation logic which uses keys --- .../Schemas/AbstractAddressSchema.php | 48 +++++++++++++++---- src/StoreApi/Schemas/BillingAddressSchema.php | 3 +- .../Schemas/ShippingAddressSchema.php | 3 +- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/src/StoreApi/Schemas/AbstractAddressSchema.php b/src/StoreApi/Schemas/AbstractAddressSchema.php index 5b70759902e..c17f497ced5 100644 --- a/src/StoreApi/Schemas/AbstractAddressSchema.php +++ b/src/StoreApi/Schemas/AbstractAddressSchema.php @@ -107,18 +107,47 @@ public function sanitize_callback( $address, $request, $param ) { } /** - * Format a state based on the country. If country has defined states, will return an upper case state code. + * Get list of states for a country. + * + * @param string $country Country code. + * @return array Array of state names indexed by state keys. + */ + protected function get_states_for_country( $country ) { + return $country ? array_filter( (array) \wc()->countries->get_states( $country ) ) : []; + } + + /** + * Validate provided state against a countries list of defined states. + * + * If there are no defined states for a country, any given state is valid. + * + * @param string $state State name or code (sanitized). + * @param string $country Country code. + * @return boolean Valid or not valid. + */ + protected function validate_state( $state, $country ) { + $states = $this->get_states_for_country( $country ); + + if ( count( $states ) && ! in_array( \wc_strtoupper( $state ), array_map( '\wc_strtoupper', array_keys( $states ) ), true ) ) { + return false; + } + + return true; + } + + /** + * Format a state based on the country. If country has defined states, will return a valid upper case state code. * * @param string $state State name or code (sanitized). * @param string $country Country code. * @return string */ protected function format_state( $state, $country ) { - $states = $country ? array_filter( (array) wc()->countries->get_states( $country ) ) : []; + $states = $this->get_states_for_country( $country ); if ( count( $states ) ) { - $state = wc_strtoupper( $state ); - $state_values = array_map( 'wc_strtoupper', array_flip( array_map( 'wc_strtoupper', $states ) ) ); + $state = \wc_strtoupper( $state ); + $state_values = array_map( 'wc_strtoupper', array_flip( array_map( '\wc_strtoupper', $states ) ) ); if ( isset( $state_values[ $state ] ) ) { // Convert to state code if a state name was provided. @@ -163,15 +192,14 @@ public function validate_callback( $address, $request, $param ) { return $errors; } - $states = array_filter( array_keys( (array) wc()->countries->get_states( $address['country'] ) ) ); - - if ( ! empty( $address['state'] ) && count( $states ) && ! in_array( $address['state'], $states, true ) ) { + if ( ! empty( $address['state'] ) && ! $this->validate_state( $address['state'], $address['country'] ) ) { $errors->add( 'invalid_state', sprintf( - /* translators: %s valid states */ - __( 'The provided state is not valid. Must be one of: %s', 'woo-gutenberg-products-block' ), - implode( ', ', $states ) + /* translators: %1$s given state, %2$s valid states */ + __( 'The provided state (%1$s) is not valid. Must be one of: %2$s', 'woo-gutenberg-products-block' ), + esc_html( $address['state'] ), + implode( ', ', array_keys( $this->get_states_for_country( $address['country'] ) ) ) ) ); } diff --git a/src/StoreApi/Schemas/BillingAddressSchema.php b/src/StoreApi/Schemas/BillingAddressSchema.php index d8c899e381d..89ab1dd12df 100644 --- a/src/StoreApi/Schemas/BillingAddressSchema.php +++ b/src/StoreApi/Schemas/BillingAddressSchema.php @@ -95,9 +95,8 @@ public function get_item_response( $address ) { if ( ( $address instanceof \WC_Customer || $address instanceof \WC_Order ) ) { $billing_country = $address->get_billing_country(); $billing_state = $address->get_billing_state(); - $valid_states = array_filter( (array) wc()->countries->get_states( $billing_country ) ); - if ( ! empty( $billing_state ) && count( $valid_states ) && ! in_array( $billing_state, $valid_states, true ) ) { + if ( ! $this->validate_state( $billing_state, $billing_country ) ) { $billing_state = ''; } diff --git a/src/StoreApi/Schemas/ShippingAddressSchema.php b/src/StoreApi/Schemas/ShippingAddressSchema.php index fb3175afd0b..af3f2c1618e 100644 --- a/src/StoreApi/Schemas/ShippingAddressSchema.php +++ b/src/StoreApi/Schemas/ShippingAddressSchema.php @@ -44,9 +44,8 @@ public function get_item_response( $address ) { $shipping_country = $address->get_shipping_country(); $shipping_state = $address->get_shipping_state(); - $valid_states = array_filter( (array) wc()->countries->get_states( $shipping_country ) ); - if ( ! empty( $shipping_state ) && count( $valid_states ) && ! in_array( $shipping_state, $valid_states, true ) ) { + if ( ! $this->validate_state( $shipping_state, $shipping_country ) ) { $shipping_state = ''; } From a274933ed11a400dd33d602cc1426d2fde34e4d6 Mon Sep 17 00:00:00 2001 From: Alex Florisca Date: Tue, 16 Nov 2021 12:39:43 +0000 Subject: [PATCH 27/44] Fix 'Country is required' error on the Cart block when updating shipping address (#5129) * Fix error on the Cart block * Created a cartIsHydrated variable in useStoreCart hook and used this to update the billing address in the internal state of the useCustomerData hook * Fix the country is required error on the Cart page using refs * Separate api calls to update shipping and billingUpdate billing and shipping addresses only when needed in API calls * Remove redundant check for customerDataToUpdate * remove use of refs in initial values Co-authored-by: Nadir Seghir --- .../base/context/hooks/cart/use-store-cart.ts | 1 + .../base/context/hooks/use-customer-data.ts | 70 +++++++++++++++---- assets/js/data/cart/actions.ts | 10 +-- assets/js/types/type-defs/cart.ts | 5 ++ 4 files changed, 63 insertions(+), 23 deletions(-) diff --git a/assets/js/base/context/hooks/cart/use-store-cart.ts b/assets/js/base/context/hooks/cart/use-store-cart.ts index c59602fed09..7430f0978bc 100644 --- a/assets/js/base/context/hooks/cart/use-store-cart.ts +++ b/assets/js/base/context/hooks/cart/use-store-cart.ts @@ -184,6 +184,7 @@ export const useStoreCart = ( const cartIsLoading = ! store.hasFinishedResolution( 'getCartData' ); + const shippingRatesLoading = store.isCustomerDataUpdating(); const { receiveCart } = dispatch( storeKey ); const billingAddress = decodeValues( cartData.billingAddress ); diff --git a/assets/js/base/context/hooks/use-customer-data.ts b/assets/js/base/context/hooks/use-customer-data.ts index 98dcce60c2d..2f7fec296e5 100644 --- a/assets/js/base/context/hooks/use-customer-data.ts +++ b/assets/js/base/context/hooks/use-customer-data.ts @@ -11,9 +11,12 @@ import { pluckAddress, pluckEmail, } from '@woocommerce/base-utils'; -import type { +import { CartResponseBillingAddress, CartResponseShippingAddress, + BillingAddressShippingAddress, + CartBillingAddress, + CartShippingAddress, } from '@woocommerce/types'; declare type CustomerData = { @@ -92,6 +95,26 @@ export const useCustomerData = (): { shippingAddress: initialShippingAddress, } ); + // We only want to update the local state once, otherwise the data on the checkout page gets overwritten + // with the initial state of the addresses here + const [ hasCustomerDataSynced, setHasCustomerDataSynced ] = useState< + boolean + >( false ); + + if ( + ! hasCustomerDataSynced && + shouldUpdateAddressStore( + customerData.shippingAddress, + initialShippingAddress + ) + ) { + setCustomerData( { + billingData: initialBillingAddress, + shippingAddress: initialShippingAddress, + } ); + setHasCustomerDataSynced( true ); + } + // Store values last sent to the server in a ref to avoid requests unless important fields are changed. const previousCustomerData = useRef< CustomerData >( customerData ); @@ -146,23 +169,40 @@ export const useCustomerData = (): { */ useEffect( () => { // Only push updates when enough fields are populated. - if ( - ! shouldUpdateAddressStore( - previousCustomerData.current.billingData, - debouncedCustomerData.billingData - ) && - ! shouldUpdateAddressStore( - previousCustomerData.current.shippingAddress, - debouncedCustomerData.shippingAddress - ) - ) { + const shouldUpdateBillingAddress = shouldUpdateAddressStore( + previousCustomerData.current.billingData, + debouncedCustomerData.billingData + ); + + const shouldUpdateShippingAddress = shouldUpdateAddressStore( + previousCustomerData.current.shippingAddress, + debouncedCustomerData.shippingAddress + ); + + if ( ! shouldUpdateBillingAddress && ! shouldUpdateShippingAddress ) { return; } + + const customerDataToUpdate: + | Partial< BillingAddressShippingAddress > + | Record< + keyof BillingAddressShippingAddress, + CartBillingAddress | CartShippingAddress + > = {}; + + if ( shouldUpdateBillingAddress ) { + customerDataToUpdate.billing_address = + debouncedCustomerData.billingData; + } + if ( shouldUpdateShippingAddress ) { + customerDataToUpdate.shipping_address = + debouncedCustomerData.shippingAddress; + } + previousCustomerData.current = debouncedCustomerData; - updateCustomerData( { - billing_address: debouncedCustomerData.billingData, - shipping_address: debouncedCustomerData.shippingAddress, - } ) + updateCustomerData( + customerDataToUpdate as Partial< BillingAddressShippingAddress > + ) .then( () => { removeNotice( 'checkout' ); } ) diff --git a/assets/js/data/cart/actions.ts b/assets/js/data/cart/actions.ts index 7b276a1aba6..253c8b3ffd7 100644 --- a/assets/js/data/cart/actions.ts +++ b/assets/js/data/cart/actions.ts @@ -6,9 +6,8 @@ import type { Cart, CartResponse, CartResponseItem, - CartBillingAddress, - CartShippingAddress, ExtensionCartUpdateArgs, + BillingAddressShippingAddress, } from '@woocommerce/types'; import { ReturnOrGeneratorYieldUnion } from '@automattic/data-stores'; import { camelCase, mapKeys } from 'lodash'; @@ -463,11 +462,6 @@ export function* selectShippingRate( return true; } -type BillingAddressShippingAddress = { - billing_address: CartBillingAddress; - shipping_address: CartShippingAddress; -}; - /** * Updates the shipping and/or billing address for the customer and returns an * updated cart. @@ -476,7 +470,7 @@ type BillingAddressShippingAddress = { * billing_address and shipping_address. */ export function* updateCustomerData( - customerData: BillingAddressShippingAddress + customerData: Partial< BillingAddressShippingAddress > ): Generator< unknown, boolean, { response: CartResponse } > { yield updatingCustomerData( true ); diff --git a/assets/js/types/type-defs/cart.ts b/assets/js/types/type-defs/cart.ts index c04cb3a0e24..ce8cbe83ed0 100644 --- a/assets/js/types/type-defs/cart.ts +++ b/assets/js/types/type-defs/cart.ts @@ -198,3 +198,8 @@ export interface ExtensionCartUpdateArgs { data: Record< string, unknown >; namespace: string; } + +export interface BillingAddressShippingAddress { + billing_address: CartBillingAddress; + shipping_address: CartShippingAddress; +} From c2cd5fecd9801e3a8df3b14c107f1ab5617e1de6 Mon Sep 17 00:00:00 2001 From: Seghir Nadir Date: Tue, 16 Nov 2021 14:12:25 +0100 Subject: [PATCH 28/44] Make order note block removable (#5139) * unforce order note * show block in inserter --- .../inner-blocks/checkout-order-note-block/block.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/block.json b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/block.json index c9d769eca23..e6eb1387922 100644 --- a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/block.json +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/block.json @@ -8,8 +8,7 @@ "align": false, "html": false, "multiple": false, - "reusable": false, - "inserter": false + "reusable": false }, "attributes": { "className": { @@ -19,7 +18,7 @@ "lock": { "type": "object", "default": { - "remove": true, + "remove": false, "move": true } } From 584fd604d7fd724820ebd40df9f646fdcc9a937e Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 16 Nov 2021 13:14:00 +0000 Subject: [PATCH 29/44] Mini Cart block fatal error caused by append_script_and_deps_src (#5142) * Remove unused use statements * Fix types for $script * `get_script_from_handle` might return null so handle this case to prevent errors * Missing escaping --- src/BlockTypes/MiniCart.php | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/BlockTypes/MiniCart.php b/src/BlockTypes/MiniCart.php index a875d64c885..9794bc9b4f5 100644 --- a/src/BlockTypes/MiniCart.php +++ b/src/BlockTypes/MiniCart.php @@ -2,8 +2,6 @@ namespace Automattic\WooCommerce\Blocks\BlockTypes; use Automattic\WooCommerce\Blocks\Package; -use Automattic\WooCommerce\Blocks\Assets; -use Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry; use Automattic\WooCommerce\Blocks\StoreApi\Utilities\CartController; use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry; @@ -102,7 +100,10 @@ protected function enqueue_data( array $attributes = [] ) { foreach ( $payment_methods as $payment_method ) { $payment_method_script = $this->get_script_from_handle( $payment_method ); - $this->append_script_and_deps_src( $payment_method_script ); + + if ( ! is_null( $payment_method_script ) ) { + $this->append_script_and_deps_src( $payment_method_script ); + } } $this->scripts_to_lazy_load['wc-block-mini-cart-component-frontend'] = array( @@ -140,7 +141,7 @@ protected function hydrate_from_api() { * * @param string $handle Handle of the script. * - * @return array Array containing the script data. + * @return \_WP_Dependency|null Object containing the script data if found, or null. */ protected function get_script_from_handle( $handle ) { $wp_scripts = wp_scripts(); @@ -149,28 +150,30 @@ protected function get_script_from_handle( $handle ) { return $script; } } - - return ''; + return null; } /** - * Recursively appends a scripts and its dependencies into the - * scripts_to_lazy_load array. + * Recursively appends a scripts and its dependencies into the scripts_to_lazy_load array. * - * @param string $script Array containing script data. + * @param \_WP_Dependency $script Object containing script data. */ protected function append_script_and_deps_src( $script ) { $wp_scripts = wp_scripts(); + // This script and its dependencies have already been appended. - if ( array_key_exists( $script->handle, $this->scripts_to_lazy_load ) ) { + if ( ! $script || array_key_exists( $script->handle, $this->scripts_to_lazy_load ) ) { return; } - if ( count( $script->deps ) > 0 ) { + if ( count( $script->deps ) ) { foreach ( $script->deps as $dep ) { if ( ! array_key_exists( $dep, $this->scripts_to_lazy_load ) ) { $dep_script = $this->get_script_from_handle( $dep ); - $this->append_script_and_deps_src( $dep_script ); + + if ( ! is_null( $dep_script ) ) { + $this->append_script_and_deps_src( $dep_script ); + } } } } @@ -252,7 +255,7 @@ protected function get_markup() { '; - $button_html = '' . wp_strip_all_tags( wc_price( $cart_contents_total ) ) . ' + $button_html = '' . esc_html( wp_strip_all_tags( wc_price( $cart_contents_total ) ) ) . ' ' . $icon . ' ' . $cart_contents_count . ' @@ -260,18 +263,18 @@ protected function get_markup() { if ( is_cart() || is_checkout() ) { return '
- +
'; } return '
- +