Commit Graph

1685 Commits

Author SHA1 Message Date
renovate[bot] f6ca3f30e4 Lock file maintenance (https://github.com/woocommerce/woocommerce-blocks/pull/2454)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-05-11 13:11:56 +01:00
Darren Ethier e7781ba407 Fixes regression with payment method validation (https://github.com/woocommerce/woocommerce-blocks/pull/2450)
* add typedefs for store notice context

* improve useStoreNotices hook so returned interfaces are fairly constant

* fix dependencies, defaults, and add types

* fix dependencies

* fix dependencies

* improve functions exposed on validation context so they are more constant

* fixing dependencies

* normalize tokenId to string everywhere

Assuming the token is a number is a bad idea because it is feasible that source for some payment methods could be a string. Also when retrieved as an input value, the id will be a string anyways.
2020-05-10 19:41:10 -04:00
Darren Ethier ea3d817db1 Fix multiple extra stripe createSource requests than necessary (https://github.com/woocommerce/woocommerce-blocks/pull/2444)
* refactor to move payment processing into it’s own effect

- this is the first step in trying to improve the createSource behaviour.

* memoize setValidationErrors so onPaymentProcessing event effect doesn’t re-run unnecessarily.

* Update assets/js/payment-method-extensions/payment-methods/stripe/credit-card/use-payment-processing.js

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* fix docs alignment

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2020-05-08 11:32:20 -04:00
Mike Jolley 657e5005ff Fix X-WC-Store-API-Nonce updates (https://github.com/woocommerce/woocommerce-blocks/pull/2429)
* Move store api nonce js to separate middleware entry

* Make middleware a depedency of block-data

* Build
2020-05-08 10:39:03 -04:00
Brent Shepherd 976556748b Fix PayPay file name (https://github.com/woocommerce/woocommerce-blocks/pull/2443) 2020-05-08 12:42:58 +01:00
Albert Juhé Lluveras 76878eff0d Fix wrong frontend error button class names (https://github.com/woocommerce/woocommerce-blocks/pull/2431) 2020-05-08 09:02:18 +02:00
Darren Ethier 467097de0c add eslint configuration for react hooks (https://github.com/woocommerce/woocommerce-blocks/pull/2436) 2020-05-07 17:21:05 -04:00
Mike Jolley 3c55918e62 Add an inline skeleton sizing script (https://github.com/woocommerce/woocommerce-blocks/pull/2420)
* Add an inline skeleton sizing script

* const/let
2020-05-07 10:53:07 +01:00
Albert Juhé Lluveras e970e4e86f SCSS mixins cleanup (https://github.com/woocommerce/woocommerce-blocks/pull/2405)
* Cleanup some old mixins

* Make font-size() mixin use parameters with units

* Remove hover-state mixin

* Cleanup mixins file
2020-05-07 10:48:38 +02:00
Mike Jolley 4436bdd23f Allow text inputs to focus on mount (https://github.com/woocommerce/woocommerce-blocks/pull/2416) 2020-05-06 15:04:00 -04:00
Mike Jolley dd811b1491 Update Stripe/payment payment notices (https://github.com/woocommerce/woocommerce-blocks/pull/2417)
* Update notices to say `card` instead of `card's`

* Track isEmpty per field so placeholders are not visible when focusing and defocusing other fields

* Make payment notices non-dissmissable, and removed on payment method switch

* Don't add validation notices

* implement nullish coalescing operator

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-05-06 14:58:31 -04:00
Mike Jolley 74a4e55075 Remove API summaries in favour of client side code (https://github.com/woocommerce/woocommerce-blocks/pull/2387)
* Remove summary from API

* Add wordCountType to assets

* Update packages

* Remove summary from test data

* Featured product uses short desc

* Pass description instead of summary

* Use new Summary Component

* Component and tests

* Increased versititilty of methods

* Update assets/js/base/components/cart-checkout/product-summary/index.js

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* Extra tests for html tags

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-05-06 11:30:15 +01:00
Mike Jolley 87e8b26e6f Store billing address to local state and persist globally to prevent loss of data (https://github.com/woocommerce/woocommerce-blocks/pull/2374)
* Remove unused shippingAsBilling prop from billing data context

* Move functions out of component and add docblocks

* Local address state

* Refactor into new custom hook

* Remove TODO and code fixed in core

* useShallowEqual to prevent updates on all field changes

* Fix stale validation errors

* cleanup

* Should be setting local state not global state for email and phone

* Combine useEffects and pass correct deps

* Update assets/js/base/hooks/checkout/use-checkout-address.js

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>

* Prettier

* Move validation update check into updateValidationError

* Fix state updaters

* Fix context definition for setShippingAddress

* Fix validation updates

* errorId dep

* Reapply changes to checkout block

* Update equality checks

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2020-05-06 11:21:30 +01:00
renovate[bot] 058d22a980 Update dependency eslint-plugin-jest to v23.9.0 (https://github.com/woocommerce/woocommerce-blocks/pull/2410)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-05-06 10:59:34 +01:00
renovate[bot] 371544a255 Update babel monorepo to v7.9.6 (https://github.com/woocommerce/woocommerce-blocks/pull/2409)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-05-06 10:59:23 +01:00
renovate[bot] 539236ff6e Update dependency jest to v25.5.4 (https://github.com/woocommerce/woocommerce-blocks/pull/2412)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-05-06 10:58:56 +01:00
renovate[bot] bad073d34e Update dependency node-sass to v4.14.1 (https://github.com/woocommerce/woocommerce-blocks/pull/2413)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-05-06 10:20:07 +01:00
Rua Haszard 44346274d2 clarify various checkout block editor sidebar wording (https://github.com/woocommerce/woocommerce-blocks/pull/2401)
* tweak various checkout block editor sidebar wording

* fix accidental sentence-casing of Return to cart label
2020-05-06 09:25:41 +12:00
Rua Haszard 440ee2e3b1 move checkout submit & related elements into "main" element (https://github.com/woocommerce/woocommerce-blocks/pull/2400) 2020-05-05 14:19:47 +01:00
Albert Juhé Lluveras 30c281c524 Use container queries to load Cart and Checkout responsive styles (https://github.com/woocommerce/woocommerce-blocks/pull/2370)
* Use container queries to load Cart and Checkout responsive styles

* Update package-lock.json

* Make form-step react to container queries instead of media queries

* Make sidebar layout inner padding relative to the full-width

* Make container queries breakpoints smaller
2020-05-05 10:10:02 +02:00
Rua Haszard b7d4b48b57 remove radius from Checkout submit, consistent with theme buttons (https://github.com/woocommerce/woocommerce-blocks/pull/2390) 2020-05-05 08:13:13 +12:00
Rua Haszard 9d0217419c decode html entities in ProductName component (https://github.com/woocommerce/woocommerce-blocks/pull/2389) 2020-05-04 15:44:23 -04:00
Rua Haszard da8fa3b870 Don't show checkout block for logged out users unless store is configured to allow guest checkout (https://github.com/woocommerce/woocommerce-blocks/pull/2375)
* expose guest checkout related options to blocks

* don't show checkout if user is not logged in and guest checkout is disabled

* checkout block doesn't yet support signup:
- if logged out / guest, don't show checkout
- even if store allows sign up at checkout

* only show login prompt if user is not logged in

* link to login page (as needed) if checkout requires login

* rejig hide login link when necessary:
- use customerId from checkout context
- revert currentUserLoggedIn setting - not needed

* add redirect param to checkout login links (so checkout can continue)
2020-05-04 15:40:09 -04:00
Albert Juhé Lluveras b5497147d5 Fix long product names regression (https://github.com/woocommerce/woocommerce-blocks/pull/2391) 2020-05-04 17:15:32 +02:00
Darren Ethier 88e397154d Add Todo Probot config (https://github.com/woocommerce/woocommerce-blocks/pull/2384)
* Add todo bot config

* tweak todo comment to test
2020-05-02 15:56:33 -04:00
Darren Ethier 76d0b9bb2e Update release notes to reflect changes in release process. 2020-05-01 17:29:20 -04:00
Darren Ethier 1e917f5a54 Ensure stripe payment request "canMakePayment" configuration uses site country. (https://github.com/woocommerce/woocommerce-blocks/pull/2372)
* export baseLocation for `@woocommerce/settings`

* implement country code from site base location instead of cart shipping country
2020-05-01 07:24:28 -04:00
Mike Jolley a640a230ca Assets/Block settings: Only lookup page if ID > 0 (https://github.com/woocommerce/woocommerce-blocks/pull/2369)
* Only lookup page if ID > 0

* Check for valid post

* Maybe fix test path
2020-05-01 11:02:20 +01:00
Mike Jolley bf8cff6f50 Rename the discount section when discount total is zero (https://github.com/woocommerce/woocommerce-blocks/pull/2367)
* Rename the discount section when discount total is zero

* Cleanup variable naming
2020-05-01 10:59:27 +01:00
Mike Jolley a3ca37bade Change when innerblocks are rendered (https://github.com/woocommerce/woocommerce-blocks/pull/2366) 2020-05-01 10:33:55 +01:00
Mike Jolley 5a39df880f Fix summary styles and margins/padding woocommerce/woocommerce-blocks#2340 (https://github.com/woocommerce/woocommerce-blocks/pull/2368) 2020-05-01 10:31:09 +01:00
Rua Haszard be968c9103 only show checkout login prompt if store allows it (https://github.com/woocommerce/woocommerce-blocks/pull/2364) 2020-04-30 13:54:43 +01:00
Albert Juhé Lluveras 9e7623567e Make all font sizes accessible + add docs about font-size() mixin (https://github.com/woocommerce/woocommerce-blocks/pull/2291)
* Switch all font-sizes to use the mixin

* Add notice in coding-guidelines to use accessible font sizes

* Fix label alignment in forms with big font-sizes

* Fix Stripe input boxes font-size not being responsive

* Fix select overflowing in small font sizes

* Add rem function from woocommerce/woocommerce-blocks#2320

* Make the font-size() mixin set relative line-height values

* Convert several magic numbers to use the new mixins

* Update docs

* Update input/select paddings to use the rem mixin

* Add lineHeight comment

* Interpolate rem() mixin inside calc

* Make input padding use only relative units
2020-04-30 12:18:12 +02:00
Mike Jolley 3122447ae4 Update payment-method-integration.md 2020-04-30 10:55:57 +01:00
Mike Jolley 4c16280977 Add placeOrderButtonLabel docs 2020-04-30 10:55:26 +01:00
Mike Jolley 1fd0fa79a9 Payment methods `placeOrderButtonLabel` config (https://github.com/woocommerce/woocommerce-blocks/pull/2362)
* Add payment method configs

* Remove submitLabel

* Enhance useCheckoutSubmit to handle button text

* copy paste error
2020-04-30 10:52:36 +01:00
Mike Jolley 6df5903e0f Checkout Block Order Summary Styles (https://github.com/woocommerce/woocommerce-blocks/pull/2355)
* Update checkout styles

* remove item prices from summary
2020-04-30 10:51:08 +01:00
Albert Juhé Lluveras 2593c711ad Fix payment method error notices issues (https://github.com/woocommerce/woocommerce-blocks/pull/2352)
* Prevent payment method errors appearing twice. Fixes woocommerce/woocommerce-blocks#2327

* Remove payment method errors on submit. Fixes woocommerce/woocommerce-blocks#2217

* Simplify useEffect dependencies

* Pass context name to removeNotice
2020-04-30 11:43:56 +02:00
Darren Ethier 06d84997e5 Update testing instructions cart stock error. 2020-04-29 16:01:52 -04:00
Albert Juhé Lluveras fce0e2d71c Fix Cart block interaction in the editor (mobile) (https://github.com/woocommerce/woocommerce-blocks/pull/2354)
* Prevent SnackbarList from loading in the editor

* Fix snackbar styles leaking into the editor

* Prevent 'Proceed to Checkout' button being fixed to the bottom in the editor
2020-04-29 17:45:29 +02:00
Mike Jolley 8424934149 Update API status codes (https://github.com/woocommerce/woocommerce-blocks/pull/2353)
* Update HTTP status codes

* Catch JSON parsing errors.
2020-04-29 15:47:05 +01:00
Rua Haszard 7abe9dffb3 align cart main heading and totals sidebar heading: (https://github.com/woocommerce/woocommerce-blocks/pull/2346)
- set appropriate padding for main cart container
- card padding is currently provided by Gutenberg component (?)
- overriding padding on totals card to match main container
2020-04-29 13:35:42 +01:00
Mike Jolley 95809b30bb Update payment method config to include icons (https://github.com/woocommerce/woocommerce-blocks/pull/2267)
* Remove strong and cleanup existing configs

* Fix TS validation for blocks-registry

* Allow label to be string

* Split up button and icons for cart

* Make icons and payment methods available on cart page

* Fix payment method enqueuing

* Icon normalization and Stripe implementation

* PayPal Icon

* adjust spacing

* Fix string handling

* Remove paypal icon config

* Check for an object before creating icon

* Add payment icons to Stripe label

* Update common-icons.js

* Update Cart.php

* Update jest.config.json
2020-04-29 11:57:58 +01:00
Albert Juhé Lluveras 60cf16a334 Fix low stock badge not breaking in a new line (https://github.com/woocommerce/woocommerce-blocks/pull/2348) 2020-04-29 12:57:04 +02:00
Darren Ethier 58abb408c2 make sure we import from external not direct files (https://github.com/woocommerce/woocommerce-blocks/pull/2330) 2020-04-29 11:20:52 +01:00
Mike Jolley 8c88870d2d Merge branch 'add/pin-woocommerce' 2020-04-29 11:07:02 +01:00
renovate[bot] cb467c8696 Update dependency @types/wordpress__data to v4.6.7 (https://github.com/woocommerce/woocommerce-blocks/pull/2333)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-29 10:53:21 +01:00
Mike Jolley afe5f4d706 Update shipping should extend the correct route (https://github.com/woocommerce/woocommerce-blocks/pull/2328) 2020-04-29 10:44:07 +01:00
renovate[bot] 4785151037 Update Node.js to v12.16.3 (https://github.com/woocommerce/woocommerce-blocks/pull/2331)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-29 10:25:12 +01:00
renovate[bot] 0a6c23ba8e Update dependency @stripe/stripe-js to v1.5.0 (https://github.com/woocommerce/woocommerce-blocks/pull/2332)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-29 10:24:52 +01:00
renovate[bot] 9c41e1bfcc Update dependency @types/wordpress__element to v2.4.1 (https://github.com/woocommerce/woocommerce-blocks/pull/2334)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-29 10:23:55 +01:00
renovate[bot] 808e40a089 Update dependency css-loader to v3.5.3 (https://github.com/woocommerce/woocommerce-blocks/pull/2336)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-29 10:23:29 +01:00
renovate[bot] a9b14b2b4e Update dependency jest to v25.5.0 (https://github.com/woocommerce/woocommerce-blocks/pull/2337)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-29 10:23:13 +01:00
Rua Haszard 1b596b94dc Quantity badge white separator + center tweak (https://github.com/woocommerce/woocommerce-blocks/pull/2347)
* add extra white border to quantity badge

* nudge checkout quantity badge so it's roughly centered with image corner
2020-04-29 10:22:12 +01:00
Mike Jolley a58420a60e Table creation validation for install routine (https://github.com/woocommerce/woocommerce-blocks/pull/2287)
* Bump package version for testing

* New install routine and db version

* Revert "Bump package version for testing"

This reverts commit c3fee55a34e75429b731cd7a2cc07e841010df6d.

* Update bootstrap to ensure blocks is installed properly before tests are ran

* Restore errors after install

* Use enabled method instead of comparing db version

* Moved installer code to admin_init

* Tweak test bootstrap
2020-04-28 16:36:37 +01:00
Mike Jolley ad93ddd891 Add PayPal Standard (https://github.com/woocommerce/woocommerce-blocks/pull/2288)
* Add paypal files

* Add PayPal Icon/resolve feedback
2020-04-28 11:13:48 +01:00
Seghir Nadir 476ae5dcd5 remove order note (https://github.com/woocommerce/woocommerce-blocks/pull/2318) 2020-04-28 11:07:05 +01:00
renovate[bot] 0a9ce1206b Lock file maintenance (https://github.com/woocommerce/woocommerce-blocks/pull/2290)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-27 17:26:29 +01:00
Seghir Nadir 797ded1efc Add notice errors to add to cart button and All products (https://github.com/woocommerce/woocommerce-blocks/pull/2278)
* expose errors when adding to cart

* clear notices

* make notice dismissible

* decode entities
2020-04-27 17:24:54 +01:00
Mike Jolley e85b6fe9a9 Inject block attributes rather than save them (https://github.com/woocommerce/woocommerce-blocks/pull/2273)
* Inject attributes rather than saving them

* Update snaps
2020-04-27 12:06:58 -04:00
Mike Jolley 30ecea188f Avoid loading Assets API during REST requests (https://github.com/woocommerce/woocommerce-blocks/pull/2286)
* Move is built to method

* Moved payment related logic into single controller class for better organization

* Only load assets on non-rest requests
2020-04-27 16:51:50 +01:00
Seghir Nadir d70174aa57 Pin WooCommerce version 2020-04-26 14:30:31 +01:00
Mike Jolley e5589727fc Support itemized taxes (https://github.com/woocommerce/woocommerce-blocks/pull/2276) 2020-04-24 14:44:44 +01:00
Mike Jolley 8bf58b4596 Trigger fragment refresh after editing cart item quantities (https://github.com/woocommerce/woocommerce-blocks/pull/2266)
* Make util to fire legacy events

* Update button to use util

* Trigger event when quantity changes

* Trigger event on removal

* Move comments to util
2020-04-24 14:41:32 +01:00
Mike Jolley 7f85c1bcc0 Migrate REST API usage to the Store API (https://github.com/woocommerce/woocommerce-blocks/pull/2282)
* Remove unused wc/blocks/cart endpoint

* remove unused withProducts hoc

* Remove getProducts util

* Use store API products endpoint in product blocks

* Remove product endpoint tests

* Remove controller

* Switch attributes endpoint to store api

* Refactor withAttributes to use store API

* Migrate tags and cats to store API

* MIgrate variations to store api

* Migrate reviews to store API

* Drop dedicated variation endpoint

* Move tests

* Move cart init

* Fix reviews

* Comment out broken tests

* Remove old class based with-attributes test
2020-04-24 14:36:47 +01:00
Albert Juhé Lluveras 72c7b38022 Add screen reader text to remove item icon (https://github.com/woocommerce/woocommerce-blocks/pull/2285) 2020-04-24 15:11:14 +02:00
Albert Juhé Lluveras 96e8ccf1a4 Cart & Checkout: Update styles to better match designs (https://github.com/woocommerce/woocommerce-blocks/pull/2283)
* Add ending dot to sentence

* Open links to products from Cart and Checkut blocks in new tabs

* Makes sure product names are broken if they overflow the container

* Use native find instead of lodash method

* Update styles to better match designs

* Revert "Open links to products from Cart and Checkut blocks in new tabs"

This reverts commit 9b64aa5f2e81bf0cf09d5640a3cfe1cc1085c046.

* Fix product name overflowing remove menu on mobile

* Remove @todo comments from form step CSS

* Make letter-spacinguse em instead of px

* IE11: Correctly align text in quantity selector

* Fix long product names overflowing in Checkout block on IE11
2020-04-24 13:23:25 +01:00
Seghir Nadir 7863a99de7 Abstract Page selector and fix some issues in sidebar. (https://github.com/woocommerce/woocommerce-blocks/pull/2270)
* abstract pageSelector to its own component and fix titles

* fix unwrapped context

* move control styles outside editor-wrapper

* restore condition to previous state

* move condition outisde

* rename condition

* keep pageSelect visible till next refresh

* remove comment
2020-04-22 17:44:12 +01:00
Mike Jolley 953712941b Update StoreApi namespaces/move files (https://github.com/woocommerce/woocommerce-blocks/pull/2277)
* `use` is never relative - absolute is always used so backslash is not needed

* Move process_legacy_payment code to rest api class

* Move storeapi directory

* Updated namespaces and moved tests
2020-04-22 15:39:19 +01:00
Mike Jolley 5a2ee88905 Fixes to totals recalculation and taxes (https://github.com/woocommerce/woocommerce-blocks/pull/2275)
* Hide tax totals row when taxes are disabled in core

* Trigger recalcs if hash changes

* move recalc until later on in rest call

* Unused class
2020-04-22 14:16:17 +01:00
Albert Juhé Lluveras 7fa4b76c52 Prevent All Products block from crashing when error has no json method (https://github.com/woocommerce/woocommerce-blocks/pull/2269) 2020-04-22 12:09:20 +02:00
renovate[bot] 5d25790d95 Update dependency jest to v25.4.0 (https://github.com/woocommerce/woocommerce-blocks/pull/2272)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-22 11:06:39 +01:00
renovate[bot] 3e9b6ad26c Update dependency eslint-config-prettier to v6.11.0 (https://github.com/woocommerce/woocommerce-blocks/pull/2271)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-22 11:06:13 +01:00
Mike Jolley db145deb70 Decode billing address from server (https://github.com/woocommerce/woocommerce-blocks/pull/2268) 2020-04-21 15:24:04 +01:00
Mike Jolley 880d4e19b4 Decode entities in cart shipping data (https://github.com/woocommerce/woocommerce-blocks/pull/2265) 2020-04-21 14:43:49 +01:00
Mike Jolley d0d0cfc565 Checkout: Rename address2 attribute (https://github.com/woocommerce/woocommerce-blocks/pull/2264)
* Rename address2 attribute

* Update snap
2020-04-21 11:51:11 +01:00
Darren Ethier 493a826e44 modify emitters so it handles non object or invalid object responses correctly. (https://github.com/woocommerce/woocommerce-blocks/pull/2249)
With these changes:

- If an observer returns an object wthout a type property an error is thrown and the emitter is aborted with an error type response.
- For anything else returned from an observer, it’s discarded.

Tests are updated for the new expectations
2020-04-21 04:33:16 +02:00
Seghir Nadir a005649ab8 Move blocks to stable flag (https://github.com/woocommerce/woocommerce-blocks/pull/2261)
* remove feature flag

* catch blocks.ini error
2020-04-20 15:55:59 +01:00
Seghir Nadir 106e187bd7 Merge branch 'master' of https://github.com/woocommerce/woocommerce-gutenberg-products-block 2020-04-20 15:13:49 +01:00
Seghir Nadir dc2d0dd6ae mark heading in docs 2020-04-20 15:13:38 +01:00
Mike Jolley a074260266 Revert "Improvements to REST API performance (https://github.com/woocommerce/woocommerce-blocks/pull/2248)" (https://github.com/woocommerce/woocommerce-blocks/pull/2259)
This reverts commit 30c0182fbe.
2020-04-20 14:59:17 +01:00
Seghir Nadir bb9f688ee4 fix some typos in testing checklist 2020-04-20 14:58:19 +01:00
Seghir Nadir 3a71233d4b Testing checklist (https://github.com/woocommerce/woocommerce-blocks/pull/2196)
* initial draft for testing

* fix typos and add table of content

* add how to report section

* finish the rest of the docs

* add free shipping section

* add create todo badge

* fix misplaced button

* add a general flow section

* change image link

* fix typos
2020-04-20 14:47:11 +01:00
Seghir Nadir 2e9b21ef8a Fix snackbar being too high and covering coupon section (https://github.com/woocommerce/woocommerce-blocks/pull/2255)
* fix snackbar issue

* fix some styles
2020-04-20 14:23:44 +01:00
Mike Jolley 248c552baf Add quantity limit at product level (https://github.com/woocommerce/woocommerce-blocks/pull/2256)
* Add quantity limit at product level

* Stock checks only needed when backorders are disabled

* Use remaining stock, not stock qty in messages etc

* Prevent duplicate validation from core
2020-04-20 14:10:39 +01:00
Mike Jolley de53038872 Check for instance of WP_Block (https://github.com/woocommerce/woocommerce-blocks/pull/2258) 2020-04-20 14:07:08 +01:00
Mike Jolley 30c0182fbe Improvements to REST API performance (https://github.com/woocommerce/woocommerce-blocks/pull/2248)
* Rejig methods and only load assets on non-api requests

* Avoid cart recalc on every request

* link to pr
2020-04-20 14:06:30 +01:00
renovate[bot] 6a8643f531 Update dependency @stripe/stripe-js to v1.4.0 (https://github.com/woocommerce/woocommerce-blocks/pull/2222)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-20 11:13:52 +01:00
Albert Juhé Lluveras 1b2e8dd435 Do not scroll to top when payment methods have an error (https://github.com/woocommerce/woocommerce-blocks/pull/2247)
* Do not scroll to top when payment methods emit an error

* Simplify code and add check for hasValidationErrors
2020-04-20 11:11:32 +01:00
renovate[bot] 75f6eb97fb Lock file maintenance (https://github.com/woocommerce/woocommerce-blocks/pull/2254)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-20 10:37:25 +01:00
Mike Jolley 4dbb7fcfbb Coupon was removed, but array was not updated (https://github.com/woocommerce/woocommerce-blocks/pull/2253) 2020-04-20 10:15:08 +01:00
Darren Ethier 580015827a remove obsolete @todo 2020-04-17 17:00:43 -04:00
Mike Jolley 5b142b58ed Coupon and Cart Item Validation Fixes (https://github.com/woocommerce/woocommerce-blocks/pull/2245)
* Move validation calls to checkout API class

* Validate before payment

* Support additional error data

* Add coupon validation before payment, and hide hashes from user

* Implement validation and recalculation

* Abstract notice handler and implement legacy filters

* Handle generic cart item errors

* strip tags from coupon error messages woocommerce/woocommerce-blocks#2212

* Ensure item errors are surfaced when coupons are removed

* Fix wrong value passed to hook

* fix broken checkout when no payment method is there

* try fixing unit test errors

* if preview data has a receiveCart function use it, otherwise default to an anononymous function

* fix tests

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-04-17 21:18:54 +01:00
Darren Ethier ae3a2dc7ad improve tocs in recently merged docs (https://github.com/woocommerce/woocommerce-blocks/pull/2246) 2020-04-17 11:42:51 -04:00
Darren Ethier 0a98037606 Add documentation for checkout flow and payment method integrations (https://github.com/woocommerce/woocommerce-blocks/pull/2246)
* add documentation for checkotu flow and payment method integrations

* Update docs/block-client-apis/README.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* Update docs/block-client-apis/README.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* standardize around capitalized API

* Remove extra dash.

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* remove 1st person narrative

* various other grammar fixes

* add table of contents to docs

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2020-04-17 11:37:09 -04:00
Rua Haszard f8489dc870 rename docker-related npm scripts so it's clear they are e2e infrastructure (https://github.com/woocommerce/woocommerce-blocks/pull/2237)
* rename docker-related npm scripts so it's clear they are e2e infrastructure

* fix travis e2e test job - update script name 😅
2020-04-17 10:44:29 +01:00
Mike Jolley 87fb1768a1 Documentation for the Store API (https://github.com/woocommerce/woocommerce-blocks/pull/2230)
* Products endpoint

* Updated STORE API docs

* Enable nonce protection for checkout endpoints and document

* feedback
2020-04-17 10:44:13 +01:00
Darren Ethier a8c2a015b4 use noticeContext properties for notice area (https://github.com/woocommerce/woocommerce-blocks/pull/2241) 2020-04-17 10:39:24 +01:00
renovate[bot] 59e4d12a7d Update dependency jest to v25.3.0 (https://github.com/woocommerce/woocommerce-blocks/pull/2226)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-17 10:27:28 +01:00
renovate[bot] 48ef1e5d93 Update dependency css-loader to v3.5.2 (https://github.com/woocommerce/woocommerce-blocks/pull/2225)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-17 10:27:13 +01:00
renovate[bot] 71a1fbc7ae Update dependency autoprefixer to v9.7.6 (https://github.com/woocommerce/woocommerce-blocks/pull/2224)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-17 10:26:29 +01:00
renovate[bot] 5de3b8544e Update dependency @types/react to v16.9.34 (https://github.com/woocommerce/woocommerce-blocks/pull/2223)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-17 10:26:13 +01:00
renovate[bot] cba08c3392 Update Node.js to v12.16.2 (https://github.com/woocommerce/woocommerce-blocks/pull/2221)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-17 10:25:37 +01:00
Mike Jolley 990949b302 Improve "sold individually" validation (https://github.com/woocommerce/woocommerce-blocks/pull/2234)
* API - Block qty > 1 for sold individually products

* Add item validation for sold individually to block checkout

* Fix validation check

* Add client side limit if sold individually

* Prevent never ending loading on failed add to cart

* Change cart button for sold individually errors
2020-04-17 10:24:44 +01:00
Seghir Nadir 2dfb8365de create a notice instead of throwing an errors (https://github.com/woocommerce/woocommerce-blocks/pull/2203) 2020-04-16 16:08:23 +01:00
Mike Jolley 216a7fc1bf Capture legacy payment notices (https://github.com/woocommerce/woocommerce-blocks/pull/2238)
* Convert woo notices into exceptions when processing legacy payments

* Prevent console errors when a message is not returned in the response

* include top level message property to capture REST error messages

* include capturing rest error messages on afterProcessing action

* clear notices before exception

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-04-16 15:39:46 +01:00
Mike Jolley 9260e7ad89 Add block asset documentation (https://github.com/woocommerce/woocommerce-blocks/pull/2209)
* Add block asset documentation

* feedback
2020-04-15 17:09:36 +01:00
Mike Jolley 21f75b61b0 Show feedback on buttons/checkout when processing (https://github.com/woocommerce/woocommerce-blocks/pull/2186)
* Allow buttons to show loading spinners

* Show spinner on cart checkout button press

* Disable fieldsets when processing

* Check icon when finished

* Style tweak to fix height

* Update events

* feedback

* Move button back
2020-04-15 17:09:15 +01:00
Darren Ethier 0501328902 Fix global validation error reporting and cheque payment method regressions (https://github.com/woocommerce/woocommerce-blocks/pull/2232)
* fix broken validation error handling after submit

* Add handling for when there are no observers for payment processing or all observers just return true.

* cheque no longer needs to hook into event emitter

* account for no data on complete status handling in reducer

* add handling for either no observers or all observers returning true for onAfterProcessingWithSuccess emitter
2020-04-15 11:43:03 -04:00
Albert Juhé Lluveras d5232c9903 Handle errors when loading payment methods (https://github.com/woocommerce/woocommerce-blocks/pull/2228)
* Handle errors when loading payment methods

* Use an error boundary

* Fix missing initial state in block error boundary

* Cleanup

* Only show internal user messages if it's admin or in editor

* Fixes

* Add friendly error message
2020-04-15 17:15:56 +02:00
Mike Jolley ceaae16d23 Fix entities in coupon validation error messages (https://github.com/woocommerce/woocommerce-blocks/pull/2179)
* decodeEntities in error messages

* Add unslash to coupon field

* Decode when receiving error
2020-04-15 09:59:01 +02:00
Rua Haszard ace2d2bd81 show preview "saved payment methods" in editor (https://github.com/woocommerce/woocommerce-blocks/pull/2151)
* factor out editor preview data for saved payment methods to previews

* add missing imports lost in rebase

* use editorcontext to provide preview data to payment method context

* remove unused `activePaymentMethod` prop in CheckoutProvider and PaymentMethodDataProvider

* don't set the preview saved card as the default

* fix js error with cart in editor - fix EditorContext, pass previewData:
- editor context preview prop has changed;
  - update cart to pass { previewCart } in previewData prop
- correctly destructure cart from previewData in useStoreCart hook
- correct typedefs
  - EditorProvider props.previewData - now just Object
  - similar for EditorDataContext
- correct default for activePaymentMethod state - empty string as before

* preselect 'use a new payment method' in checkout block editor preview

* update unit tests for changes to editor context
2020-04-15 12:05:01 +12:00
Darren Ethier 6069b9b90a Lazy load stripe.js and preserve payment method registration order. (https://github.com/woocommerce/woocommerce-blocks/pull/2214)
* remove stripe.js registration because it is lazy loaded via the library used.

* refactor payment method registration to preserve registration order.

* register payment method asset handles as dependency on editor script as well.
2020-04-14 18:44:31 -04:00
Darren Ethier 5850966894 Refactor checkout status and event emitters to support stripe intents and more complex payment methods. (https://github.com/woocommerce/woocommerce-blocks/pull/2189)
* initial mapping out of stripe payment intents

* rename checkout processing statuses to be clearer

* Add new status and refactor checkout complete behaviour.

* Make sure payment result data is included in checkout processing response

* add payment intent handling

Still testing

* make sure promise is returned

* include site url with endpoint

* modify setComplete status to optionally receive redirectUrl for changing in state at the same time as setting status

* fix typo in property retrieval

* add error handling for after checkout processing event

* add notices area for payment methods

* implement error handling for stripe intents

* hook into stripe error processing and include error in payment response

* clear notices so they don’t show in block and merge payment details

* add notice handling to payment context

* modify error processing in checkout processor

* handle errors with fallback in checkout state context

* hook into after processing for stripe cc error handling

* set checkout to idle status if before processing emitters result in error

* Add emit response type-defs and normalize expectations for observer responses

* improve doc block

* switch checkoutIsComplete check to checkoutAfterProcessing for payment complete status change

* remove unneeded event emitters and consolidate some logic

* fix idle status set logic
2020-04-14 12:52:23 -04:00
renovate[bot] 6b63f19fcb Lock file maintenance (https://github.com/woocommerce/woocommerce-blocks/pull/2198)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-14 15:19:48 +01:00
Mike Jolley 31b45a0989 Create block-assets.md
Syncing with hackmd
2020-04-14 13:12:59 +01:00
Albert Juhé Lluveras 923eef90ee Fix build styles incosistencies (https://github.com/woocommerce/woocommerce-blocks/pull/2208)
* Prevent select label/value breaking in two lines

* Make sure frontend and base styles are loaded in the same order

* Use link-button mixin for address button

* Refactor shipping rates control CSS to decrease specificity and overwrites

* Refactor sidebar panel CSS to decrease specificity and overwrites

* Fix link-button vertical-align
2020-04-14 13:43:10 +02:00
Seghir Nadir 32b80c40bb respect SHIPPING_ENABLED in Cart and Checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/2202) 2020-04-14 08:01:59 +02:00
Darren Ethier 70f8b48165 implement editor previews for stripe cc and check payment methods (https://github.com/woocommerce/woocommerce-blocks/pull/2190) 2020-04-14 08:01:29 +02:00
Seghir Nadir a00d06b7f2 Use icons directly from stripe (https://github.com/woocommerce/woocommerce-blocks/pull/2188)
* use icons from stripe

* rename classes

* use object instead of array

* update jsdocs
2020-04-09 15:31:03 -04:00
Mike Jolley c26fae204b Sync name and company to account (https://github.com/woocommerce/woocommerce-blocks/pull/2187) 2020-04-09 14:04:00 -04:00
Albert Juhé Lluveras c035a578a8 Fix currency format in On Sale badge (https://github.com/woocommerce/woocommerce-blocks/pull/2185)
* Fix currency format in On Sale badge

* Add back translators comment

* Use self-closing tag
2020-04-09 18:53:22 +02:00
Albert Juhé Lluveras 0663ac7f6f Prevent auto-scroll to invalid fields (https://github.com/woocommerce/woocommerce-blocks/pull/2184) 2020-04-09 18:42:53 +02:00
Darren Ethier e21883d69c Refactor logic for handling active payment method with express payment methods via checkout (https://github.com/woocommerce/woocommerce-blocks/pull/2170)
* remove logic server side for getting payment method from paymentdata

* ensure stripe accounts for payment request type payment methods

* make sure legacy payment method handling always runs last

* add processedPaymentMethodId to payment method data context state

* switch checkout processor to use new processedPaymentMethod id for submission

* implement returning paymentMethodId from payment-request-express

* include paymentMethodId in stripe cc success return value

* include paymentMethodId in cheque success return value

* add active payment method setting and handling via checkout

express payment methods still need to implement:

- onClick when their button is clicked
- onClose when the express payment interface is closed (cancelled etc).

* don’t expose setActivePaymentMethod on the payment method interface

* remove/fix artifacts from earlier iterations of the pull

* rename `id` property to `name` property for payment method registration

* Revert "include paymentMethodId in cheque success return value"

This reverts commit fe4ee8aced6d67bbd9033263ce61844349d18250.

* Revert "include paymentMethodId in stripe cc success return value"

This reverts commit 359a1f0089866110ec204182f8ffa14ab099c425.

* Revert "implement returning paymentMethodId from payment-request-express"

This reverts commit 117c68980b0876dee0acc78cec7754ccfe2a9bb1.

* Revert "switch checkout processor to use new processedPaymentMethod id for submission"

This reverts commit c38a05b63626dfc1336c7bb0e86417b798a803d6.

* Revert "add processedPaymentMethodId to payment method data context state"

This reverts commit 3d7923e7297f3c76efde536d26eaf68464ba9583.

* improve isSuccess response check and variable name

* implement paymentMethodId config option

* doh php ain’t javascript

* add missing dependency from rebase
2020-04-09 11:22:34 -04:00
Seghir Nadir 9e1adb7ea8 fix broken labels on twentyTwenty (https://github.com/woocommerce/woocommerce-blocks/pull/2181) 2020-04-09 15:26:16 +01:00
Albert Juhé Lluveras 93764f9f89 Check if cart needs payment before showing payment methods (https://github.com/woocommerce/woocommerce-blocks/pull/2177)
* Check if cart needs payment before showing payment methods

* Fix tests
2020-04-09 16:01:11 +02:00
Mike Jolley c02a7cb115 Update cart after conflicts (https://github.com/woocommerce/woocommerce-blocks/pull/2175)
* Return updated cart if there is a conflict (409 response) e.g. item no longer exists

* Receive updated carts

* Update tests and coupon handling

* Further rewording
2020-04-09 13:52:31 +01:00
Albert Juhé Lluveras fed597e5c8 Fix prices overflowing in some widths in the Order summary panel (https://github.com/woocommerce/woocommerce-blocks/pull/2178) 2020-04-09 13:50:00 +01:00
Mike Jolley 5e595d8794 Prevent data hydration on rest requests (https://github.com/woocommerce/woocommerce-blocks/pull/2176) 2020-04-09 13:51:27 +02:00
Darren Ethier 12b384374b Use cart data to provide country and currency_code for payment method registration config (https://github.com/woocommerce/woocommerce-blocks/pull/2169)
* use cart data to provide country and currency_code

* remove files that likely got added back in from a bad rebase.

* modify canMakePayment config property so it must be a function

* Feed cart data to registered payment methods `canMakePayment` function.

This can then be used by payment methods for determining whether to show the payment method or not.

* implement new canMakePayment signature for cheque

Now canMakePayment doesn’t need to be a promise (payment method registry will handle wrapping all values in a promise to treat them as promises.

* implement canMakePayment as a function
2020-04-09 07:44:29 -04:00
Darren Ethier d79f5ab271 Convert apple pay integration to payment request integration and finish implementation (https://github.com/woocommerce/woocommerce-blocks/pull/2127)
* add logic allowing payment method to be overridden via payment data in request

* hook in to trigger server side processing of stripe payment request

* improvements to shipping data context

- memoize event emitters
- split up emitted events (reduces how often events trigger)
- Include whether rate is being selected in exported data.

* expose `isSelectingRate` value to payment method interface

* fix typo in shipping emitters for emitter type

* include setting of shipping data in payment method success status call

- this also requires changing the nested order of providers in checkout provider

* fix priority logic for event emitters.

- lower priority is supposed to fire before higher priority.

* normalize postal code for comparisons

* move normalize functions into stripe-utils folder

* refactor stripePromise so that it provides a specific instance to each payment method.

This also provides it as a prop to the pm components.

* renadme apple pay express to payment request express

This adds full support for the stripe payment request api instead of just applePay (so GooglePay, MicrosoftPay and ApplePay are now supported).

Also adds numerous fixes to internal logic.

* add handling to skip core checkout validation logic if express payment method is handling payment

Express payment methods have their own internal validation so this removes the need for checkout validating fields. This is also necessary because checkout validation breaks the flow when making a payment using express payment methods because of the order of the flow for these methods.

* splitting out emmitter effects for checkout and improving logic

Splitting up effects limits the potential for firing off emitters more than needed.

* remove unnecessary ref definitions

* fix on cancel action erroring for payment request modal

* ensure unique stripe object for component and canPay

* set default total label if one isn’t configured on the server

* fix order of state changes

* simplify condition

* remove unnecessary dependency

* normalize to uppercase too

* simplify can make payment conditional

* update comment blocks
2020-04-08 12:36:04 -04:00
Darren Ethier bfdfa2f603 Move calculating state outside of checkout state (https://github.com/woocommerce/woocommerce-blocks/pull/2163)
* remove calculating as a checkout status (making it separate)

* include checkout is calculating for determining whether to flip payment status to process

* only change payment method state for status changes if needed

* fix reducer for shipping state

* include checkoutIsCalculating for determining whether to show validation errors in checkout block

* change where currentStatus is defined

* fix bug with saved payment method option
2020-04-08 11:46:34 -04:00
Albert Juhé Lluveras 10851a4e00 Handle errors in processOrder (https://github.com/woocommerce/woocommerce-blocks/pull/2156)
* Handle errors in processOrder

* Move scroll to top handler higher so error notices are visible

* Improve error messaging
2020-04-08 17:29:48 +02:00
Mike Jolley 4a8609737d Increase specificity of wc-block-totals__change-address-button (https://github.com/woocommerce/woocommerce-blocks/pull/2162) 2020-04-08 17:23:17 +02:00
Mike Jolley 55d0067426 Update previews and editor styles for cart and checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/2160)
* Update cart block editor styles to more closely match frontend

* Checkout editor styles

* Add image assets for previews and correct totals

* Add new previews

* Cart Preview

* Checkout preview

* Remove optional chaining
2020-04-08 16:03:39 +01:00
Mike Jolley 45fdcf16fc Render the shortcode if on an endpoint page (https://github.com/woocommerce/woocommerce-blocks/pull/2161) 2020-04-08 15:51:44 +01:00
Mike Jolley d73d9ca12e Refactor some of the shipping hooks/context usage (https://github.com/woocommerce/woocommerce-blocks/pull/2146)
* Counting helpers for shipping rates and packages

* Use new helpers

* Make shipping calculator use shipping context directly

* Totals should use current address

* Avoid useShippingRates

* Return rates and other items from useShippingRatse in useStoreCart instead

* Update tests

* Merge conflict

* Merge conflict
2020-04-08 12:20:41 +01:00
renovate[bot] 9a4fc8e2cc Update dependency @stripe/stripe-js to v1.3.1 (https://github.com/woocommerce/woocommerce-blocks/pull/2150)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-08 12:20:31 +01:00
Mike Jolley bb20212390 Fix cached shipping fees on consecutive orders (https://github.com/woocommerce/woocommerce-blocks/pull/2144)
* Rest API - Ensure totals are up to date on init

* Update cart controller to bail if the cart does not need shipping

* Update todos and wc supported version to match status of core

* Add todos

* Fix customer address population

* exit early
2020-04-08 11:23:25 +01:00
renovate[bot] bbf19ed59f Update dependency @stripe/react-stripe-js to v1.1.2 (https://github.com/woocommerce/woocommerce-blocks/pull/2149)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-08 11:21:15 +01:00
renovate[bot] 0742e8a3aa Update dependency @babel/preset-env to v7.9.5 (https://github.com/woocommerce/woocommerce-blocks/pull/2148)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-08 11:20:39 +01:00
renovate[bot] f9a754ea40 Pin dependency source-map-explorer to 2.4.2 (https://github.com/woocommerce/woocommerce-blocks/pull/2147)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-08 11:20:22 +01:00
renovate[bot] be35f98b06 Update dependency @types/jest to v25.2.1 (https://github.com/woocommerce/woocommerce-blocks/pull/2152)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-08 11:19:56 +01:00
Albert Juhé Lluveras db4f7820c6 Use new util functions in ShippingRatesControl (https://github.com/woocommerce/woocommerce-blocks/pull/2153)
* Use new util functions in ShippingRatesControl

* Import from base-utils
2020-04-08 11:19:05 +01:00
Mike Jolley 0000cac384 Don't show "select" labels for shipping or payment method steps if there is only one option (https://github.com/woocommerce/woocommerce-blocks/pull/2133)
* Only show descriptions if shipping/payment methods > 1

* Hide descriptions if no description text is set

* Fix object length

* methods->options

* Counting helpers for shipping rates and packages

* Use new helpers
2020-04-08 10:00:31 +02:00
Rua Haszard 0b956e1a4f Revert "show a "preview" saved card in the editor (first cut!)"
This reverts commit f409908eda.

(Accidental push to master)
2020-04-08 12:12:00 +12:00
Rua Haszard f409908eda show a "preview" saved card in the editor (first cut!) 2020-04-08 12:04:23 +12:00
Seghir Nadir 736d437316 Get preview data from Editor Context / (https://github.com/woocommerce/woocommerce-blocks/pull/2134)
* move preview to editor data and alias it no nothing in frontend builds

* seperate context and provider

* pass previewData as a prop to provider

* address comments
2020-04-07 16:41:22 +01:00
Albert Juhé Lluveras 5bcdc8f84a CheckboxControl: stop using Gutenberg's CheckboxControl (https://github.com/woocommerce/woocommerce-blocks/pull/2137)
* CheckboxControl: stop using Gutenberg's CheckboxControl

* Simplify styles and make them work fine in the editor
2020-04-07 16:37:03 +01:00
Mike Jolley 8ae3e1d195 Show "save payment information" checkbox only if customer ID > 0 (https://github.com/woocommerce/woocommerce-blocks/pull/2138)
* Add customer ID to checkout API response

* Add customer ID to checkout context

* Show/hide remember payment checkbox based on checkout context

* Pass via payment interface instead

* Missing commas
2020-04-07 15:29:59 +01:00
Seghir Nadir 5160d9d794 Disable continue to checkout if Item quantity is being updated and immediately remove items. (https://github.com/woocommerce/woocommerce-blocks/pull/2106)
* disable continue to checkout if item is being removed

* rename isPending and selectors/actions to isPendingDelete

* switch itemPendingDelete params order

* change to watching quantity changes not removal

* yield RECEIVE_REMOVED_ITEM

* update types and add return to select

* update tests

* switch params back

* only delete item after response from server

* update tests

* handle errors and unrelated unmounts

* disable row if is loading
2020-04-07 12:03:22 +01:00
Rua Haszard 3f0dcf00bc Revert "Record a tracks event when merchant toggles cart shipping calculator: (https://github.com/woocommerce/woocommerce-blocks/pull/1975)" (https://github.com/woocommerce/woocommerce-blocks/pull/2136)
This reverts commit 7921c3e5ba.
2020-04-07 12:11:14 +02:00
Jason Conroy dc8cc7681f Update CONTRIBUTING links (https://github.com/woocommerce/woocommerce-blocks/pull/2135) 2020-04-07 09:56:17 +02:00
Albert Juhé Lluveras 8c7d4805a4 Show validation errors again (https://github.com/woocommerce/woocommerce-blocks/pull/2124)
* Make validation errors appear

* Make validation errors appear all at once

* Simplify diff

* Expose shippingErrorStatus from shipping context

* Memoize currentErrorStatus

* Pass currentErrorStatus to observers

* Add missing type-def property

* Fix typo in constant name

* Refactor emitEvent so false responses don't return true

* Make onCheckoutProcessing observers return errorMessage and validationErrors properties
2020-04-06 16:36:19 -04:00
Mike Jolley 9085f8aa8d Bump required jetpack autoloader version (https://github.com/woocommerce/woocommerce-blocks/pull/2132) 2020-04-06 17:37:23 +01:00
Seghir Nadir 0ca78dd654 Remove Keep me updated (https://github.com/woocommerce/woocommerce-blocks/pull/2057)
* remove checkbox of keep me updated

* remove double margin on useSameForBilling
2020-04-06 16:57:38 +01:00
Mike Jolley 5d2a630a07 Use mousedown event so view switches before blur event prevents the switch (https://github.com/woocommerce/woocommerce-blocks/pull/2129) 2020-04-06 16:36:03 +01:00
Mike Jolley cc3ed31feb Disable checkout form in the editor (https://github.com/woocommerce/woocommerce-blocks/pull/2128)
* Move no-shipping-placeholder to block - allow pointer events

* Allow payments placeholder to have pointer events

* Enable pointer events for children

* Wrap checkout with disabled
2020-04-06 16:35:09 +01:00
Darren Ethier 22ea154c6f Implement stripe server-side handling (stripe cc) (https://github.com/woocommerce/woocommerce-blocks/pull/2120)
* remove usage of paymentstatus dispatcher from apple pay

* add type-def for payment data response objects

* make sure shape of payment data for stripe cc is as server expects

* include payment data in checkout processor request

* fix bug that got reintroduced in rebase

* rename typedef
2020-04-06 08:44:00 -04:00
Darren Ethier d108e5ea96 Update stripe payment methods to work with new event emitters (https://github.com/woocommerce/woocommerce-blocks/pull/2115)
* Add interface for setting an express payment error notice.

* fix typedefs

* remove usage of paymentstatus dispatcher from stripe cc

* remove usage of paymentstatus dispatcher from apple pay

* remove any existing express payment notice on click

* revert buggy change with abort payment call

- also ensure that completePayment sets applePayProcessing to false
2020-04-06 08:18:35 -04:00
Mike Jolley 3ac335e1f9 Storefront compatibility for sticky proceed to checkout button on mobile (https://github.com/woocommerce/woocommerce-blocks/pull/1999)
* Storefront compatibility

* Remove storefront actions
2020-04-06 07:50:33 -04:00
Darren Ethier 4baa99cf65 Refactor payment method interface to remove payment status dispatcher (https://github.com/woocommerce/woocommerce-blocks/pull/2116)
* don’t expose payment method status dispatcher on payment method interface

* update apple-pay-express to use new currentPaymetnStatus object shape
2020-04-06 07:28:46 -04:00
Mike Jolley d637c28d62 Update add to cart to useStoreCart hook (https://github.com/woocommerce/woocommerce-blocks/pull/2103)
* Switch add to cart events to useStoreCart hook

* Add to cart endpoint

* Inject dependenct schemas

* Feedback, cart items are based on product schema

* Variable typo

* Move hook to base

* Update totals correcrly

* Update tests to use schema/routes class

* Update tests to correctly use schema

* Remove type hint to prevent strict standards error
2020-04-06 11:36:28 +01:00
Seghir Nadir ea703c4a13 Add forcing source map on production to analyze tree-shaking (https://github.com/woocommerce/woocommerce-blocks/pull/2117)
* add forcing source map on production

* rename command to explore
2020-04-06 10:00:47 +01:00
Darren Ethier 4f990fd475 switch from event subscription to status watch (https://github.com/woocommerce/woocommerce-blocks/pull/2119) 2020-04-04 13:36:46 -04:00
renovate[bot] e54e08bccf Update npm to v6.14.4 (https://github.com/woocommerce/woocommerce-blocks/pull/1989)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-03 14:58:32 +01:00
Albert Juhé Lluveras 72801baf97 Switch 'Try reloading the page' from links to buttons (https://github.com/woocommerce/woocommerce-blocks/pull/2105)
* Switch 'Reload page' from links to buttons

* Rename class to wp-block-link-button

* Remove no longer needed CSS property
2020-04-03 15:22:56 +02:00
Mike Jolley d83214ed44 Ensure `AbstractBlock::enqueue_data` is only run once in the editor request. (https://github.com/woocommerce/woocommerce-blocks/pull/2113)
* Enqueue assets once

* Updates classes extending AbstractBlock to use enqueue_scripts
2020-04-03 14:17:32 +01:00
Albert Juhé Lluveras 8a78371703 Checkout: fix skeleton and responsive styles (https://github.com/woocommerce/woocommerce-blocks/pull/2109) 2020-04-03 14:17:09 +01:00
Darren Ethier 30fb8bef28 Fix flaw with event emitters and complete checkout flow for the cheque payment method. (https://github.com/woocommerce/woocommerce-blocks/pull/2108)
* Allow for priority to be set on event emitters

* Add payment event emitters

* add new actions/status to checkout state context

* implement event emitters in payment data context

* refactor checkout state context to use new actions in event emitters

* refactor checkout processor to handle new event emitters

* fix type-defs for registered payment methods

* register observer for cheque payment method integration

* add inline todo

* fix sort

* fix tests and add test for priority usage in event emitters

* remove todo and just add explanatory comment

* condense sort logic

* lowercase test description

* abstract emitter callback to reduce code

* don’t process passed in errors if it’s undefined

* improve error response expectation for payment processing event observer
2020-04-03 07:50:54 -04:00
Seghir Nadir c361a158c4 Respect needs_shipping in Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/2101)
* replace SHIPPING_ENABLED with needsShipping

* rename needsShipping variable

* only show shipping in checkout sidebar if we need shipping
2020-04-02 18:10:36 +01:00
Seghir Nadir cede3a0acf disable proceed to checkout if rates are loading or being selected (https://github.com/woocommerce/woocommerce-blocks/pull/1978)
* disable proceed to checkout if isCalculating is true

* add checkout provider

* remove unnecessary duplicate checkout count increment/decrement.

* remove redudant checkoutProvider

* remove already handled todo

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-04-02 18:05:08 +01:00
Mike Jolley f0b4be8bc8 Add Payment Methods Registry for registering scripts and data (https://github.com/woocommerce/woocommerce-blocks/pull/2090)
* Added cheque gateway and payment method registration system

Fix promises

Remove log

Use status, not checkoutstate

Bug @nerrad showed me

Payment method type registry

Refactor integrations to register themselves.

Stripe and Cheque Integrations/registration

Splt gateways into separate files on build

Add settings from server to cheque gateway

Merge apple and credit card stripe scripts

* Missing files from rebase

* Tweaks to payment-methods-registry (https://github.com/woocommerce/woocommerce-blocks/pull/2091)

* Small tweaks and docblock updates

* Handle undefined settings

* rebase fix

* Simplify promise

* Remove filesuffix for payment methods config

* Fix typo

* Rebase fix

* Update cart and block actions

* Add woocommerce_blocks_payment_method_type_registration

* Missing method names

* Missing name in stripe

* replace actions with script dependencies

* Scripts are needed in admin context too, by default

* Put back the hooks...

* Add is_active check to see if assets need to be enqueued or not

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-04-02 18:04:15 +01:00
Seghir Nadir 0ac3300ebf fix broken e2e-tests (https://github.com/woocommerce/woocommerce-blocks/pull/2102) 2020-04-02 16:10:27 +01:00
renovate[bot] 11a63860a9 Update babel monorepo (https://github.com/woocommerce/woocommerce-blocks/pull/2014)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-02 15:10:55 +01:00
Mike Jolley 8468869319 Cart item validation and notices in cart/checkout (https://github.com/woocommerce/woocommerce-blocks/pull/2079)
* Add error handling to cart API

* Handle new error codes in checkout

* Display errors in cart

* Fix failing test

* Move error codes to constants
2020-04-02 15:04:43 +01:00
renovate[bot] 95c1a53b2f Update dependency @types/react to v16.9.31 (https://github.com/woocommerce/woocommerce-blocks/pull/2015)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-02 14:50:15 +01:00
renovate[bot] fd6c4b2e73 Update dependency autoprefixer to v9.7.5 (https://github.com/woocommerce/woocommerce-blocks/pull/2016)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-02 14:48:33 +01:00
renovate[bot] cfb4d83d2c Update storybook monorepo to v5.3.18 (https://github.com/woocommerce/woocommerce-blocks/pull/1990)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-02 14:47:50 +01:00
Albert Juhé Lluveras 503fb9bd70 Update Checkout skeleton to match layout introduced in woocommerce/woocommerce-blocks#2041 (https://github.com/woocommerce/woocommerce-blocks/pull/2099) 2020-04-02 14:40:49 +01:00
renovate[bot] 2117453656 Update mariadb Docker tag to v10.5 (https://github.com/woocommerce/woocommerce-blocks/pull/1988)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-02 14:40:27 +01:00
renovate[bot] 3958de2f88 Pin dependencies (https://github.com/woocommerce/woocommerce-blocks/pull/2084)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-02 14:39:33 +01:00
renovate[bot] d98a0d89f9 Update dependency eslint-config-prettier to v6.10.1 (https://github.com/woocommerce/woocommerce-blocks/pull/2086)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-02 14:38:59 +01:00
Albert Juhé Lluveras 73d1432b02 Hook up checkout validation with context (https://github.com/woocommerce/woocommerce-blocks/pull/2033)
* Hook up checkout validation with context

* Make sure hasValidationErrors is up to date in onCheckoutProcessing

* Move validation check inside CheckoutProcessor's processCheckout

* Make sure all checkout form fields have a unique ID

* Don't clear checkout context errors in shipping context

* Move CheckoutProcessor to the top so scrollToTop works

* Do not disable Place Order Button if there are errors

* Split checkValidation and processCheckout in Checkout Provider

* Refactor event emitter to use Maps

* Save payment method errors to validation context

* Show an notice when a payment method has an error

* Make sure JS errors during payment are displayed

* Remove error notice when payment method doesn't return an error anymore

* Make sure payment methods know if shipping and billing addresses are the same

* Make sure checkout is only processed if payment methods didn't fail

* Make sure state input also has an id

* Clear input and select errors on unmount

* Pass id to CountryInput and StateInput

* Fix function name

* Add missing default context values

* Move onCheckoutCompleteError effect to CheckoutBlock

* Remove conditional from shipping setHasError
2020-04-02 11:27:54 +02:00
renovate[bot] 837a52f44f Update dependency config to v3.3.1 (https://github.com/woocommerce/woocommerce-blocks/pull/2085)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-02 10:36:41 +02:00
renovate[bot] 6e70e3b9c1 Update dependency jest to v25.2.4 (https://github.com/woocommerce/woocommerce-blocks/pull/2087)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-02 10:33:47 +02:00
Darren Ethier b0370b44b9 split up payment-methods.js file into smaller bits (https://github.com/woocommerce/woocommerce-blocks/pull/2089)
- adds more inline docs
- improves/adds more type-defs
2020-04-01 10:58:50 -04:00
Darren Ethier 2d53b2ace1 Refactor checkout context provider to be more flexible and implement CartProvider (https://github.com/woocommerce/woocommerce-blocks/pull/2083)
* Rename and move existing checkout provider to checkout-state provider.

This allows us to re-use the interface exposed on this provider for cart and checkout blocks.

* refactor checkout provider to implement the new checkout state provider.

* Add Cart provider and export

* fix type-defs

* fix editor context provider and ensure all `isEditor` checks come from this provider

* fix type definition

* implement cart provider
2020-04-01 05:27:53 -04:00
Darren Ethier df851aaff3 refactor checkout error status dispatcher (https://github.com/woocommerce/woocommerce-blocks/pull/2082)
- setHasError now receives a boolean that determines what state to set.
- remove clearError dispatcher
- fix related type-defs in checkout context.
2020-03-31 15:28:36 -04:00
Mike Jolley 9b0f545398 Parse error response before rejecting (https://github.com/woocommerce/woocommerce-blocks/pull/2080) 2020-03-31 17:00:03 +01:00
Darren Ethier d3fdc4b358 Finish wiring up shipping data context provider and add disabled state to checkout submit button (https://github.com/woocommerce/woocommerce-blocks/pull/2070)
* add selecting rate resolution state to the cart store

* expose whether rate is being selected on useSelectShippingRate

* Cleanup and refactor ShippingDataProvider

- remove un-needed component and move shipping rates into context provider
- remove error handling (currently the ui/ux for the checkout should result in no errors and any api errors are non-recoverable).
- Add logic for shipping rate selection into context provider and add event emitters for it.
- increment/decrement checkout calculation counts when shipping rates are being selected.

* dispatch checkout error if there is an error

* disable place order button if checkout is calculating or has error

* update doc block

* fix convention for js comment blocks
2020-03-31 11:40:27 -04:00
Albert Juhé Lluveras 8bac7b8264 Fix minor Stripe payment method issues (https://github.com/woocommerce/woocommerce-blocks/pull/2078)
* Fix params mismatch in Stripe

* Wrap Strip onSubmit with a try/catch block

* Fix createSource signature
2020-03-31 15:21:54 +02:00
Darren Ethier 355c1269d8 Implement mechanism for reliably passing through server data in editor context. (https://github.com/woocommerce/woocommerce-blocks/pull/2076)
* add method for enqueueing editor assets for the block editor

* configure Checkout to ensure editor assets are loaded in the block editor.

* move common functions to abstract

* ensure cart has server data passed through to editor

* ensure `enqueue_data` is only ever called once.

* make sure we enqueue data for cart

* add missing attributes arg

* remove logic that doesn’t do anything
2020-03-31 09:20:49 -04:00
Seghir Nadir 0046b73bbf delete passed arg to useShippingRates since it's not needed 2020-03-31 13:22:41 +01:00
Seghir Nadir 868f21c62c dont include stripe with Cart block 2020-03-31 13:21:25 +01:00
Darren Ethier 6c75dd9eae make sure payment method assets are loaded in block editor (https://github.com/woocommerce/woocommerce-blocks/pull/2075) 2020-03-31 12:56:32 +01:00
Rua Haszard 9d2fec68d0 add extra checks to checkout/cart/order APIs to avoid editor errors (https://github.com/woocommerce/woocommerce-blocks/pull/2072)
* add extra checks to checkout/cart/order APIs to avoid editor errors

* remove redundant register_block_script, introduced in rebase of woocommerce/woocommerce-blocks#2071

* prevent JS errors in checkout block in editor:
- add fallback state in defaults
- this is needed because checkoutData setting is null in admin

* Revert "add extra checks to checkout/cart/order APIs to avoid editor errors"

This reverts commit a26045b4a4675eb90b6b7235e2df0d29ca776915.

* Revert "prevent JS errors in checkout block in editor:"

This reverts commit 79729617f17c855ad71938af7703119fa5ccdabf.

* Hydrate from API conditonally

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2020-03-31 11:57:28 +01:00
Albert Juhé Lluveras 4d19b0a18a Add 2.5.15 changelog 2020-03-31 12:54:12 +02:00
Mike Jolley 61a5b7b132 Add checkout error state (https://github.com/woocommerce/woocommerce-blocks/pull/2069)
* Add checkout error state

* Update message wording and icon
2020-03-31 11:47:48 +01:00
Mike Jolley bf8715707d [Experiment] Add container to run php unit tests in docker (https://github.com/woocommerce/woocommerce-blocks/pull/2004)
* Add container to run php unit tests in docker

* Improvemnets to entrypoints

* Simplfiy dockerfile
2020-03-31 11:47:40 +01:00