Commit Graph

531 Commits

Author SHA1 Message Date
Manish Menaria 861bc091d4
Product Collection - Add Editor UI for missing product reference (#51114)
* Initial implementation of the missing product state

- Changed `getProductCollectionUIStateInEditor` to a hook `useProductCollectionUIState`.
	- As we added logic to check if selected product reference is deleted which require making an API call. Therefore, I decided to use a hook.
- While making an API call to check if product reference is deleted, I decided to show spinner in the block.
- Introduced new UI state `DELETED_PRODUCT_REFERENCE` to handle the missing product state.
- Updated existing `ProductPicker` component to handle the new UI state.
	- It's better to use existing component for the missing product state, as it already has all the required UI.

* Add changefile(s) from automation for the following project(s): woocommerce-blocks

* Use getEntityRecord to check if product exists and other improvements

* Remove console log

* Add E2E tests for deleted product reference in Product Collection block

This commit introduces new E2E tests to verify the behavior of the Product
Collection block when dealing with deleted product references. The changes
include:

1. New test suite in register-product-collection-tester.block_theme.spec.ts
2. Modification to product-collection.page.ts to support custom product selection
3. Minor update to utils.tsx to handle trashed products

These tests ensure that the Product Collection block correctly handles
scenarios where referenced products are deleted, trashed, or restored,
improving the overall reliability of the feature.

* Simplify product creation in Product Collection block test

* Refactor E2E test for delete product reference picker

1. Removing the unnecessary `test.describe` block for "Deleted product reference"
2. Eliminating the `beforeEach` hook that was creating a test product
3. Integrating the test product creation directly into the main test

This change simplifies the test structure and improves readability while
maintaining the same test coverage for the Product Collection block's
behavior when dealing with deleted or unavailable products.

* Simplify logic for product collection UI state

This commit simplifies the handling of the `usesReference` prop in the
Product Collection block:

1. In `edit/index.tsx`, directly pass `usesReference` to
   `useProductCollectionUIState` hook without conditional spreading.

2. In `utils.tsx`, update the type definition of `usesReference` in the
   `useProductCollectionUIState` hook to explicitly include `undefined`.

* Refactor Product Collection block to improve prop passing

- Introduce ProductCollectionContentProps type for better prop management
- Refactor Edit component to use a renderComponent function
- Update component prop types to use more specific props
- Remove unnecessary props from ProductCollectionEditComponentProps
- Simplify component rendering logic in Edit component
- Adjust ProductPicker to receive only required props
- Update imports and prop types in various files to use new types

This refactoring improves code organization and reduces prop drilling by
only passing necessary props to each component. It enhances maintainability
and readability of the Product Collection block and related components.

* Refactor Product Collection block editor UI state handling

This commit simplifies the rendering logic in the Product Collection block's
Edit component. It removes a redundant case for the VALID state, as both
VALID and VALID_WITH_PREVIEW states now render the same ProductCollectionContent
component. This change improves code maintainability and reduces duplication.

* Fix: isDeletedProductReference is not set correctly

* Use "page.reload" instead of "admin.page.reload"

* Separate PRODUCT_REFERENCE_PICKER and DELETED_PRODUCT_REFERENCE cases

This improves readability and maintainability of the switch statement.

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-09-17 14:08:24 +05:30
Tung Du 93053f39ed
[Experimental] Product Filters: New and improved blocks structure (#51096) 2024-09-14 00:04:06 +07:00
Mike Jolley b0401ef25d
[Experimental] Delayed Account Creation Block (#50934)
* Add block to templates

* Register block type with php

* Create block type class

* Update webpack

* Move password strength meter component

* Add button styles when disabled

* Move password strength component

* Block WIP

* CSRF token handling

* Put new block behind feature flag

* Add experimental flag docs

* Update icon + description

* Changelog

* Lint errors

* Style controls

* Adjust icon markup

* subsctring match

* More specific import

* Fix test fail caused by layout shift

* Wording changes from Figma

* Check if logged in, not just if the current email is registered

* Use opacity for disabled button text

* Sync order data with customer after account creation

* Add id/fragment to form
2024-09-12 11:18:13 +01:00
Karol Manijak ed9742f18b
Skip failing tests from experimental Product filters feature (#51305)
* Skip failing tests from experimental feature

* Add changelog
2024-09-12 10:37:51 +02:00
Roy Ho 41cf2b285e
[Experimental] Product filters/overlay nav block redesign (#51211)
* Remove overlay icon settings from parent block

* Change overlay block icon to generic button icon

* Add logic to remove overlay nav when overlay mode is set to never

* Add logic to add overlay nav when overlay mode is not never

* Add default attributes for overlay nav button

* Add changefile(s) from automation for the following project(s): woocommerce-blocks

* Use unique icons for each overlay navigation close and open

* Add icon picker for open overlay navigation

* Add trigger type for overlay close navigation

* Add missing settings label

* Fix e2e tests

* Skip a test for overlay-navigation block

* Add e2e tests for overlay button behavior

* Fix linting error

* Skip overlay nav tests

* Fix icon size value not saving

* Revise logic to target explicitly the innerblock of product-filters

* Ensure overlay navigation is of type open-overlay

* Prevent possible race conditions

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-09-11 12:11:51 -07:00
Alexandre Lara 0b16cfa06a
[Experimental] Product Filters Redesign > Overlay: Add Fullscreen view (#50505)
* Add variation to Product Filters Overlay Navigation

* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce

* Move Product Filters Overlay Navigation to correct position

* Hide block when it is outside the Product Filters template part

* Display Navigation block in the frontend

* Show the Product Filters Overlay Navigation on the frontend

* Add logic to hide Product Filters Overlay Navigation block on the frontend

* Hide block on the Overlay template part

* Fix eslint errors

* Update the block variation title

* Remove the `isActive` property from the block variations

* Use Product Filters block context

* Replace enum with const

* Remove unnecessary `StyleAttributesUtils`

* Rename context key

* Move BlockOverlayAttribute to the constants.ts file

* fix BlockOverlayAttribute import

* Fix import error

* Improve code for the shouldHideBlock method

* Remove unnecessary attributes property

* Fix error in ProductFiltersOverlay block

* Add dialog to the Product Filters block

* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce

* Fix interactivity api error

* Prevent block from being hidden on Product Filters template part

* Fix inspector controls when block is hidden

* Add clickable action to the Product Filters Overlay Navigation block

* Fix interactivity directives that were not working for the Overlay

* Fix issue with dialog styles not being correctly applied

* Add the `closeDialog` functionality

* Parse and render blocks for the Product Filters overlay

* Fix padding

* Fix style for Product Filters Overlay navigation block

* Add e2e test

* Add e2e test to Product Filters Overlay template part

* Fix e2e test

* Fix issue causing the trigger button to show even though the overlay mode is set to 'Never"

* Fix issue causing close button to not be displayed in the dialog

* Add e2e tests

* Fix issue that was preventing users from scrolling down the dialog content

* Remove text duplication in e2e tests

* Remove unnecessary imports

* Fix php cs errors

* Fix php cs error

* Revert changes on Product Gallery modal styles

* Fix lint errors

* fix php cs lint errors

* fix php cs error

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-09-11 11:30:35 -03:00
Thomas Roberts 72112bd5d4
Update shipping calculator wording and Cart/Checkout order summary title (#51072)
* Update isAddressComplete to allow only specific fields to be checked

* Update tests for isAddressComplete

* Update wording on "enter address" prompt in Cart sidebar

* Update Shipping to Delivery in cart & checkout shipping total

* Only check the city, state, country, & postcode fields in shipping calc

* Update wording in the "Ships to" section of cart/checkout sidebar

* Update shipping calculator button to say delivery

* Update tests to use new strings

* Remove test that was falsely passing anyway

This test checked for presence of a string that wasn't in the codebase. It also doesn't seem like a valid test. Why would we want to remove the button just because default rates are available?

* Add changelog

* Left align text in shipping calculator button

It floats weirdly in the middle with the new text changes

* Update text in tests

* Update wording in unit tests

* Update shipping calculator text in test

* Update shipping text in test

* Update use of shipping in tests

* Skip test with no translation available

* Lint fixes

---------

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2024-09-09 15:19:57 +02:00
Karol Manijak a7231863c0
Product Collection: Trigger `wc-blocks_viewed_product` JS event (#51156)
* Define the event

* Add action sending an event in PC store

* Add directives and context to Product Template li element

* Use on--click directive in ProductImage

* Use on--click directive in Product Title

* Use on--click directive in Product Button

* Add changelog

* Add E2E tests

* Update docs

* Update blocks reference and docs manifest

* Update m,anifest

* Fix mistake in docs

* Regenerate docs manifest

* Fix lint

* Extractb new tests to a separate file
2024-09-05 12:52:35 +02:00
Roy Ho b618f81c6d
[Experimental] Product filters - ensure we can add multiple instances (#51051)
* Product filters ensure we can add multiple instances

* Add changefile(s) from automation for the following project(s): woocommerce-blocks

* Add e2e tests to ensure multiple filters can be added

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-09-04 05:39:07 -07:00
Manish Menaria 2433664aa8
Product Collection - Show product picker in Editor when collection requires a product but it doesn't exist (#50164)
* Show product picker control in the editor when a product context is required but not provided

Enhanced the Product Collection block by introducing the `selectedReference` attribute and implementing a product picker control. This control appears in the editor when a product context is required but not provided in the current template/page/post.

1. **block.json**: Added `selectedReference` attribute of type `object`.
2. **constants.ts**: Included `selectedReference` in the `queryContextIncludes` array.
3. **EditorProductPicker.tsx**: Created a new component for selecting products within the editor.
4. **editor.scss**: Added styles for the new Editor Product Picker component.
5. **index.tsx**: Updated logic to determine the component to render, incorporating the new Editor Product Picker.
6. **types.ts**: Defined types for `selectedReference` and updated `ProductCollectionAttributes` interface.

This enhancement allows merchants to manually select a product for collections that require a product context, ensuring the block displays correctly even when the product context is not available in the current template/page/post.

- **Product Picker Control**: Utilizes the existing `ProductControl` component for selecting products. This component is displayed in the editor when a collection requires a product context but it doesn't exist in the current template/page/post.

* Update label on ProductControl component

* Implement dynamic UI state management for product collection block

- Introduced `ProductCollectionUIStatesInEditor` enum to define various UI states for the product collection block.
- Added `getProductCollectionUIStateInEditor` utility function to determine the appropriate UI state based on context.
- Updated `Edit` component to use `getProductCollectionUIStateInEditor` for dynamic state management.
- Refactored `ProductCollectionContent` to utilize the new Editor UI state management.

* Fix: Product picker isn't showing

* Fix: Preview label state isn't showing

* Add changefile(s) from automation for the following project(s): woocommerce-blocks

* Refactor WooCommerceBlockLocation type

- Introduced specific interfaces for WooCommerceBlockLocation, including ProductLocation, ArchiveLocation, CartLocation, OrderLocation, and SiteLocation, to improve type safety and code clarity.
- Updated createLocationObject function to return a BaseLocation type.
- Refactored useSetPreviewState hook in product-collection utils:
  - Extracted termId from location.sourceData for cleaner and more readable code.
  - Replaced direct access of location.sourceData?.termId with termId variable.

* Remove fallback to 0 in case there may be a product with id 0

* Use optional chaining to avoid undefined errors

* Rename  to

* Change order of arguments in  function

* Pass boolean prop instead of making further recognition of the UI state in ProductCollectionContent

* Destructure  props in  component

* Rename  to

* Update names in  enum

* Rename  to  and change the structure to single number.

* Rename location to

* Add a method to choose a product in the product picker in Editor

* Add E2E tests

* Fix failing e2e tests by changing location to productCollectionLocation

* Add changefile(s) from automation for the following project(s): woocommerce-blocks

* Don't allow selecting product variations

* Minor code refactoring

* Fix: Product control isn't showing products

**Before**
```tsx
const getRenderItemFunc = () => {
		if ( renderItem ) {
			return renderItem;
		} else if ( showVariations ) {
			return renderItemWithVariations;
		}
    return () => null;
	};
```

As you can see above, `return () => null;` is returning a function which is causing the issue. This will render nothing in the list. I changed this to `return undefined;`. This way, we will use default render item function.

* Translate text in ProductPicker component

* Improve E2E test

* Use createInterpolateElement to safely render strong HTML tag

* Fix E2E tests

* Fix E2E tests

* Product Collection: Inspector control to change selected product (#50590)

* Add Linked Product Control to Product Collection Block Inspector Controls

- Introduced a new `LinkedProductControl` component in the Product Collection block's Inspector Controls.
- This control allows users to link a specific product to the product collection via a dropdown with a search capability.
- Added corresponding styles to `editor.scss`.
- Integrated a `useGetProduct` hook in the `utils.tsx` to fetch and manage the state of the linked product data, including handling loading states and errors.
- Updated the Inspector Controls to include the new Linked Product Control component, enhancing the block's customization options for users.

* Add E2E tests

* Hide product picker when product context is available

* Improve logic to hide Linked Product Control

* Add changefile(s) from automation for the following project(s): woocommerce-blocks

* Remove hasError state from useGetProduct hook

* Rename isShowLinkedProductControl to showLinkedProductControl

* Convert jsxProductButton to ProductButton component

* Refactor jsxPopoverContent to LinkedProductPopoverContent component

* Improve UI of Linked Product Control

* Address PR feedback

* Fix E2E tests

---------

Co-authored-by: github-actions <github-actions@github.com>

* Rename isUsesReferencePreviewMode to isUsingReferencePreviewMode

* Change order of conditions in getProductCollectionUIStateInEditor

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-09-02 12:39:33 +05:30
Bart Kalisz ff197207ef
Product Collection: Don't render when empty unless the no results block is present (#50404)
* Disable PC render when content empty unless no results block is present

* Introduce empty PC classname

* Add E2E test

* Add changelog entry

* Ensure the render is preserved as expected

* Do not render empty div

* Update tests

* Try a different logic

* Add hint to the docblock

* Remove obsolete e2e test

* Update render handler name to acknowledge context

* Fix tests failing due to recent v3 update

* Restore block interactivity

---------

Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
2024-08-30 08:48:54 +02:00
Alba Rincón 1d21197f77
Hide reviews in the frontend when they are disabled at store or product level (#50979)
* Not show reviews in the frontend when they are disabled at store or product level

* Add tests for single product template

* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce

* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce

* Fix typo

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-08-28 10:01:55 +02:00
Maikel Perez e5c6477a4e
Blocks E2E: Move register product collection tester e2e tests from product collection file to its own file (#50852)
* Move register product collection tester e2e tests from product collection file to its own file

* Add changelog file

* Remove the unstable allTextContents usage

* Remove page.waitForTimeout because it doesn't validate that the button is hidden after exactly 1 second

* Remove page.waitForTimeout from 'Should display properly in Product Catalog template' e2e test

* Let's use one parent describe per file for good practice

* Keeping the structure flat
2024-08-27 09:37:45 -04:00
Albert Juhé Lluveras 1e650d06a9
Add 'Show tab title' attribute to the Product Details block (#50884)
* Add 'Show tab title' attribute to the Product Details block

* Add tests

* Add changelog file

* Linting

* Use editor.selectBlocks() instead of block.click()
2024-08-27 15:10:49 +02:00
Gabriel Manussakis d773bb483a
[Accessibility] Focus coupon input if it has an error (#48738)
* Focus cupon input if it has errors

* Add changelog file

* Add styles to coupon field with error on cart page

* Make coupon errors accessible on the cart page

* Add styles to coupon field with error on checkout page

* Rename coupon variables on cart

* Focus coupon field with error before updating live region on cart page

* Focus coupon field with error before updating live region on checkout page

* Remove incorrect early return

* Update coupon error notice test

* Improve coupon error message semantics

* Fix coupon errors for block based themes

* Update tests to not look for coupon errors on the notice block

* Rename coupon-error-message to coupon-error-notice

* Fix notice if coupon doesn't exist on tests

* FIx invalid coupon notice on classic theme test

* Update test for coupon inline notice

* Fix code formatting

Co-authored-by: Darin Kotter <darin.kotter@gmail.com>

* Fix code formatting

Co-authored-by: Darin Kotter <darin.kotter@gmail.com>

* Fix code formatting

Co-authored-by: Darin Kotter <darin.kotter@gmail.com>

* Fix code formatting

Co-authored-by: Darin Kotter <darin.kotter@gmail.com>

* Don't clear coupon input if code doesn't exist

* Create coupon error notice mixin

* Update coupon error notice styles

* Coupon error notice T19 compatibility

* Coupon error notice T17 compatibility

* Coupon error notice TT1 compatibility

* Coupon error notice TT compatibility

* Coupon error notice TT2 compatibility

* Coupon error notice TT3 compatibility

* Add spaces around paramenters

Co-authored-by: Darin Kotter <darin.kotter@gmail.com>

* Add spaces around paramenters

Co-authored-by: Darin Kotter <darin.kotter@gmail.com>

* Replace $red SCSS variable with a CSS one

* Keep input with the invalid coupon code after notice appears

* Fix typo in comment

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Fix typo in comment

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Break notice message into two lines

* Break if statement into two lines

---------

Co-authored-by: Darin Kotter <darin.kotter@gmail.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
2024-08-23 19:22:28 +01:00
Caleb Mazalevskis b4fd419f74
Fix typos. (#50047) 2024-08-23 18:26:09 +01:00
Maikel Perez c09e45a391
Blocks E2E: Move collections e2e tests from product collection file to its own file (#50853)
* Move collections e2e tests from product collection file to its own file

* Add changelog file
2024-08-23 09:26:38 -04:00
Karol Manijak 2f68f9265b
Fix most of lint warnings (#50869)
* Fix number of lint warnings

* Add changelog

* Improve mocking value

* Fix exports

* Fix mock

* Bring back the empty array hook dependency
2024-08-23 14:30:14 +02:00
Maikel Perez a779788a93
Blocks E2E: Move the inspector controls e2e tests from product collection file to its own file (#50849)
* Move the inspector controls e2e tests from product collection file to its own file

* Add changelog file
2024-08-22 10:55:20 -04:00
Fernando Marichal 771fd00e5d
Featured Product: Fix variable product Selection dropdown (#50633)
* Add hook to SearchListItem

* Add changelog

* Invert is-expanded chevron

* Fix expanded setting

* Fix e2e test

* Add hasChildren and isSelected as dependency
2024-08-20 12:42:35 -03:00
Fernando Marichal ce98e51430
[Filter Products by Price]: Update view when changing the min/max value (#50651)
* Use handlePriceChange method

* Fix E2E test

* Add changelog

* Remove onBlur

* Add select when clicked

* Fix comment

* Add functionality to experimental block

* Fix E2E test
2024-08-20 10:20:09 -03:00
Seghir Nadir 2a406c7e8a
Update all blocks to V3 (#48720)
* Update all blocks to V3

* remove explicit version set in shared config blocks

* update styling for Cart/Checkout in iframe

* test: fix block e2e tests

* test: fix attribute filter e2e tests

* test: fix product collection e2e tests

* test: fix product on sale e2e test

* test: fix rating filter e2e tests

* test: fix review e2e tests

* test: fix stock e2e tests

* test: fix preview button test

* fix: product on sale wrapper

* test: fix insertBlockByShortcut in iframe

* test: fix core e2e tests

* chore: changelog

* test: typo

* test: update PC e2e tests

* add test to make sure iframe canvas is loaded

* fix syntax error

* Update plugins/woocommerce-blocks/tests/e2e/tests/basic.block_theme.spec.ts

Co-authored-by: Bart Kalisz <bartlomiej.kalisz@gmail.com>

---------

Co-authored-by: Tung Du <dinhtungdu@gmail.com>
Co-authored-by: Bart Kalisz <bartlomiej.kalisz@gmail.com>
2024-08-20 10:14:11 +00:00
Adrian Duffell a4fe8a6417
Add visual changes to the blueprint slotfill (#50724) 2024-08-16 18:23:05 +00:00
Adrian Moldovan d7909ecb3c
[e2e tests] Add BuildKite reporter to Blocks e2e tests (#50642) 2024-08-15 13:48:44 +01:00
Mike Jolley a932ceb59f
Fix extensionCartUpdates not surfacing errors to cart and checkout (#49762)
* Add context to type

* Clean up notifyerrors helpers

* Notify and clear top level cart errors

* changelog

* Make extensionCartUpdate surface the errors

* No automatic clearing of notice

* Handle generic errors only, add docs

* Rename param

* Fix linting in readme

* Update toc

* test coverage

* Unused import

* We're only dealing with arrays of errors so simplify logic
2024-08-14 15:24:44 +01:00
DAnn2012 3a363d232b
Fix typo (product-collection.block_theme.spec.ts) (#50154)
Co-authored-by: github-actions <github-actions@github.com>
2024-08-13 12:38:56 +01:00
Karol Manijak 8bdc78c777
Product Collection: Trigger `wc-blocks_product_list_rendered` JS event (#50166)
* Dispatch JS event about PC being rendered

* Revert format changes

* Write the callback

* Add functions descriptions

* Add changelog

* Remove empty line

* Add tests

* Rename test cases

* Replace waiting for page load with more reliable expect.poll

* Remove leftover step

Co-authored-by: Bart Kalisz <bartlomiej.kalisz@gmail.com>

* Fix typo in function name

* Add collection name to default Product Collection block

* Expect collection name in the event

* Expose the collection name through IAPI context

* Send the collection name with the event

* Trigger event also on page change

* Remove unused CUSTOM collection type

* Provide documentation

* Update TOC

* Update tests that verify the event payload

* Improve E2E tests further

* Don't add a Product Catalog collection type to default collection

* Avoid repeating the same piece of code by extracting some function on tag processor

* Rename function to better depict its purpose

* Move the documentation to the right place

* Remove the unused variable

* Add example to dom-events doc

* Update documentation

* Update docs manifest

* Attach default collection name

* Add the default collection context in PHP so it covers all the cases

* Prevent exposing product catalog collection name in event

* Update docs

* Update test

---------

Co-authored-by: Bart Kalisz <bartlomiej.kalisz@gmail.com>
2024-08-13 12:29:04 +02:00
Bart Kalisz 418c8f029f
Product Collection: Remove automatic migration code (#50440)
Co-authored-by: Karol Manijak <20098064+kmanijak@users.noreply.github.com>
2024-08-13 11:29:07 +02:00
Tung Du 70e54f90ca
[Experimental]Attribute Filter: Dynamic title and description. (#50234) 2024-08-09 19:57:40 +07:00
Tung Du aaf3046eb6
[Experimental] Product Filters Redesign: Attribute Filters: List style (#50340)
* update: new simplified markup and style

* add: editor preview

* add: show 15 items initially

* fix: render li class for checked items

* chore: naming

* chore: changelog

* update: set some preview items checked for styling purpose

* fix: only show show more button when the list is long

* chore: lint

* fix: e2e tests
2024-08-09 16:17:14 +07:00
Albert Juhé Lluveras 06b9380ab4
Enable Classic Template tests in the frontend and the Product Attribute template (#49199)
* Enable Classic Template tests in the Product Attribute template

* Reenable and simplify frontend test

* Add changelog file
2024-08-07 12:32:54 +02:00
Adrian Moldovan 4e2c72ec23
[e2e tests] Remove Github reporter (#50256) 2024-08-02 11:38:24 +03:00
Manish Menaria a73c6e5546
Product Collection: Enable Context-Aware Previews by Adding `usesReference` to `registerProductCollection` (#49796)
* Allow registering custom collections with various context references

Implemented the registration of product collections with different context references using the `usesReference` property. These custom collections are now registered with specific contexts such as product, cart, order, and archive.

This enhancement allows for more tailored previews and functionality based on the specific context in which the product collection is used.

* Add changefile(s) from automation for the following project(s): woocommerce-blocks

* Support multiple references for usesReference

* docs: update documentation to include `usesReference`

Enhanced the `register-product-collection` documentation to include details about the new `usesReference` property. This property allows collections to specify required references, enhancing their contextual relevance and preview capabilities.

- Added `usesReference` description to the collection fields section.
- Included examples demonstrating the usage of `usesReference` with single and multiple references.
- Clarified the behavior when required references are unavailable on the editor side but available on the frontend.

This documentation update provides third-party developers with the necessary information to utilize the `usesReference` property effectively in their custom product collections.

* test: add e2e tests for `usesReference`

Added end-to-end tests to verify the functionality of the `usesReference` property in product collections. These tests ensure that the appropriate preview labels are displayed.

- Created multiple custom product collections with different `usesReference` values: `product`, `cart`, `order`, `archive`, and combinations of these.
- Verified that collections show the correct preview label when the required reference is present.
- Ensured that the preview label is not shown in irrelevant contexts, such as posts or product catalog templates.

This addition enhances test coverage and ensures the robustness of the `usesReference` feature.

* Fixed issue with preview label showing in Specific Product and Archive templates.

* Handle cases when termId or productId is 0

This also improves the readability of the code by using better variable names.

* Make PC use postId context so location can be recognised correctly (#50152)

* Fix TS errors

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Karol Manijak <20098064+kmanijak@users.noreply.github.com>
2024-08-01 15:33:27 +05:30
Bart Kalisz 63e212f9ce
Blocks: Update wp-env config to use production WP (#49704) 2024-08-01 11:59:42 +02:00
Tung Du 5ffad9a659
[Experimental]: Update: new title and icon for the Overlay Navigation block (#50011)
* update: rename Navigation block to Overlay Navigation with new icon

* chore: changelog

* chore: use comment instead of update

* reset lock file

* test: update block title

* test: update overlay navigation test
2024-07-31 12:56:53 +07:00
Alexandre Lara ced27dddeb
[Experimental] Product Filters Redesign > Overlay: Replace Product Filters Block with Template Part (#49999)
* Modify Product Filters Overlay template part

* Add changefile(s) from automation for the following project(s): woocommerce

* Add E2E tests for the Product Filters Overlay template part

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-07-29 15:36:53 -03:00
Karol Manijak edc268afa5
Product Collection: sync with current query doesnt display the correct products in the specific category templates (#49889)
* Recognize custom category templates as archive ones

* Disable the preview label if termId is recognized

* Fetch the product category template ID

* Prepare util to properly parse product taxonomies

* Utilise the taxonomies util and update the query accordingly

* Add tests

* Update tests to be more specific

* Improve selectors in E2E test

* Add changelog

* Update selectors

* Fix the order of expected products

* Remove unneceessery entries from array that are covered by another entries

* Rename the variable to beytter depict its purpose
2024-07-29 14:21:44 +02:00
Bart Kalisz d731edc868
Product Collection: Fix max price filter query value inclusion (#49917) 2024-07-29 11:51:26 +02:00
Seghir Nadir 0dcd359b25
Add validation to select fields and add placeholder option to additional fields API (#49929)
* Add validation and empty value to select components

* address feedback

* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce

* remove console log

* Update plugins/woocommerce-blocks/docs/third-party-developers/extensibility/checkout-block/additional-checkout-fields.md

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

* Update plugins/woocommerce-blocks/docs/third-party-developers/extensibility/checkout-block/additional-checkout-fields.md

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

* remove test

* Fix tests

* also move select to parent

* fix tests

* add empty enum to schema

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
2024-07-26 16:38:44 +00:00
Tung Du 234f5d7e49
[Experimental] Attribute Filter: Update Inspector Control Settings (#49751)
* add: new inspector controls

* update: cleanup the edit component

* chore: remove unused old inspector component

* tweak: add formatting to help text

as Jarek said:

> Here’s the copy. Please mind the formatting.

* add: default attribute id that closest to 30

* update: pass the whole attribute object

* update: use default attribute term in Product Filters template

* add: style settings

* add: sorting and show empty behavior in the editor preview

* tweak: use hideEmpty to align with existing settings

* chore: changelog

* test: add basic e2e tests

* chore: restore previous default value

* add: attribute help text and border support

* chore: lint

* fix: add missing context
2024-07-25 09:13:56 +07:00
Alexandre Lara 6000a1e83c
[Experimental] Product Filters Redesign: Create the template part (#49692)
* Add Product Filters template part

* Improve Product Filters template part description

* Hide Product Filters block from the inserter

* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce

* Add E2E tests

* Fix lint error

* Fix lint error

* add: register variation for unmodified template part

We should move this to abstract class later.

* Fix lint error

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2024-07-24 17:36:18 -03:00
Thomas Roberts df8d5b751e
Revert "[Enhancement]: Add option to show price on the place order button" (#49899)
* Revert "[Enhancement]: Add option to show price on the place order button (#4…"

This reverts commit a71fb4d7a6.

* Add changelog
2024-07-24 18:08:05 +02:00
Karol Manijak dace7ba296
Product Collection: add control to toggle whether block is filterable in non archive context (#49627)
* Add syncWithFilters attribute to Product Collection

* Add SycnWithFilters Inspector Control to PC

* Minor import adjustments

* Move the controls to Inherit as they share the same labels

* Rename the attirbute to filterable

* Hide control for collections

* Consume the filterable

* Consume filterable attribute so it enables the filtering

* Bring back file format

* Bring back filterable

* Move filterable from attribute to query

* Improve checks

* Fix incorrent function name

* Add changelog

* Set the default filterable value on insert

* Update test selector

* Add E2E tests to #49627 (#49715)

* Remove unnecessary call to create new post

* Fix "Use page context" control tests

* Fix post ↔ template collection sync test

* Fix non-thenable linter errors

* Extend the "Use page context" default setting test

* Add test for filtering in non-archive context

* Add test for combining editor and front-end filters

* Fix lint

* Update plugins/woocommerce-blocks/assets/js/blocks/product-collection/edit/inspector-controls/inherit-query-control.tsx

Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>

* Improve query properties access

* Rename inherit-query-control to use-page-context-control to better depict its purpose

* Lint fix

---------

Co-authored-by: Bart Kalisz <bartlomiej.kalisz@gmail.com>
Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
2024-07-24 11:51:53 +02:00
Thomas Roberts afe245fdce
Make the address 2 line visible when a value is autofilled (#49730) 2024-07-23 16:44:20 +01:00
Karol Manijak d85acc7e09
Product Collection: allow custom collections hiding each of the filters (#49713)
* Allow hiding all of the filter controls in PC block

* Add new test

* Add changelog

* Update documentation with information about hideControls values
2024-07-23 09:03:27 +02:00
Bart Kalisz 800cf7e9ed
Blocks E2E: Fix DB snapshot removal step in setup script (#49677) 2024-07-19 12:02:56 +02:00
Roy Ho 038ef3d751
[Experimental] Add Product filters overlay settings (#48732)
* Add overlay settings

* Tweak icon size slider

* Add overlay template part link

* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce

* Fix scss linting

* Fix php linting

* Remove preview

* Rename setting props to be more clear

* Remove unused import

* Update plugins/woocommerce-blocks/assets/js/blocks/product-filters/editor.scss

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

* Update plugins/woocommerce-blocks/assets/js/blocks/product-filters/edit.tsx

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

* Update plugins/woocommerce-blocks/assets/js/blocks/product-filters/types.ts

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

* Update plugins/woocommerce-blocks/assets/js/blocks/product-filters/edit.tsx

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

* Move experimental controls to last of list

* Improve typescript code

* Remove unneeded constructor code

* Extract icons into own component

* Moved overlay template part link to the bottom

* Add apply button

* Hide overlay settings when in always mode

* Remove overlay template part from list and put into general area

* Update api version to 3

* Update plugins/woocommerce-blocks/assets/js/icons/library/filter.tsx

Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>

* Update plugins/woocommerce-blocks/assets/js/icons/library/filter-three-lines.tsx

Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>

* Fix overlay button link style and clickable

* Remove edit overlay link from never mode

* Add e2e tests for the filters overlay settings

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
2024-07-18 11:33:25 -07:00
Bart Kalisz 720c1de6bf
Blocks E2E: Refactor Product Collection vs classic template test for stability (#49638) 2024-07-18 15:50:25 +02:00
Alexandre Lara 7dd0c1a055
[Experimental] Product Filters Redesign: Rename individual inner filter blocks to "Filter Options" (#49579)
* Rename blocks to "Filter Options"

* Add changefile(s) from automation for the following project(s): woocommerce-blocks

* Add icon to Filter Options block

* Remove unused import

* Fix e2e tests

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-07-17 11:12:32 -03:00
Bart Kalisz 06374b9691
Blocks E2E: Stabilize Product Collection tests where saving fails (#49590) 2024-07-17 09:50:02 +02:00