woocommerce/plugins/woocommerce-blocks
Thomas Roberts a30179f165 Improve error displayed to customers when an item's stock status changes during checkout. (https://github.com/woocommerce/woocommerce-blocks/pull/3656)
* Add new exceptions for out of stock scenarios

These are needed to differentiate between the different stock validation errors, and so we can create the correct error message.

* Catch new out of stock exceptions when checking the cart for errors

This is so we can get the cart sent back to the client, if we don't catch these, then the route will just return a 500 error and crash.

* Add ArrayUtils class

This will contain methods used to operate on arrays that don't fit anywhere else.

* Handle the case in Checkout where the error is already a WP_Error

This will happen when the cart fails validation.

* Handle StockAvailabilityException in AbstractRoute

This will happen when an item or number of items in the cart are out of stock/insufficient stock.

* Throw exceptions for each type of invalid stock in validate_cart_items

This will allow us to create an error message for each type of violation to display to the user.

* Display additional error notices returned by the API

* Fix wording when throwing exceptions relating to stock

* Handle TooManyInCartException in CartController

* Abstract the merging of cart, status, and additional data into new fn

This allows us to simplify the way errors are returned from the API. The reason we have to add all of the data at once is because of how WP_Error works with the additional data, if there is already existing data in a WP_Error object, it gets moved into additional_data. By adding all of the data in one place, we stop this from happening. Also since we're only adding status and/or cart explicitly, it makes sense to just do it in one place.

* Add get_route_error_response_from_object method

This is so we can differentiate between a string and WP_Error object.

* Remove unnecessary slashes from WP_Error instantiation

* Add option to enclose each item in quotes in natural_language_join

* Abstract adding error messages to error object into single function

A lot of code was repeated, so doing this cuts down on that and ensures any changes only need to be made in one place.

* Create new parent exception for each type of out of stock exception

This is so we don't have to repeat code inside each different exception and we can simply inherit StockAvailabilityException.

* Catch the generic StockAvailabilityException in get_cart_item_errors

* No longer recalculate totals in validate function

It is not needed, the totals are recalculated elsewhere. This call was superfluous.

* Reduce nesting, and only throw exception if error object has errors

* Improve comment on get_route_error_response_from_object method

