Commit Graph

825 Commits

Author SHA1 Message Date
Mike Jolley eb196226d8 WIP: Add Inner blocks to order summary (https://github.com/woocommerce/woocommerce-blocks/pull/6065)
* Sub/Total/Fee inner blocks

* Row blocks within the inner block

* Update icons

* Resolve stying issues

* Remove old block

* Pin totals row

* Locking logic update

* Heading inner block

* Refactor where inner blocks are defined

* Add todos

* Todo for Consider deprecating OrderMetaSlotFill and DiscountSlotFill in favour of inner block areas.

* Improve frontend registration of components using new entrypoint

* Experiment- external block context

* Revert "Experiment- external block context"

This reverts commit 4b75668ec7eb62f065c6a488cd942a666e26204f.

* Duplicate inner blocks to avoid conflicts with context

* Remove todo

* Rename block dir

* Some test fixes

* Fix import

* fix import

* linting

* Remove unused attributes

* Optional classname

* fix coupons import

* fix shipping mocks

* Styling

* Fix selectors in e2e tests

* Add back the wc-block-components-totals-wrapper class that was used for each segment in the totals Order summary

Because, removing them was:
-  a breaking change for the old structure
- was making it harder to target the inner blocks. Before the class was used to target each segment
- it was making the wc-block-components-totals-item behave as a child or parent depending on the inner block, inconsitency

* Reuse the TotalsWrapper component for C& C blocks inner blocks

This component was removed in this PR, but  we wrap components in the Cart and Checkout sidebar in a TotalsWrapper. This will ensure consistent spacing and borders are applied to items in the sidebar.

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
Co-authored-by: Raluca Stan <ralucastn@gmail.com>
2022-04-01 15:45:18 +02:00
Tung Du 77990a5c1b Fix: Shopping Button default hover and focus style (https://github.com/woocommerce/woocommerce-blocks/pull/6157) 2022-03-30 18:38:29 +07:00
Albert Juhé Lluveras eb8bfedcf1 Remove button aligment from Featured Product and Featured Category blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6156) 2022-03-30 10:57:06 +02:00
Tung Du f4d4bed2c1 Mini Cart Contents: Refactor inner blocks styling using `currentColor` (https://github.com/woocommerce/woocommerce-blocks/pull/6130) 2022-03-29 20:48:59 +07:00
Alba Rincón e140901142 Convert `CheckoutOrderNotes` to TS (https://github.com/woocommerce/woocommerce-blocks/pull/6118)
* Convert order-notes to TS

* Rename onChange argument name

To be consistent with the one in the `setOrderNotes` action
2022-03-28 15:44:25 +02:00
Tomasz Tunik f7f1b89dc5 Upgrade @wordpress/scripts and /env packages (https://github.com/woocommerce/woocommerce-blocks/pull/6114)
* upgrade wordpress/scripts to 22.3

* update jest config/setup

* add explicit-exports-references plugin

to handle payment-method-config.tsx spying on external methods
the way code is output now changed and tests like this would not
work anymore as transpilet files were no longer using exports but
local references to methods.

* missing snapshot

* make cart-products E2E test more stable

* surppress eslint error in test file

* fix css stylelint issues

* update eslint-plugin-woocommerce eslint package

* remove temp test:e2e:start script

* re-run

* add stylelint as recommended extension

* remove redundant types (provided by packages now)

* patch update @testing-library/jest-dom
2022-03-28 15:00:20 +02:00
Tung Du 3b8d790efe Prepare the Mini Cart block for Feature Plugin (https://github.com/woocommerce/woocommerce-blocks/pull/6127) 2022-03-28 15:42:07 +07:00
Tung Du 7d60c8fc66 Fix: Mini Cart: Ability to choose the drawer behavior when user add products to cart (https://github.com/woocommerce/woocommerce-blocks/pull/6052) 2022-03-26 07:32:23 +07:00
Alba Rincón 88b208ebef Convert Textarea component to TS (https://github.com/woocommerce/woocommerce-blocks/pull/6113) 2022-03-25 10:21:09 +01:00
Tung Du 6e375408f7 Mini Cart: Fix footer buttons hover style (https://github.com/woocommerce/woocommerce-blocks/pull/6086)
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2022-03-24 22:34:36 +07:00
Tung Du 937bab7688 Fix: Mini Cart Contents: only show the active view (https://github.com/woocommerce/woocommerce-blocks/pull/6053) 2022-03-23 09:58:03 +07:00
Alba Rincón 13311e7bee Rename Legacy Template block to Classic Template block (https://github.com/woocommerce/woocommerce-blocks/pull/6021)
The internal ID has been kept after a comment by @tjcafferkey. This causes a
bit of inconsistency in the internal code, but it was deemed that it would have
been better as users who have customized templates using this
blocks ID will have saved this in their database, and it would result
in a corrupt block when loaded, and we didn't want to support both IDs at the
moment.

Otherwise, most other references to the legacy template, are now using the word
“classic”.

Co-authored-by: Alba Rincón <alba@albasauatticmbp.home>
2022-03-22 23:34:43 +01:00
Tung Du 9c22f241ca Mini Cart: Improve template part description (https://github.com/woocommerce/woocommerce-blocks/pull/6054) 2022-03-22 08:56:02 +07:00
Thomas Roberts a6bff7e6e8 Change `shippingRatesLoading` to `isLoadingRates` (https://github.com/woocommerce/woocommerce-blocks/pull/5999)
* Change `shippingRatesLoading` to `isLoadingRates`

* Revert isLoadingRates back to old name in payment method interface

* Update docs with correct names returned by usePaymentMethodInterface

* Update TS to name the selectShippingRate method correctly

* Change method name on usePaymentMethodInterface back
2022-03-14 11:29:25 +00:00
Tomasz Tunik 2ad55b5b9e Fix box-sizing on Global Styles blocks with border width control (https://github.com/woocommerce/woocommerce-blocks/pull/6043)
Set box-sizing to border-box on affected blocks: Featured product, featured category, sale badge.
2022-03-11 13:01:15 +01:00
Luigi Teschio f78b2d8619 Remove not used attributes (https://github.com/woocommerce/woocommerce-blocks/pull/5974)
* Remove not used attributes woocommerce/woocommerce-blocks#5952

remove not used attributes

* remove not necessary jsdoc comments

Co-authored-by: Tomasz Tunik <tomasztunik@gmail.com>
2022-03-11 12:44:51 +01:00
Tung Du 75bf08d2c9 Fix: Exclude Button block from the Empty Mini Cart Contents block insterter (https://github.com/woocommerce/woocommerce-blocks/pull/6034) 2022-03-11 08:17:37 +07:00
Mike Jolley 5165611e45 Remove deprecated data controls in favour of those from the `@wordpress/data` package (https://github.com/woocommerce/woocommerce-blocks/pull/5574)
* Remove expected warnings from test suite

* Switch dispatch and select usage to `controls`, from `@wordpress/data`

* Wrap render with act

* resolveSelect to wait for resolution

* resolveSelect
2022-03-10 13:22:05 +00:00
Tung Du e735ffe5c2 Refactor: Use an alternative mini cart icon to fix the Mini Cart styling issues (https://github.com/woocommerce/woocommerce-blocks/pull/5985) 2022-03-09 16:13:52 +07:00
Tung Du 22cdefd3da Cart: Accepted Payment Methods block: Use utility instead of the local function (https://github.com/woocommerce/woocommerce-blocks/pull/6001) 2022-03-09 07:06:32 +07:00
Luigi Teschio fc01576a38 Additional classes are visible on frontend page woocommerce/woocommerce-blocks#5881 (https://github.com/woocommerce/woocommerce-blocks/pull/5991)
Additional classes are visible on frontend page
2022-03-08 14:24:52 +01:00
Mike Jolley eae1d75c86 Store API: Consistent error code and hook naming (https://github.com/woocommerce/woocommerce-blocks/pull/5992)
* Update error codes with `woocommerce_rest_` prefixes.

* Update action and filter hooks with woocommerce_store_api_ prefix

* Update hook docs

* Update error code mismatches

* Update hook name in tests

* update hook name in tests

* phpcs
2022-03-07 13:51:07 +00:00
Thomas Roberts 6b8ef2773a Try move shipping related dat to a `@wordpress/data` store (https://github.com/woocommerce/woocommerce-blocks/pull/5896)
* Add address-related items to wc/store/cart data store

* Add useUpdateCustomerData hook

This allows us to have a single hook responsible for updating the customer information on the server.

* Add useUpdateCustomerData hook in Checkout block

* Remove shippingAsBilling from previousCustomerData ref type

* Add useShippingAsBillingCheckbox hook

* Remove checkbox handling from useCheckoutAddress

* Merge with woocommerce/woocommerce-blocks#5810 changes

* Move shipping as billing to checkout state context provider

* Subscribe to changes

* Cache customerDataToUpdate

* Combine customerDataType and customerDataContextType

* Fix notice context

* Clean up inline docs for push changes

* Add useShippingData hook

* Add shipping related selectors to cart store

* Update useShippingDataContext to useCustomerData hook

* Update uses of useShippingDataContext to get data from hook instead

* Remove rogue linebreak

* Re-add linebreak

* Re-add linebreak, remove shippingAsBilling

* Re-add linebreak

* Use useShippingData and useCustomerData instead of context

* Fix fromEntriesPolyfill to use number or undefined as an index option

* Convert derive-selected-shipping-rates to TS

* Add SelectShippingRateType

* Get needsShipping from new hook and not context

* Get address data from useCustomerData instead of useShippingDataContext

* Move selectedRates, selectShippingRate and isSelectingRate

* Remove items from ShippingDatacontext that are available in data stores

* Get shipping data from stores, not context in payment method interface

* Consider shipping rates to be loading if customer data is updating

* Get rates from useShippingData hook instead of context

* Fix incorrect TypeScript types and incorrectly named destructure

* Move useShippingData into shipping folder

* Update tests to mock useShippingData instead of context

* Remove empty string fallback from shipping phone

* Get types from Cart declaration instead of Picking them

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2022-03-04 17:43:45 +00:00
Luigi Teschio 31b179eb49 Revert "Add wc-block-mini-cart__contents class for the Mini Cart block (https://github.com/woocommerce/woocommerce-blocks/pull/5800)" (https://github.com/woocommerce/woocommerce-blocks/pull/5984)
This reverts commit 54ce880762.
2022-03-03 09:52:51 +01:00
Tom Cafferkey e8855a5af3 Full Store Editing: Technical documentation (https://github.com/woocommerce/woocommerce-blocks/pull/5939)
* templates README and block-template-controller README

* Add execution scenario to block template controller readme

* Amend return value to block template controller readme

* Add source file link to block template controller docs

* LegacyTemplate.php overview

* Legacy Template JavaScript block README

* Update requirements of templates feature

* Doc updates based on feedback, and change Legacy Template references to Classic Template in anticipation of naming convention updates

* Update classic-template.md README

* Reword part of the add_block_templates section

* Update assets/js/blocks/legacy-template/README.md

Co-authored-by: Michael P. Pfeiffer <frontdevde@users.noreply.github.com>

* Update docs/readme.md

Co-authored-by: Michael P. Pfeiffer <frontdevde@users.noreply.github.com>

* Update docs/templates/README.md

Co-authored-by: Michael P. Pfeiffer <frontdevde@users.noreply.github.com>

* Update docs/templates/README.md

Co-authored-by: Michael P. Pfeiffer <frontdevde@users.noreply.github.com>

* Update README for blocktemplatecontroller

* Review feedback for Woo FSE technical documentation

Co-authored-by: Michael P. Pfeiffer <frontdevde@users.noreply.github.com>
2022-03-02 08:57:53 +00:00
Tomasz Tunik 61427b9e60 Change label from Remove to Reset (https://github.com/woocommerce/woocommerce-blocks/pull/5951)
This is to reflect how we agreed it would be best
  when working on Featured Product block
2022-02-28 11:39:52 +01:00
Tarun Vijwani 2a5a40279f Removed negative margin-bottom from .wc-block-checkout__additional_fields class (https://github.com/woocommerce/woocommerce-blocks/pull/5899) 2022-02-24 12:29:30 +04:00
Mike Jolley a58b2d0ac4 Store API: Introduce API Versioning System (https://github.com/woocommerce/woocommerce-blocks/pull/5911)
* Fix missing dependency

* Min version exceeds required 5.6

* Move exceptions

* Move schemas under V1 namespace

* Move routes to v1

* Move RouteException

* Route versioning

* Update route and schema identifiers/init

* Rework route init to support multiple versions and multiple schema

* Tests for cart routes

* Cart coupons tests

* Batch

* extensions

* Update docs

* Update remaining tests

* woocommerce_store_api_route_version was unused

* Revert unrelated change

* Fix phpcs

* Update src/StoreApi/docs/guiding-principles.md

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Update src/StoreApi/docs/cart-items.md

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Update src/StoreApi/RoutesController.php

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Note about v1 unversioned endpoints

* Remove unused get_route_version

* 409 comment in tests

* Remove copy pasted comments

* Update all usage to v1

* Correct namespace

* More v1 namespaces

* More missing v1

* fix mocks

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
2022-02-23 12:00:45 +00:00
Tomasz Tunik 1805d29cc9 Add to Featured Product block option to remove custom image (https://github.com/woocommerce/woocommerce-blocks/pull/5886)
* adds toolbar option to remove custom image

removing custom image will reset it back to the default
product image if available

* update copy as per discussion

went with just Reset as it is commonly used in WordPress
and will have translation available
2022-02-23 08:16:47 +01:00
Mike Jolley 0714fa41bd Customer Data Store and revised handling for Shipping As Billing (https://github.com/woocommerce/woocommerce-blocks/pull/5817)
* Add address-related items to wc/store/cart data store

* include shippingAsBilling in return value of useCustomerData

* Add useUpdateCustomerData hook

This allows us to have a single hook responsible for updating the customer information on the server.

* Add useUpdateCustomerData hook in Checkout block

* Remove the updating customer data work from the useCustomerData hook

* Remove shippingAsBilling from previousCustomerData ref type

* Add useShippingAsBillingCheckbox hook

* Control shippingAsBilling from single hook

* Remove checkbox handling from useCheckoutAddress

* Remove CustomerDataContext typedef

* Merge with woocommerce/woocommerce-blocks#5810 changes

* Move shipping as billing to checkout state context provider

* Unused import

* Subscribe to changes

* Only receiveCartContents when updating customer data via checkout

* Cache customerDataToUpdate

* rename debounced function

* Combine customerDataType and customerDataContextType

* Change case of CustomerDataType

* debouncedUpdateCustomerData typo

* Fix notice context

* Clean up inline docs for push changes

* Comment on dirty state

* Phone is always set

* shippingAddress is never undefined

* setBillingPhone

* receiveCartContents explanation

* Tweak customerData to avoid null

* useShippingAsBilling

Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2022-02-22 17:45:01 +00:00
Luigi Teschio 6e05f2dcf9 update innerBlock template for Featured Product and Featured Category blocks woocommerce/woocommerce-blocks#5676 (https://github.com/woocommerce/woocommerce-blocks/pull/5867)
update innerBlock template for Featured Product and Featured Category blocks
2022-02-22 15:49:11 +01:00
Albert Juhé Lluveras 530730e1a8 Remove hover effect from disabled Mini Cart button (https://github.com/woocommerce/woocommerce-blocks/pull/5909) 2022-02-22 15:40:48 +01:00
Raluca Stan 858fffd697 Pass context information about parent block to the existing Slots (https://github.com/woocommerce/woocommerce-blocks/pull/5885)
* Pass context information about containing block to the existing Slots

* Fix images added to the Slots docs

* Use the parent's block name for the context prop passed to Slot fills
2022-02-22 10:33:52 +01:00
Luigi Teschio 71bd69ad07 Pre-hydrate Mini Cart Block woocommerce/woocommerce-blocks#5882 (https://github.com/woocommerce/woocommerce-blocks/pull/5892)
* Pre-hydrate Mini Cart Block woocommerce/woocommerce-blocks#5882

Pre-hydrate Mini Cart Block

* try to fix test

* fix wrong behaviour
2022-02-18 14:44:10 +01:00
Tung Du dceb480e00 fix shopping button icon (https://github.com/woocommerce/woocommerce-blocks/pull/5859) 2022-02-17 16:19:01 +01:00
Luigi Teschio 54ce880762 Add wc-block-mini-cart__contents class for the Mini Cart block (https://github.com/woocommerce/woocommerce-blocks/pull/5800)
* Add wc-block-mini-cart__contents class for the Mini Cart block woocommerce/woocommerce-blocks#5418

Add wc-block-mini-cart__contents class for the Mini Cart block

* removed comment
2022-02-16 17:18:44 +01:00
Daniel Dudzic 5e55c1ae4a Mini Cart Block contents: Remove item border bottom (https://github.com/woocommerce/woocommerce-blocks/pull/5739)
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
2022-02-16 16:13:26 +01:00
Tung Du c7c914218e Fix: Mini Cart template part editor height (https://github.com/woocommerce/woocommerce-blocks/pull/5825) 2022-02-15 16:57:53 +07:00
Tung Du e513968a2d Add Shopping Button Inner block (https://github.com/woocommerce/woocommerce-blocks/pull/5614) 2022-02-15 13:48:06 +07:00
Luigi Teschio 8ae22fbc51 Remove not necessary div woocommerce/woocommerce-blocks#5419 (https://github.com/woocommerce/woocommerce-blocks/pull/5687)
Remove not necessary div
2022-02-14 17:39:04 +01:00
Raluca Stan 051bb64138 Fix wide appender buttons overlap in Cart & Checkout blocks in the Editor (https://github.com/woocommerce/woocommerce-blocks/pull/5801)
* Add the correct appender button for non empty groups

* Revert "Add the correct appender button for non empty groups"

This reverts commit 4b41d7d7f82461813b3464d1b4f931c442bce3be.

* Force position relative for custom InnerBlocks.ButtonBlockAppender  appenders.

Removing InnerBlocks.ButtonBlockAppender  from renderAppender = {InnerBlocks.ButtonBlockAppender } results in the black appender button beeing shown only when the block is selected, and we need the appender to be visible by default.
2022-02-10 11:33:48 +01:00
Saad Tarhi d53551d4a7 Fix/cart button focus hover states (https://github.com/woocommerce/woocommerce-blocks/pull/5712)
* Add hover & focus styles for component buttons

We are using an old version of the "@wordpress/component" package,
that's why we are not getting the latest style fixes from Gutenberg.

The reason to not using the latest version is that we had some issues
with the bundle size.

The current solution is to set our own focus & hover styles

* Replace raw value with Sass variable

* Fix hover style for the mini cart block

We don't have the outlined button yet. This styles is unique for the
mini cart button.

To refactor this code, maybe we should create a reusable outlined button

* Add variant to the Woo Block Button component

To refactor our code, adding a "variant" prop looks logical since we are
have already "contained" & "outlined" buttons. So, for future need for an
outlined button, no need to manually apply the same style again.

The "contained" variant is set by default for legacy reasons. Our Button
component was first built as a contained one.

* Fix height difference: oulined & contained buttons

The outlined buttons have more height because of the added border value.

To fix it we can replace the border with the inner shadow.

Co-authored-by: Saad Tarhi <saad.tarhi@automattic.com>
2022-02-09 18:32:05 +01:00
Luigi Teschio 62cabea003 Set focus on Empty Mini Cart Contents Block (https://github.com/woocommerce/woocommerce-blocks/pull/5744)
* Set focus on Empty Mini Cart Contents Block woocommerce/woocommerce-blocks#4618

Set focus on Empty Mini Cart Contents Block

* fix useEffect logic
2022-02-09 10:51:30 +01:00
Thomas Roberts 3c16e7f533 Spread metadata when loading block in frontend (https://github.com/woocommerce/woocommerce-blocks/pull/5732) 2022-02-08 10:33:27 +00:00
Alex Florisca 16d5e773bc Reformatted prettier files (https://github.com/woocommerce/woocommerce-blocks/pull/5735) 2022-02-07 16:59:44 +00:00
Tom Cafferkey d533ae42e7 Add a Remove Image option to the Featured Category block (https://github.com/woocommerce/woocommerce-blocks/pull/5719) 2022-02-07 08:35:02 +00:00
Tomasz Tunik 729de5ea05 Revert "fix: accessibility of search products block (https://github.com/woocommerce/woocommerce-blocks/pull/5691)" (https://github.com/woocommerce/woocommerce-blocks/pull/5717)
This reverts commit d4d3f18453.
2022-02-04 11:26:34 +01:00
Tomasz Tunik d4d3f18453 fix: accessibility of search products block (https://github.com/woocommerce/woocommerce-blocks/pull/5691)
When output with php the block had correct accessibility on
the frontend but in the editor or when rendered as block
the correct aria label was missing because of misspelled
aria-label attribute.

Also fixed wrong value type provided for tabIndex in editor
while at it.
2022-02-02 19:56:56 +01:00
Luigi Teschio 86bbf5a037 Attribute Filter block: Enable global style (https://github.com/woocommerce/woocommerce-blocks/pull/5557)
* Product title: add support global style woocommerce/woocommerce-blocks#4965

* add specific type

* add custom save function

* move hooks in a specific folder

* fix crash on WP 5.8

* Featured Category block: Add support for global style woocommerce/woocommerce-blocks#4965

Featured Category block: Add support for global style

* fix border color

* Attribute Filter block: enable global style woocommerce/woocommerce-blocks#4965

Attribute Filter block: enable global style woocommerce/woocommerce-blocks#4965

* fix eslint error

* fix test

* add comments about !important
2022-02-02 18:41:39 +01:00
Mike Jolley 2b5f115d41 Remove custom `Icon` component in favour of `@wordpress/icons` where possible (https://github.com/woocommerce/woocommerce-blocks/pull/5599)
* Remove atom icon

* Swap icon usage to WordPress package

* remove unused icons from library

* Use @wordpress/primitives

* Product cats block to listView

* On-sale to use percent instead of tag icon

* add to cart button use button icon

* on sale products block icon

* Handpicked products use stack icon

* Products by stock box icon

* Make sparkles woo purple

* Fix icon name

* Correct more tag name

* fix path to icons

* Update snaps

* Update readme to explain updated usage

* Import SVG and path from primitives

* Missing isFeaturePluginBuild

* Update assets/js/icons/README.md

Co-authored-by: Raluca Stan <raluca.stan@automattic.com>

* Update assets/js/icons/README.md

Co-authored-by: Raluca Stan <raluca.stan@automattic.com>

* Update assets/js/icons/README.md

Co-authored-by: Raluca Stan <raluca.stan@automattic.com>

* update lock

Co-authored-by: Raluca Stan <raluca.stan@automattic.com>
2022-02-01 16:54:38 +00:00
Tung Du 995d41e2a9 Fix: Empty Mini Cart contents overflow issue (https://github.com/woocommerce/woocommerce-blocks/pull/5635)
* fix: add wrapper for empty mini cart contents inner blocks. Allow inner content to be scrollable

* fix overflow issue for the editor

* add padding for the empty cart view
2022-02-01 17:19:41 +01:00
Luigi Teschio 9d1464baf3 Featured Product: Enable global style (https://github.com/woocommerce/woocommerce-blocks/pull/5555)
* Product title: add support global style woocommerce/woocommerce-blocks#4965

* add specific type

* add custom save function

* move hooks in a specific folder

* fix crash on WP 5.8

* Featured Category block: Add support for global style woocommerce/woocommerce-blocks#4965

Featured Category block: Add support for global style

* fix border color

* Featured Product block: enable global style woocommerce/woocommerce-blocks#4965

Featured Product block: enable global style

* fix border color

* fix eslint error

* fix opacity

* fix border radius

* fix opacity

* disable font-size support

* restore height for featured product and featured category
2022-02-01 15:01:31 +01:00
Luigi Teschio 2438fcd434 Disable font-size for the Featured Category block woocommerce/woocommerce-blocks#5681 (https://github.com/woocommerce/woocommerce-blocks/pull/5682)
Disable font-size for the Featured Category block
2022-01-31 18:03:54 +01:00
Manos Psychogyiopoulos 6ed7034223 Add inner wrapper div in 'td.wc-block-cart-item__product' (https://github.com/woocommerce/woocommerce-blocks/pull/5240)
* Add inner wrapper div in td.wc-block-cart-item__product

Adding this wrapper element is necessary in order to be able to "fake" item grouping in a theme-agnostic manner: https://user-images.githubusercontent.com/1783726/118831630-97855600-b8c8-11eb-8906-c7f9ada769e7.png

* Whoops

* Remove classnames function

* Update indentation for QuantitySelector

Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2022-01-31 15:18:29 +00:00
Niels Lange 83ae876898 Keep top margin for create account section in editor (https://github.com/woocommerce/woocommerce-blocks/pull/5633) 2022-01-31 22:15:46 +07:00
Thomas Roberts c7aa3a75b9 Update tests to use `useEvent` (https://github.com/woocommerce/woocommerce-blocks/pull/5573)
* Update payment-method-data-context tests to use userEvent

* Update mini cart block tests to use userEvent

* Update payment methods tests to use userEvent
2022-01-31 10:53:21 +00:00
Thomas Roberts afd9d42805 Add Checkout Order Summary inner block tests (https://github.com/woocommerce/woocommerce-blocks/pull/5675)
* Add fake items fixture

* Add test for rendering items in sidebar

* Add test for items with addons

* Add textContentMatcherAccrossSiblings helper

This is needed to match text when it's spread over a few elements

* Add test to ensure subtotal renders correctly

* Add test to ensure discounts are rendered correctly

* Add test to ensure fees are shown correctly

* Add test to check coupon entry form isn't present when coupons disabled

* Add more mock data to useStoreCart

* Mock useShippingDataContext

* Rename useStoreCartValue to useStoreCartReturnValue

* Remove unnecessary coupon button test

This should be tested within the TotalsCoupon component

* Add tests for shipping presence

* Add test for coupons

* Remove cart items fixtures

These are no longer needed

* Move the findByText utils to the utils folder

* Move inner blocks test to correct directory
2022-01-31 10:53:08 +00:00
Thomas Roberts a46f13c6c5 Move Checkout block attributes into metadata (`block.json`) (https://github.com/woocommerce/woocommerce-blocks/pull/5594)
* Add block title to AbstractBlock class

* Add block title to Checkout block

* Include all block.json files in tsconfig

* Add get_block_title method to Checkout.php

* Remove redundant block_title field

* Add block.json and remove static attributes from attributes.ts

* Register block using attributes from block.json

* Add metadata_path to AbstractBlock

* Add function to AssetsApi to get the metadata path from the plugin root

* Register the block using metadata if it's set in the block's class

* Remove get_block_title method

* Only add supports and attributes to the block when not registering with metadata

* Change get_block_metadata to get_block_metadata_path

* Change indentation to tabs in block.json

* Update comment to clarify why attributes and supports are set later

* Check if path to metadata is not empty instead of set and not empty

* Move checkout block out of cart-checkout directory

* Update get_block_metadata_path function to find block.json automatically

* Remove metadata path from AbstractBlock

* Check if there's a metadata file and register blocks with metadata if so

* Move deprecated attributes out of metadata and into attributes.ts

* Re-add deprecated attributes to checkout index

* Move order notes test

* Move test for checkout phone number in edito

* Fix indentation in checkout/block.json

* Move checkout terms tests

* Try forcing storefront theme in e2e tests

* Revert "Try forcing storefront theme in e2e tests"

This reverts commit 5b0fd47a2c39aadb0141a4ed28cbc0e6baa89625.

* Try capturing screenshot on test failures

* Try uploading error in try catch

* Try uploading artefacts on error

* Test uploading artefacts

* Screenshot just before looking for edit post layout

* Revert "Screenshot just before looking for edit post layout"

This reverts commit 61dff027789ce13a0d84e7b6f11e431637c5a450.

* Revert "Test uploading artefacts"

This reverts commit adf5cc55bcdb677f889bf5a62803b4150d98e665.

* Revert "Try uploading artefacts on error"

This reverts commit 7441a832a113a95fef89cc1b8db6dc79271be516.

* Revert "Try uploading error in try catch"

This reverts commit ca412ce505d56286b164f588a201a451f6bceeb6.

* Revert "Try capturing screenshot on test failures"

This reverts commit 0de6e97df19b116091a7bb3b8652713867d2d80f.

Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
2022-01-28 16:37:06 +00:00
Thomas Roberts b7560ebed5 Add tests for Checkout Terms block (https://github.com/woocommerce/woocommerce-blocks/pull/5621)
* Install @wordpress/block-editor package

* Add test for checkout terms frontend block

* Add tests for checkout terms in editor

* Add tests for Checkout Terms in editor

* Use void 0 as function's return type

* Update tests to use toBeInTheDocument and split checkbox test in two

* Use void 0 for empty function
2022-01-27 12:34:52 +00:00
Tung Du 6f4c00a2fd Fix: Exclude Mini Cart and other blocks inside the Mini Cart Contents block (https://github.com/woocommerce/woocommerce-blocks/pull/5616) 2022-01-27 17:10:53 +07:00
Tom Cafferkey 9934533375 Revert "Allow LegacyTemplate block to be reinserted, only on WooCommerce block templates. (https://github.com/woocommerce/woocommerce-blocks/pull/5545)" (https://github.com/woocommerce/woocommerce-blocks/pull/5643)
This reverts commit cf9c82e02e.
2022-01-27 09:45:00 +00:00
Luigi Teschio 2370ce4378 Featured Category block: add support for global style (https://github.com/woocommerce/woocommerce-blocks/pull/5542)
* Product title: add support global style woocommerce/woocommerce-blocks#4965

* add specific type

* add custom save function

* move hooks in a specific folder

* fix crash on WP 5.8

* Featured Category block: Add support for global style woocommerce/woocommerce-blocks#4965

Featured Category block: Add support for global style

* fix border color

* fix opacity

* fix border radius

* fix order rules css
2022-01-26 18:16:50 +01:00
Niels Lange 59c8ddc531 Show single express payment button in full width (https://github.com/woocommerce/woocommerce-blocks/pull/5601)
* Show single express payment button in full width

* Change :first-child:nth-last-child(1) to :only-child
2022-01-24 10:22:02 +07:00
Tung Du 718f2dbc6f Mini Cart Contents: Support link and text colors (https://github.com/woocommerce/woocommerce-blocks/pull/5566) 2022-01-22 00:39:04 +07:00
Thomas Roberts aaaf6787a3 Add tests for phone field on checkout (https://github.com/woocommerce/woocommerce-blocks/pull/5604) 2022-01-21 13:24:48 +00:00
Thomas Roberts 0d7b8ab95a Add tests for order notes component (https://github.com/woocommerce/woocommerce-blocks/pull/5605) 2022-01-21 12:07:36 +00:00
Mike Jolley c492a97d83 Fix default `stockStatusOptions` in tag and attribute blocks (https://github.com/woocommerce/woocommerce-blocks/pull/5590)
* Fix default stockStatusOptions in tag and attribute blocks

These should be an array of keys, not objects.

* Fix stockStatus definition on PHP side

* Swap state to debounce.

* Improve presentation of stock filters

* Remove state usage for display options

* Remove debounce

* Consistent panel titles
2022-01-19 11:42:21 +00:00
Tom Cafferkey cf9c82e02e Allow LegacyTemplate block to be reinserted, only on WooCommerce block templates. (https://github.com/woocommerce/woocommerce-blocks/pull/5545)
* Set attribute of legacy template block when block is inserted

* Allow inserter on Woo templates only

* Allow correct legacy block straight from the inserter

* Use WP Data store outside component to register block

* Pass in all attribute data when registering block

* Accommodate templates targetted at specific products or taxonomies

* Replace beginsWith with startsWith

* Replace test data with production data

* Conditionally use stores selector if it exists

* Unsubscribe if the store does not exist

Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
2022-01-17 10:50:57 +00:00
Luigi Teschio dfa98dcb5e Price Filter block: enable global style woocommerce/woocommerce-blocks#4965 (https://github.com/woocommerce/woocommerce-blocks/pull/5559)
Price Filter block: enable global style woocommerce/woocommerce-blocks#4965
2022-01-17 10:10:26 +01:00
Thomas Roberts c950f29400 Remove extra padding for cart sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/5430)
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
2022-01-13 17:10:18 +00:00
Raluca Stan b1bef86632 Fix Using / for division is deprecated warnings seen when building the project (https://github.com/woocommerce/woocommerce-blocks/pull/5556) 2022-01-13 15:01:36 +01:00
Alex Florisca a8d979c47b Default all product images to "cropped" and actual image width (https://github.com/woocommerce/woocommerce-blocks/pull/5551)
* Default imageSizing for the all products block to 'cropped'

* set max-width:100%, width: auto on product grid images
2022-01-12 17:50:48 +00:00
Luigi Teschio cba17c2ef9 Mini Cart block: re-enable background support woocommerce/woocommerce-blocks#4965 (https://github.com/woocommerce/woocommerce-blocks/pull/5539)
Mini Cart block: re-enable background support woocommerce/woocommerce-blocks#4965
2022-01-11 15:08:16 +01:00
Mike Jolley a5bd8f0564 Fix All Products Block Tests due to incorrect Stock Filter addition (https://github.com/woocommerce/woocommerce-blocks/pull/5541)
* Remove stock filter from all products block

* Add missing stock filter to product-category block
2022-01-11 11:25:05 +00:00
Mike Jolley a1695861f2 Add minimum quantity, maximum quantity, and step (multiple_of) to the Cart Block and Store API (https://github.com/woocommerce/woocommerce-blocks/pull/5406)
* add min and step to Store API

* add min and step support

* typo

* Update assets/js/base/components/quantity-selector/index.tsx

* Update assets/js/base/components/quantity-selector/index.tsx

* Fix debounce callback

* Style qty input to show steps

* Implement quantity_limits in API

* Quantity validation

* Update product API

* Normalize on + -

* Separate add to cart events from cart item events in regards to limits

* Prevent qty change for editable line items

* Unify filters

* Remove step number indicator from buttons ¯\_(ツ)_/¯

* Normalize on mount

* Update docs

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
2022-01-11 11:09:59 +00:00
Mike Jolley e19abbc0c2 Remove Built-in Stripe Integration in favour of Stripe Extension (https://github.com/woocommerce/woocommerce-blocks/pull/5449)
* Remove Stripe from PHP side

* Remove stripe from client

* fix const name in tests

* Update docs
2022-01-11 10:53:38 +00:00
jonny-bull 87cb033cbd Add stock level filter to product blocks (https://github.com/woocommerce/woocommerce-blocks/pull/4943) 2022-01-10 13:39:24 +00:00
Tung Du 14c1017feb Mini Cart Contents block improvements (https://github.com/woocommerce/woocommerce-blocks/pull/5446) 2022-01-08 08:19:01 +07:00
Tung Du 4b159f0fcd Allow inserting blocks to filled mini cart (https://github.com/woocommerce/woocommerce-blocks/pull/5527) 2022-01-08 07:51:20 +07:00
Luigi Teschio c54440d0e1 Add wide and full alignment support for legacy template block (https://github.com/woocommerce/woocommerce-blocks/pull/5433)
* add align wide and full support for legacy template block

* fix PHP warning

* add a comment on get_markup_with_classes_by_attributes

* rename function

* add align wide and full support for legacy template block

* fix PHP warning

* add a comment on get_markup_with_classes_by_attributes

* rename function

* fix regex

* update regex

* update regex

* fix code styling
2022-01-07 10:47:48 +01:00
Luigi Teschio 549e10fabb Mini Cart Block: The color of the badge reflects the global style (https://github.com/woocommerce/woocommerce-blocks/pull/5477)
* Mini Cart Block: the color of the badge reflects the global style woocommerce/woocommerce-blocks#4965

Mini Cart Block: the color of the badge reflects the global style woocommerce/woocommerce-blocks#4965

* disable background
2022-01-06 09:47:34 +01:00
Lucio Giannotta 78a25b235f Legacy Template: Add warning about block removal (https://github.com/woocommerce/woocommerce-blocks/pull/5208)
Legacy blocks were previous locked for removal to avoid unintended
consequences. However, this would lock the ability to move the block within
other e.g. layout blocks and unnecessarily limit merchant customization ability.

Now that we have reverted this decision, merchants could delete this block,
which is likely **not** what they want to do. While we investigate other, more
long-term, solutions, we are adding a warning notice.

Refs woocommerce/woocommerce-blocks#5180. Fixes woocommerce/woocommerce-blocks#5207.

* Rename legacy blocks to avoid confusion with the term “Template”
2022-01-05 19:18:23 +01:00
Malith Senaweera 65835d3689 Fix duplicated error notices (https://github.com/woocommerce/woocommerce-blocks/pull/5476)
* Fix duplicated error notices

StoreNoticeProvider is already being used within Block component. This
removal prevents duplicated error notices within the Payment Options
section

* Move StoreNoticeProvider from payment block

Remove StoreNoticeProvider from payment block and move it to the parent
frontend block to avoid unnecessarily loading the notice provider
2022-01-04 17:37:46 +00:00
Luigi Teschio 723eabee80 Add global style for Active Filters block (https://github.com/woocommerce/woocommerce-blocks/pull/5465)
* Enable global style for active filters block

* show blacklisted blocks in full site editing side

* fix test

* --amend

* fix check
2022-01-03 10:41:19 +01:00
Thomas Roberts a8e094473c Revert "Remove extra padding for cart sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/5247)" (https://github.com/woocommerce/woocommerce-blocks/pull/5429)
This reverts commit a60cd66692.
2021-12-30 12:24:18 +00:00
Thomas Roberts 5036c69638 Add E2E tests for Filter blocks (Price, Attribute, and Active Filters) (https://github.com/woocommerce/woocommerce-blocks/pull/4562)
* Add clear and fill input test util

* Add tests for Filter Products by Price

* Add class name to filter products by price block in editor

* Update wp-env

* Fix formatting

* Update lock

* Revert "Update lock"

This reverts commit f4e809e000430eea3972c94fd2aea0a19ba6961b.

* Create product attributes during setup

* Remove product attributes during teardown

* Add attributes in fixture-data

* Add two new products, for attribute testing

* Load attributes into store and apply them to products

* Add class to Filter by Attribute when editing

This is so it can be targeted in E2E tests more easily.

* Add tests for Filter Product by Attribute

* Fix formatting in attribute-filter.test.js

* Add tests for active filters block

* Add doc block for ensuteCleanAttributes

* Update wording of title test in all filter block E2E

* Update test wording to read better

* Update snapshots

* Use pptr-testing-library selectors to click elements

This makes the tests easier to reason with, and lets us take a step back from the implementation details (classnames etc.)

* Add saveOrPublish test util

* Use pptr-testing-library selectors to click elements in attribute filter

* Use pptr-testing-library selectors to click elements in price filter

* Add `puppeteer-testing-library`

* Use puppeteer-testing-library API to look for H6 button

* Use correct argument in jest-puppeteer.dev.config

* Update package.json & package-lock.json

* remove tests for 5.3

* remove snapshots

* Remove ensureCleanAttributes

* Remove puppeteer-testing-library, install missing expect-puppeteer package and update tests

The puppeteer-testing-library, although added by gutenberg is not actively used.
I have removed it and realised that the added functionality can be easily replaced by expect-puppeteer.
This is a package that we specify in the jest configuration but it was not part of our package.json.
The selectors from puppeteer-testing-library have been replaced with .toClick and the utility clearAndFillInput with .toFill

The Filter by Attribute block has been skiped until tests are fixed.

* Add back setupPageSettings to jest setup

* Fix filter by attribute block test

* Fix linting error

Co-authored-by: Raluca Stan <ralucastn@gmail.com>
2021-12-23 17:26:10 +01:00
Thomas Roberts 20cac18474 Don't show shipping price when no options are available (https://github.com/woocommerce/woocommerce-blocks/pull/5444)
* Add isCheckout prop to NoShippingPlaceholder and TotalsShipping

* Pass isCheckout to TotalsShipping in Checkout sidebar

* Show the NoShippingPlaceholder if no rates are found

* Show better error message when no shipping is available in checkout
2021-12-23 13:24:08 +00:00
Tung Du b2eecf3bb0 Fix: Mini Cart: Default content for empty state (https://github.com/woocommerce/woocommerce-blocks/pull/5421) 2021-12-22 18:03:58 +07:00
Niels Lange 9a1cd85779 Remove text decorations from product filter (https://github.com/woocommerce/woocommerce-blocks/pull/5384) 2021-12-22 15:33:37 +07:00
Alex Florisca a60cd66692 Remove extra padding for cart sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/5247) 2021-12-21 13:46:49 +00:00
Niels Lange ee45d9d9cf Remove full-width mode from cart and checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/5315) 2021-12-20 11:27:51 +00:00
Tung Du 50066455c0 Fix: Mini Cart block: divide contents into three inner blocks (https://github.com/woocommerce/woocommerce-blocks/pull/5386)
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2021-12-20 14:57:55 +07:00
Albert Juhé Lluveras bffbc491a8 Add correct class to Legacy Template block icon (https://github.com/woocommerce/woocommerce-blocks/pull/5400) 2021-12-16 13:29:55 +01:00
Tung Du b0623a8b52 Mini Cart: only display the editing link to users with site editing permission (https://github.com/woocommerce/woocommerce-blocks/pull/5372) 2021-12-14 07:54:23 +07:00
Tung Du 0350268b82 Switch to correct view if inner block is selected (https://github.com/woocommerce/woocommerce-blocks/pull/5358) 2021-12-14 07:46:10 +07:00
Seghir Nadir 772ee23faa Update item quantity if server result is different from client (https://github.com/woocommerce/woocommerce-blocks/pull/5352)
* respect when quantity changes from up

* add test
2021-12-10 16:26:57 +01:00
Mike Jolley 70106d45d3 Revise checkout payment statuses to avoid data loss on error (https://github.com/woocommerce/woocommerce-blocks/pull/5350)
* Clarify docs for STARTED

* Clarify docs for setActivePaymentMethod

* Remove useActivePaymentMethod hook (this held state for active methods and tokens)

* Update type defs

* Enhance setActivePaymentMethod action to accept method data

* SET_ACTIVE_PAYMENT_METHOD action

* Add setActivePaymentMethod dispatcher and make "started" status only

* Update setActivePaymentMethod usage in express methods

* Set radio control defaults

* Consolodate tokens and methods

* Update assets/js/base/context/providers/cart-checkout/payment-methods/reducer.ts

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

* Spacing

* Split saved cards tests from regular, since saved cards are checked by default

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2021-12-10 16:26:16 +01:00
Niels Lange 6a74887464 Limit CSS styles to WooCommerce Block icons only (https://github.com/woocommerce/woocommerce-blocks/pull/5363)
* Limit CSS styles to WooCommerce Block icons only

* Update assets/css/editor.scss

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

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2021-12-10 21:32:44 +07:00
Luigi Teschio 13deb1b09e Mini Cart Block: render the empty state set on template parts (https://github.com/woocommerce/woocommerce-blocks/pull/5338)
* add view switcher for mini cart contents block

* editor view switcher

* update mini cart template file

* render the empty state template parts for the Mini Cart Block woocommerce/woocommerce-blocks#4674

render the empty state template parts for the Mini Cart Block woocommerce/woocommerce-blocks#4674

* update selector

* allow empty mini cart block to add all blocks

* fix tests; improve code style

* install @wordpress/block-editor package

* fix warning on frontend side

* block-editor package is not necessary

* merge attributes object

Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2021-12-10 12:11:59 +01:00
Albert Juhé Lluveras 29fa0a61e6 Fix Mini Cart template part link on WP 5.9 (https://github.com/woocommerce/woocommerce-blocks/pull/5348)
* Fix link to edit the Mini Cart template part in WP 5.9

* Use wp_is_block_theme() function

* Add protection against overwriting isSiteEditorAvailable setting

* Rename isSiteEditorAvailable to isBlockTheme
2021-12-10 11:23:16 +01:00