diff --git a/plugins/woocommerce-blocks/assets/js/base/context/cart-checkout/checkout/processor/index.js b/plugins/woocommerce-blocks/assets/js/base/context/cart-checkout/checkout/processor/index.js index e36f15149fa..d29f04f57f7 100644 --- a/plugins/woocommerce-blocks/assets/js/base/context/cart-checkout/checkout/processor/index.js +++ b/plugins/woocommerce-blocks/assets/js/base/context/cart-checkout/checkout/processor/index.js @@ -222,17 +222,17 @@ const CheckoutProcessor = () => { } ); } ) .catch( ( errorResponse ) => { + // Update nonce. + triggerFetch.setNonce( errorResponse.headers ); + + // If new customer ID returned, update the store. + if ( errorResponse.headers?.get( 'X-WC-Store-API-User' ) ) { + dispatchActions.setCustomerId( + errorResponse.headers.get( 'X-WC-Store-API-User' ) + ); + } + errorResponse.json().then( function ( response ) { - // Update nonce. - triggerFetch.setNonce( errorResponse.headers ); - - // If new customer ID returned, update the store. - if ( errorResponse.headers?.get( 'X-WC-Store-API-User' ) ) { - dispatchActions.setCustomerId( - errorResponse.headers.get( 'X-WC-Store-API-User' ) - ); - } - // If updated cart state was returned, update the store. if ( response.data?.cart ) { receiveCart( response.data.cart ); diff --git a/plugins/woocommerce-blocks/docs/testing/releases/390.md b/plugins/woocommerce-blocks/docs/testing/releases/390.md index e546e7cff57..29fed7ea9ef 100644 --- a/plugins/woocommerce-blocks/docs/testing/releases/390.md +++ b/plugins/woocommerce-blocks/docs/testing/releases/390.md @@ -1,4 +1,4 @@ -## Testing notes and ZIP for release 3.8.0 +## Testing notes and ZIP for release 3.9.0 Zip file for testing: [woocommerce-gutenberg-products-block.zip](https://github.com/woocommerce/woocommerce-gutenberg-products-block/files/5597018/woocommerce-gutenberg-products-block.zip) diff --git a/plugins/woocommerce-blocks/docs/testing/releases/400.md b/plugins/woocommerce-blocks/docs/testing/releases/400.md new file mode 100644 index 00000000000..ec9cb60dcb3 --- /dev/null +++ b/plugins/woocommerce-blocks/docs/testing/releases/400.md @@ -0,0 +1,106 @@ +## Testing notes and ZIP for release 4.0.0 + +Zip file for testing: [woocommerce-gutenberg-products-block.zip](https://github.com/woocommerce/woocommerce-gutenberg-products-block/files/5654619/woocommerce-gutenberg-products-block.zip) + +## Feature plugin and package inclusion in WooCommerce core + +### Input appearance in IE 11 (Create IE11 SCSS mixin) + +Setup: + +* Create a Products Block, Filter by Price Block, and Checkout Block. + +Testing: + +- [ ] With IE11, check that there are no visual regressions in the Filter products by price block. +- [ ] With IE11, check that there are no visual regressions in the checkboxes of the Checkout block. + +See screenshots in https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3473. + +## Feature plugin only + +### Fix notice close button color in Twenty Twenty One dark mode + +Setup: + +* Install and activate Twenty Twenty One. +* Go to Customize > Colors & Dark mode and check the Dark mode support checkbox. +* In the frontend, make sure the dark mode is enabled and go to a page with the Checkout block. + +Testing: + +* [ ] Try submitting the form leaving one of the required inputs empty so the error notice appears. +* [ ] Verify the close button is visible. + +### Ensure correct alignment of checkout notice's dismiss button + +Setup: + +* Enable Storefront theme +* Add an item to the cart and go to the checkout block + +Testing: + +* [ ] Leave a required field on the checkout form blank and attempt checkout +* [ ] Ensure the error notice's dismiss button is aligned to the right + +See screenshot in https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3455. + +### Fix notices in console on Checkout (Update @wordpress/components to v. 11.1.1 and @wordpress/base-styles to v. 3.2.0) + +Setup: + +* Add the checkout block to a page. +* Add an item to your cart, and go to checkout. + +Testing: + +* [ ] Change the value of the Country/Region select. +* [ ] Verify no errors appear in the browser console. + +### Checkout block: Fixes around account creation and coupon validation + +Setup: + +* Create a coupon with a usage requirement of a specific email address. +* Enable registration during checkout. +* Add the checkout block to a page. +* Add an item to your cart, apply the coupon, and go to checkout. + +Testing: + +* [ ] Fill out the checkout form, and indicate that you would like to create an account. Use an email address different to the coupon restriction. Submit the form. +* [ ] Confirm a coupon error appears, and the create account signup box is hidden. +* [ ] Submit the form again. Order should go through without error. + +### Remove held stock for a draft order if an item is removed from the cart + +Setup: + +* Setup a stock managed item with 1 in stock +* Add that 1 item to the cart +* Go to checkout +* Go back to the cart and remove the item from your cart + +Testing: + +* [ ] From another device or in another browser, add the same item to the cart. No stock errors should be shown. + +### Make sure cart is initialized before the CartItems route is used in the Store API + +Setup: + +You need to use the StoreAPI. Add an item to your cart via the API (replacing the product ID with one from your store). + +POST `https://yourstore.test/wp-json/wc/store/cart/add-item` + +``` +{ + "id": 163, + "quantity":1 +} +``` + +Testing: + +* [ ] GET the following endpoint: `https://yourstore.test/wp-json/wc/store/cart/items`. There should be a valid response with response code 200. diff --git a/plugins/woocommerce-blocks/docs/testing/releases/README.md b/plugins/woocommerce-blocks/docs/testing/releases/README.md index ebc51c8f544..fb30b146cd6 100644 --- a/plugins/woocommerce-blocks/docs/testing/releases/README.md +++ b/plugins/woocommerce-blocks/docs/testing/releases/README.md @@ -17,3 +17,4 @@ Every release includes specific testing instructions for new features and bug fi - [3.7.1](./371.md) - [3.8.0](./380.md) - [3.9.0](./390.md) +- [4.0.0](./400.md) diff --git a/plugins/woocommerce-blocks/package.json b/plugins/woocommerce-blocks/package.json index 78190179307..e19eacf1165 100644 --- a/plugins/woocommerce-blocks/package.json +++ b/plugins/woocommerce-blocks/package.json @@ -2,7 +2,7 @@ "name": "@woocommerce/block-library", "title": "WooCommerce Blocks", "author": "Automattic", - "version": "4.0.0-dev", + "version": "4.0.0", "description": "WooCommerce blocks for the Gutenberg editor.", "homepage": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/", "keywords": [ diff --git a/plugins/woocommerce-blocks/readme.txt b/plugins/woocommerce-blocks/readme.txt index af86306ec18..2c9b803b91c 100644 --- a/plugins/woocommerce-blocks/readme.txt +++ b/plugins/woocommerce-blocks/readme.txt @@ -4,7 +4,7 @@ Tags: gutenberg, woocommerce, woo commerce, products, blocks, woocommerce blocks Requires at least: 5.3 Tested up to: 5.6 Requires PHP: 7.0 -Stable tag: 4.0.0-dev +Stable tag: 4.0.0 License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.html @@ -45,9 +45,9 @@ Use this plugin if you want access to the bleeding edge of available blocks for = Minimum Requirements = * WordPress 5.3 or greater -* WooCommerce 4.2 or greater -* PHP version 5.6 or greater (PHP 7.2 or greater is recommended) -* MySQL version 5.0 or greater (MySQL 5.6 or greater is recommended) +* WooCommerce 4.3 or greater +* PHP version 7.0 or greater (PHP 7.4 or greater is recommended) +* MySQL version 5.6 or greater Visit the [WooCommerce server requirements documentation](https://docs.woocommerce.com/document/server-requirements/) for a detailed list of server requirements. @@ -85,6 +85,25 @@ Release and roadmap notes available on the [WooCommerce Developers Blog](https:/ == Changelog == += 4.0.0 - 2020-12-07 = + +#### Enhancements + +- Dev: Change register_endpoint_data to use an array of params instead of individual params. ([3478](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3478)) +- Dev: Expose store/cart via ExtendRestApi to extensions. ([3445](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3445)) +- Dev: Added formatting classes to the Store API for extensions to consume. + +#### Bug Fixes + +- Checkout block: Prevent `Create an account` from creating up a user account if the order fails coupon validation. ([3423](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3423)) +- Make sure cart is initialized before the CartItems route is used in the Store API. ([3488](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3488)) +- Fix notice close button color in Twenty Twenty One dark mode. ([3472](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3472)) +- Remove held stock for a draft order if an item is removed from the cart. ([3468](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3468)) +- Ensure correct alignment of checkout notice's dismiss button. ([3455](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3455)) +- Fixed a bug in Checkout block (Store API) causing checkout to fail when using an invalid coupon and creating an account. +- Checkout block: Correctly handle cases where the order fails with an error (e.g. invalid coupon) and a new user account is created. ([3429](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3429)) +- Dev: Refactored and reordered Store API checkout processing to handle various edge cases and better support future extensibility. ([3454](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3454)) + = 3.9.0 - 2020-11-25 = See release post [here](https://developer.woocommerce.com/?p=8234) diff --git a/plugins/woocommerce-blocks/src/Package.php b/plugins/woocommerce-blocks/src/Package.php index f207ace46f6..64bc5d8592d 100644 --- a/plugins/woocommerce-blocks/src/Package.php +++ b/plugins/woocommerce-blocks/src/Package.php @@ -106,7 +106,7 @@ class Package { NewPackage::class, function ( $container ) { // leave for automated version bumping. - $version = '4.0.0-dev'; + $version = '4.0.0'; return new NewPackage( $version, dirname( __DIR__ ), diff --git a/plugins/woocommerce-blocks/src/RestApi.php b/plugins/woocommerce-blocks/src/RestApi.php index 06cc6420785..69fba836385 100644 --- a/plugins/woocommerce-blocks/src/RestApi.php +++ b/plugins/woocommerce-blocks/src/RestApi.php @@ -36,6 +36,7 @@ class RestApi { protected function init() { add_action( 'rest_api_init', array( $this, 'register_rest_routes' ), 10 ); add_filter( 'rest_authentication_errors', array( $this, 'store_api_authentication' ) ); + add_action( 'set_logged_in_cookie', array( $this, 'store_api_logged_in_cookie' ) ); } /** @@ -81,6 +82,19 @@ class RestApi { return true; } + /** + * When the login cookies are set, they are not available until the next page reload. For the Store API, specifically + * for returning updated nonces, we need this to be available immediately. + * + * @param string $logged_in_cookie The value for the logged in cookie. + */ + public function store_api_logged_in_cookie( $logged_in_cookie ) { + if ( ! defined( 'LOGGED_IN_COOKIE' ) || ! self::is_request_to_store_api() ) { + return; + } + $_COOKIE[ LOGGED_IN_COOKIE ] = $logged_in_cookie; + } + /** * Check if is request to the Store API. * diff --git a/plugins/woocommerce-blocks/woocommerce-gutenberg-products-block.php b/plugins/woocommerce-blocks/woocommerce-gutenberg-products-block.php index dcf613b2f09..deb656dc4d7 100644 --- a/plugins/woocommerce-blocks/woocommerce-gutenberg-products-block.php +++ b/plugins/woocommerce-blocks/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: 4.0.0-dev + * Version: 4.0.0 * Author: Automattic * Author URI: https://woocommerce.com * Text Domain: woo-gutenberg-products-block