* Fix nesting when throwing the InvalidStockLevelsInCartException
2021-01-18 17:35:02 +00:00
..
.github change eslint workflow to use different method and action (https://github.com/woocommerce/woocommerce-blocks/pull/3693) 2021-01-17 14:06:24 -05:00
.sources Update previews and editor styles for cart and checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/2160) 2020-04-08 16:03:39 +01:00
.wordpress-org Add WordPress.org assets folder and add latest assets. (https://github.com/woocommerce/woocommerce-blocks/pull/3377) 2020-11-09 08:07:15 -05:00
assets Improve error displayed to customers when an item's stock status changes during checkout. (https://github.com/woocommerce/woocommerce-blocks/pull/3656) 2021-01-18 17:35:02 +00:00
bin introduce SlotFill for Sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/3361) 2021-01-11 13:12:26 +01:00
docs Release: 4.2.0 (https://github.com/woocommerce/woocommerce-blocks/pull/3637) 2021-01-06 10:48:11 +01:00
packages/checkout Support for multiple fee rows in the cart (https://github.com/woocommerce/woocommerce-blocks/pull/3678) 2021-01-13 16:57:42 +00:00
src Improve error displayed to customers when an item's stock status changes during checkout. (https://github.com/woocommerce/woocommerce-blocks/pull/3656) 2021-01-18 17:35:02 +00:00
storybook Support for multiple fee rows in the cart (https://github.com/woocommerce/woocommerce-blocks/pull/3678) 2021-01-13 16:57:42 +00:00
templates/emails Support "create account" option in checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/2851) 2020-10-01 15:07:16 +13:00
tests Fix broken PHPunit tests (https://github.com/woocommerce/woocommerce-blocks/pull/3690) 2021-01-16 08:48:46 +01:00
.distignore Release: 3.0.0 (https://github.com/woocommerce/woocommerce-blocks/pull/2887) 2020-07-22 12:36:55 -04:00
.editorconfig Introduce legacy build system and new aliases (https://github.com/woocommerce/woocommerce-blocks/pull/1018) 2019-10-06 08:36:15 -04:00
.env Switch to use `wp-env` as the development/test environment (https://github.com/woocommerce/woocommerce-blocks/pull/2730) 2020-06-17 16:28:11 -04:00
.eslintignore Add @woocommerce/eslint-plugin dependency (https://github.com/woocommerce/woocommerce-blocks/pull/3115) 2020-09-07 13:31:10 -04:00
.eslintrc.js introduce SlotFill for Sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/3361) 2021-01-11 13:12:26 +01:00
.gitattributes update .gitattributes ans add comment blocks (https://github.com/woocommerce/woocommerce-blocks/pull/3143) 2020-09-14 12:18:00 -04:00
.gitignore change eslint workflow to use different method and action (https://github.com/woocommerce/woocommerce-blocks/pull/3693) 2021-01-17 14:06:24 -05:00
.nvmrc Adds continuous integration testing with travis (https://github.com/woocommerce/woocommerce-blocks/pull/156) 2018-11-27 12:12:48 -05:00
.prettierrc Fix increment bug in withComponentId (https://github.com/woocommerce/woocommerce-blocks/pull/951) 2019-09-07 08:04:34 -04:00
.stylelintrc.json Add stylelint to find and fix css code style issues (https://github.com/woocommerce/woocommerce-blocks/pull/126) 2018-11-15 10:45:49 -05:00
.wp-env.json Create GitHub actions for automated tests (https://github.com/woocommerce/woocommerce-blocks/pull/3544) 2021-01-05 09:27:22 +00:00
README.md Revert test badge name back to Automated Tests (https://github.com/woocommerce/woocommerce-blocks/pull/3640) 2021-01-05 12:38:44 +00:00
babel.config.js Fix wp-cli container permissions issues for e2e docker test environment (https://github.com/woocommerce/woocommerce-blocks/pull/1716) 2020-02-11 11:13:20 -05:00
composer.json update jetpack autoloader to 2.7.1 (https://github.com/woocommerce/woocommerce-blocks/pull/3683) 2021-01-14 14:11:55 +01:00
composer.lock update jetpack autoloader to 2.7.1 (https://github.com/woocommerce/woocommerce-blocks/pull/3683) 2021-01-14 14:11:55 +01:00
docker-compose.yml Expand travis matrix (https://github.com/woocommerce/woocommerce-blocks/pull/2686) 2020-06-16 13:18:34 +01:00
globals.d.ts Add initial cart flow tests (https://github.com/woocommerce/woocommerce-blocks/pull/2678) 2020-06-10 14:21:34 -04:00
package-lock.json Update dependency @testing-library/react to v11.2.3 (https://github.com/woocommerce/woocommerce-blocks/pull/3674) 2021-01-15 14:24:40 +01:00
package.json change eslint workflow to use different method and action (https://github.com/woocommerce/woocommerce-blocks/pull/3693) 2021-01-17 14:06:24 -05:00
phpcs.xml Fix incorrect usage of static method in Stripe payment method integration (https://github.com/woocommerce/woocommerce-blocks/pull/3400) 2020-11-14 11:04:48 -05:00
phpunit.xml.dist Move main controllers from assets/php to src (https://github.com/woocommerce/woocommerce-blocks/pull/655) 2019-07-01 13:52:44 +01:00
postcss.config.js Create Reviews by Product block (https://github.com/woocommerce/woocommerce-blocks/pull/658) 2019-08-15 16:55:57 +02:00
readme.txt Update versions to 4.3.0-dev 2021-01-06 10:51:04 +01:00
renovate.json Add major for devDependencies. (https://github.com/woocommerce/woocommerce-blocks/pull/3653) 2021-01-07 12:41:55 +00:00
tsconfig.json Create @woocommerce/checkout to export components to a global (https://github.com/woocommerce/woocommerce-blocks/pull/3654) 2021-01-07 13:02:21 +01:00
webpack.config.js Add Webpack config docs (https://github.com/woocommerce/woocommerce-blocks/pull/3043) 2020-08-25 12:01:19 +02:00
woocommerce-gutenberg-products-block.php Update versions to 4.3.0-dev 2021-01-06 10:51:04 +01:00

README.md

WooCommerce Blocks

Latest Tag View JavaScript and CSS Linting PHP Coding Standards Automated tests

This is the feature plugin for WooCommerce + Gutenberg. This plugin serves as a space to iterate and explore new Blocks and updates to existing blocks for WooCommerce, and how WooCommerce might work with the block editor.

Use this plugin if you want access to the bleeding edge of available blocks for WooCommerce. However, stable blocks are bundled into WooCommerce, and can be added from the "WooCommerce" section in the block inserter.

Table of Contents

Documentation

To find out more about the blocks and how to use them, check out the documentation on WooCommerce.com.

If you want to see what we're working on for future versions, or want to help out, read on.

Code Documentation

Installing the plugin version

We release a new version of WooCommerce Blocks onto WordPress.org every few weeks, which can be used as an easier way to preview the features.

Note: The plugin follows a policy of supporting the "L2" strategy for version support. What this means is that the plugin will support the most recent two minor versions of WordPress, and the most recent two minor versions of WooCommerce core at the time of a release.

That means if the latest version of WooCommerce is 4.3 at the time of a release, then our minimum version requirements for WooCommerce core would be 4.1+.

We recommend you always keep WordPress and WooCommerce core up to date in order to ensure your store is running with the most recent fixes and enhancements to help your store be successful.

  1. Make sure you have WordPress 5.4+ and WooCommerce 4.3+
  2. The plugin version is available on WordPress.org. Download the plugin version here.
  3. Activate the plugin.

Installing the development version

  1. Make sure you have WordPress 5.4+ and WooCommerce 4.3+
  2. Get a copy of this plugin using the green "Clone or download" button on the right.
  3. npm install to install the dependencies.
  4. composer install to install core dependencies.
  5. npm run build (build once) or npm start (keep watching for changes) to compile the code.
  6. Activate the plugin.

The source code is in the assets/ folder and the compiled code is built into build/.

Getting started with block development

Run through the "Writing Your First Block Type" tutorial for a quick course in block-building.

For deeper dive, try looking at the core blocks code, or see what components are available.

To begin contributing to the WooCommerce Blocks plugin, see our getting started guide and developer handbook.

Other useful docs to explore:

Long-term vision

WooCommerce Blocks are the easiest, most flexible way to build your store user interface and showcase your products.