Commit Graph

2335 Commits

Author SHA1 Message Date
Thomas Roberts 7b1bd90f61 Update changelog to describe a bug fix more appropriately 2021-02-23 10:35:24 +00:00
Thomas Roberts 81fdd45f70 Update changelog in readme 2021-02-23 10:20:05 +00:00
Thomas Roberts 76d00db174 Update testing docs 2021-02-23 10:18:57 +00:00
Thomas Roberts 78a0680657 Show total sale badge in medium carts & make it display below price (https://github.com/woocommerce/woocommerce-blocks/pull/3879)
* Show total sale badge in medium carts

* Add markup to cart line item row to enable it to be displayed as flex

* Add styling to display price and sale badge as flex

* Revert product price being displayed as block

* Rename sale badge and price wrapper

* Hide line-total sale badge on mobile

* Change class name on total price and sale badge wrapper again
2021-02-23 10:14:48 +00:00
Thomas Roberts 1e93a75104 Update zip file in testing notes 2021-02-22 14:19:12 +00:00
Thomas Roberts 8a73b5c870 Fix cart line subtotal display when currency has 0 decimals (https://github.com/woocommerce/woocommerce-blocks/pull/3876)
* Fix cart line subtotal display when currency has 0 decimals

* Fix wrong usages of getCurrency instead of getCurrencyFromPriceResponse

* Add tests

* Move comment in tests to relevant line
2021-02-22 14:16:23 +00:00
Thomas Roberts 366e0a1875 Add 4.5.2 testing notes 2021-02-22 13:46:57 +00:00
Thomas Roberts c7c8fbe4bf Update Readme with changelog 2021-02-22 13:33:04 +00:00
github-actions 68b0fad08b generating changeset for pull request 2021-02-22 13:17:40 +00:00
github-actions aa76de1385 generating changeset for pull request 2021-02-22 13:17:40 +00:00
Thomas Roberts 4e409e2fc5 Update changelog for 4.4.2 and 4.5.1 2021-02-16 19:31:01 +00:00
github-actions 82ccf5b159 generating changeset for pull request 2021-02-16 18:09:09 +00:00
github-actions e5441060ec generating changeset for pull request 2021-02-16 18:09:09 +00:00
Thomas Roberts 70262ab890 Bumping version strings to new version. 2021-02-16 18:08:49 +00:00
Thomas Roberts 3f79b42c14 Bumping version strings to new version. 2021-02-16 16:40:15 +00:00
Thomas Roberts 71cbc9cfa0 Update date of release in readme 2021-02-16 16:38:04 +00:00
Thomas Roberts 20a9d9ff22 Fix a typo in the word image 2021-02-16 14:27:11 +00:00
Thomas Roberts 3d1fc239d3 Remove documentation improvement from changelog 2021-02-16 14:02:56 +00:00
Thomas Roberts aaab546b39 Update zip file for testing 2021-02-16 13:47:57 +00:00
Thomas Roberts c9ade2c722 Update testing documentation and changelog with blocking changes 2021-02-16 12:32:32 +00:00
Thomas Roberts 4fe4060fec Fix product price not displaying properly when product is on sale (https://github.com/woocommerce/woocommerce-blocks/pull/3853)
* Use else if in ProductPrice

This is because the priceComponent variable should be set depending on some conditions, but multiple of them could be true, so by using else if we only handle the first true case

* Update snapshots for jest
2021-02-16 12:30:10 +00:00
Albert Juhé Lluveras f4f95eb26e Show cart item total price including taxes when DISPLAY_CART_PRICES_INCLUDING_TAX is true (https://github.com/woocommerce/woocommerce-blocks/pull/3851)
* Show cart item total price including taxes when DISPLAY_CART_PRICES_INCLUDING_TAX is true

* Show cart item total price including taxes in Checkout block too
2021-02-16 10:14:24 +00:00
Thomas Roberts 1fb61c1199 Update release testing documenatation 2021-02-15 20:01:32 +00:00
Thomas Roberts 6a2d8e331d Update readme.txt with 4.5.0 release changelog 2021-02-15 17:47:16 +00:00
github-actions 2aadfdc652 generating changeset for pull request 2021-02-15 17:29:46 +00:00
github-actions bd08f3988e generating changeset for pull request 2021-02-15 17:29:46 +00:00
Mike Jolley be4d32d705 Pages must be published to be valid (https://github.com/woocommerce/woocommerce-blocks/pull/3843) 2021-02-15 16:48:30 +00:00
Mike Jolley 51789e2105 Login via account page (https://github.com/woocommerce/woocommerce-blocks/pull/3844) 2021-02-15 16:46:02 +00:00
Thomas Roberts edf79c699a Catch errors during cart validation (https://github.com/woocommerce/woocommerce-blocks/pull/3703)
* 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

* Catch errors during cart validation

* Add get_error_message_for_stock_exception_type function

This will be used to get an error message depending on the type of extension, and whether the plural form, or singular form is needed. This abstraction is better because the code is used in more than one place in the API.

* Use error message generation function instead of creating errors individually

* Use specific error codes for each type of error & fix PHPDoc

Now the stock_exceptions_to_wp_errors function will return an array of WP_Errors this is better as the client needs a distinct error code to display and replace notices.

* No longer remove items from cart or modify quantity if there is an error

* Return the WP_Error from RouteException or all Stock WP_Errors

* Fix error in PHPDoc

* No longer necessary to add get_cart_item_errors into an array

This is because the method always returns an array now.

* Rename variables in get_cart_item_errors to be more descriptive

* Improve PHPDoc on get_cart_item_errors

* Replace underscores with hyphens in error code

* Only return WP_Errors that have an actual error in them

* Add unit test for ensure the cart errors relating to stock are handled

* Fix typo in comment

* Use optional chaining to add errors to cart
2021-02-15 14:03:04 +00:00
renovate[bot] c8adb17cd1 Lock file maintenance (https://github.com/woocommerce/woocommerce-blocks/pull/3842)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-15 12:23:43 +00:00
Albert Juhé Lluveras e5f6a1047c Allow extensions to extend cart item price (https://github.com/woocommerce/woocommerce-blocks/pull/3750)
* Add filter to extend product price

* Extend order summary product price too

* Make it so 'format' is applied to all product price types

* Order

* Pass lineItem to the filter

* Remove code targeting WC Subscriptions

* Rename filter

* Remove unnecessary CSS block that made prices be displayed as blocks

* Use line item totals instead of product price multiplied by quantity to show line item price

* Fix wrong currency usage

* Add comment to disable eslint

* Fix JS error when totals is undefined

* Align order summary item price to the right

* Use extendibility API instead of filters

* Remove __EXPERIMENTAL_CART_ITEM_PRICE_FILTER from docs

* fix rebase

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2021-02-12 00:37:05 +01:00
Seghir Nadir f7894b3c7f remove unsed imports (https://github.com/woocommerce/woocommerce-blocks/pull/3811) 2021-02-11 15:29:43 -05:00
Mike Jolley e9cc965aea Update jetpack autoloader dependency to 2.9.1 (https://github.com/woocommerce/woocommerce-blocks/pull/3832)
* Update jetpack autoloader and make version dependency more permissive

* lock file
2021-02-11 17:53:54 +00:00
Mike Jolley 7772d41007 Extensibility for Block Checkout Address Fields (https://github.com/woocommerce/woocommerce-blocks/pull/3662)
* Pass get_country_locale via assets

* Create helper to prepare and merge address fields

* Use new helper in address form

* Only pass field overrides now that fields are merged

* Fixc configs and remove lodash usage

* Prevent formatting of empty postcodes to suppress api error

* prevent memo on rerender

* Conitonal enqueue of locale data

* define index in increments of 10

* remove address-form

* circ deps changes

* Workaround for core data issue

* fix test

* remove prepareAddressFields export

* Remove old comment

* object from.entries polyfil

* Revert "object from.entries polyfil"

This reverts commit ba343adcf5fd2f843b225aebe340cce9b664c851.

* replace fromentries

* fix final fromentries
2021-02-11 16:49:27 +00:00
Mike Jolley 66fbd9738b Moved Nonce Logic to Cart API Classes (https://github.com/woocommerce/woocommerce-blocks/pull/3812)
* Reduce repetition in SchemaController::initialize

* Ensure AbstractCartRoute has a cart schema when it returns errors

* Move nonce logic to cart

* typo
2021-02-11 16:26:52 +00:00
Seghir Nadir 39ab3070c8 fix double imports 2021-02-11 16:36:24 +01:00
Seghir Nadir d107dc89a9 Allow extensions to extend Cart Item Name in Cart and Checkout. (https://github.com/woocommerce/woocommerce-blocks/pull/3807)
* Add validation function

* Prefix validateElementOrString with __experimental

* Update experimental docs

* Typo

* Update JS docs

* Use an object for applyCheckoutFilter args

* Args doesn't need to be an object

* Wrap validation function execution in a try/catch block

* Only accept strings for the totalLabel filter

* Change applyCheckoutFilter signature

* Add validation function

* Add Product name filter

* rebase

* update second filter call

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2021-02-11 13:40:55 +01:00
renovate[bot] 03551edae8 Update dependency @automattic/color-studio to v2.4.0 (https://github.com/woocommerce/woocommerce-blocks/pull/3819)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-11 10:57:17 +01:00
Thomas Roberts cb09248b07 Add subtotal and sale badge filters - PR to correct branch (https://github.com/woocommerce/woocommerce-blocks/pull/3826)
* Replace filters with an extendibility API to hook into Cart and Checkout blocks

* Update docs

* Add a validate argument

* Add docs comments

* Add tests

* Add validation function

* Prefix validateElementOrString with __experimental

* Update experimental docs

* Typo

* Update comment

* Update JS docs

* Use an object for applyCheckoutFilter args

* Args doesn't need to be an object

* Wrap validation function execution in a try/catch block

* Only accept strings for the totalLabel filter

* Change applyCheckoutFilter signature

* Apply filters for subtotal and sale badge in CartLineItemRow

* Append suffix to prices and SaleBadge if passed in as a prop

* Add subtotal filter to OrderSummaryItem

* Add tests for OrderSummaryItem and ProductPrice

* Rename test for ProductPrice

* Update checkout filter registration plugin name

* Remove obsolete snapshop

* Remove suffix and change to format

This is because we want to make the entire price string editable, not just the part after it.

* Change formatting on SaleBadge to use createInterpolateElement

* Remove tests that are no longer needed.

* Update ProductPrice tests to reflect changes to format prop

* Check that subtotalPriceFormat contains <price/> in OrderSummaryItem

* Fix cart block styling to stop badges overflowing the container

* Add <price/> placeholder in OrderSummaryItem price filter

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2021-02-10 17:12:47 +00:00
renovate[bot] 2e90e95551 Update dependency @stripe/stripe-js to v1.12.1 (https://github.com/woocommerce/woocommerce-blocks/pull/3820)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-10 13:32:18 +00:00
Albert Juhé Lluveras 7b829b8a82 Use cart item key instead of name as the React key in Package (https://github.com/woocommerce/woocommerce-blocks/pull/3814) 2021-02-10 12:37:58 +01:00
renovate[bot] 7afdb11dc4 Update dependency @types/react to v16.14.3 (https://github.com/woocommerce/woocommerce-blocks/pull/3822)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-10 11:11:21 +00:00
renovate[bot] abb3323e00 Lock file maintenance (https://github.com/woocommerce/woocommerce-blocks/pull/3808)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-10 10:28:53 +01:00
renovate[bot] a9800f5ef7 Update dependency mini-css-extract-plugin to v1.3.6 (https://github.com/woocommerce/woocommerce-blocks/pull/3823)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-10 03:22:45 +00:00
renovate[bot] e70e3e6e40 Update dependency @testing-library/user-event to v12.6.3 (https://github.com/woocommerce/woocommerce-blocks/pull/3821)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-10 02:34:41 +00:00
renovate[bot] a9626c8d06 Update babel monorepo to v7.12.13 (https://github.com/woocommerce/woocommerce-blocks/pull/3818)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-10 01:11:36 +00:00
Albert Juhé Lluveras 1a97bf80b0 Replace filters with an extendibility API to hook into Cart and Checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/3774)
* Replace filters with an extendibility API to hook into Cart and Checkout blocks

* Update docs

* Add a validate argument

* Add docs comments

* Add tests

* Add validation function

* Prefix validateElementOrString with __experimental

* Update experimental docs

* Typo

* Update comment

* Update JS docs

* Use an object for applyCheckoutFilter args

* Args doesn't need to be an object

* Wrap validation function execution in a try/catch block

* Only accept strings for the totalLabel filter

* Change applyCheckoutFilter signature
2021-02-09 17:54:38 +01:00
Mike Jolley d90e212f74 Validate order items on post, not on draft order creation (https://github.com/woocommerce/woocommerce-blocks/pull/3810) 2021-02-09 12:43:45 +00:00
Albert Juhé Lluveras 77119d9a7e Update Cart and Checkout sidebar design (https://github.com/woocommerce/woocommerce-blocks/pull/3797)
* Fix ShippingRatesControl not honoring renderOption prop

* Update order summary design

* Updates TotalsCoupon design

* Update Cart block sidebar title design

* Make values bold and labels regular in Cart and Checkout sidebar

* Update styles of shipping rates selector and radio control

* Remove unnecessary overflow rule in Panel content

* Fix shipping options in Checkout block

* Add some Twenty Twenty One fixes

* Fix saved payment methods display

* Remove top spacing no longer necessary in order summary quantity badge

* turn Totals title to bold

* Move right padding from product name to item description

* Take left margin off list items in product details

This is because in themes where a left margin is applied to li elements, the product detail/addon gets indented and it does not sit flush with the edge of the product details container. Adding this rule to the main wc-block-components-product-details  rule will stop other themes indenting <li>s

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2021-02-09 09:10:45 +01:00
Albert Juhé Lluveras 2acdbc088b Align Place Order button to the right (https://github.com/woocommerce/woocommerce-blocks/pull/3803)
* Fix Place Order button alignment

* Change order of Place Order and Return to Cart buttons
2021-02-08 14:42:56 +01:00