Commit Graph

2864 Commits

Author SHA1 Message Date
Calvin Rodrigues 562e791978
Fix minicart icon cursor on hover in site navbar (#46996)
* Fix minicart icon cursor on hover in site navbar

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-06-06 16:54:48 +02:00
Albert Juhé Lluveras f9281ae895
Only load 'productCount' and 'experimentalBlocksEnabled' settings in admin (#48152)
* Only load 'productCount' setting in admin

* Only load 'experimentalBlocksEnabled' setting in admin

* Add changelog file

* Update WcBlocksConfig types
2024-06-05 11:20:35 +02:00
Karol Manijak 7d3309dc6c
Related Products: hide unusable options from Inspector Controls (#47845)
* Hide unusable options from Related Products block

* Add changelog

* Fix the dscription of Single Product template compatibility layer tests

* Add E2E test

* Replace editorUtils with editor in E2E tests

* Fix typo

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

* Fix typo

---------

Co-authored-by: Bart Kalisz <bartlomiej.kalisz@gmail.com>
2024-06-04 11:51:27 +02:00
Alexandre Lara b702fb1288
[Experimental] Product Filters Redesign: Hide individual filter blocks from the Block Inserter (#47526)
* Hide individual filter blocks from the inserter

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

* Adjust E2E tests to check for hidden filters

* Fix file conflict

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: roykho <roykho77@gmail.com>
2024-06-03 12:26:21 -07:00
Lucio Giannotta 45cbc41f65
Move registration of block categories on the server side (#47836)
Previously, we registered block categories on the client-side, leading to them not
being available until client initialization. This meant, for example, that hooking
external blocks to our categories would result in a warning.

With this change, we register the categories server-side, and only update them
on the client-side to attach the SVG icon. This is the recommended approach
in the Gutenberg docs, to make sure we use the SVG primitive, which affords some
accessibility features.
2024-06-03 20:34:41 +02:00
Thomas Roberts bb92392d9f
Apply spacing improvements to the Checkout block (#47565) 2024-06-03 11:18:42 -07:00
Niels Lange 93214eeb2b
[Enhancement]: Block-based checkout input fields style updates (#46362)
* Adjust border and box-shadow color for textual inputs

* WIP: Style checkboxes

* Vertically center checkmark

* Adjust focus outline width

* Adjust selected checkbox background in light mode

* Adjust background color of selected radio button

* Add chevron icon to dropdown fields

* Add changelog

* Fix CSS lint issues

* Adjust outline width

* Revert checkbox styles

* Adjust input field height and label size

* Revert box-shadow styles

* Add spacing between coupon title and coupon code

* Simplify onFocus and onBlur

* Fix outline width when focusing combobox

* Ensure chevron points down after selecting value

* Adjust outline color of focused delivery option

* POC: Use currentColor for focus states
2024-06-03 18:46:08 +07:00
Luigi Teschio 0712c6037b
Add To Cart Form: Improve the default style and add the `Stepper` style (#47664)
* Add To Cart Form: Improve the default style and add the Stepper style

* fix height button when no variation is selected

* not allow the user to set 0 as value of the input

* format css

* fix padding

* format css

* fix CSS

* unset margin to align with the button
2024-05-31 10:25:04 +02:00
Karol Manijak fe30778293
Increase product excerpt default length in Single Product template and block (#47651)
* Increase the length of Product Summary block (core/post-excerpt variation)

* Add changelog

* Bring back the Product Summary variation to original length

* Increase the Product Summary length to max 100 words in Single Product template and block

* Increase the Product Summary length to max 100 words in Single Product block

* Update tests

* Change the attribute type froms tring to niumber as expected
2024-05-31 08:19:06 +02:00
Patricia Hillebrandt 5dd7713346
[Performance]: Replace `classnames` usage with `clsx` (#47760)
* Replace classnames with clsx within woocommerce-blocks.

* Undo unnecessary change to getClassnames const.

* Replace classnames with clsx within woocommerce-admin.

* Add changelog.

* Update the pnpm lock file

* Address lint.

* Address lint errors for the block-library.
2024-05-31 05:49:36 +02:00
Manish Menaria 4bee1547b7
Fix: "On Sale" collection isn't displaying on Editor side (#47994)
* Fix the issue

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

* Add E2E test to cover this regression

* Fix: On sale collection should be visible after refresh in Post

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-30 21:55:49 +05:30
Sam Seay 82f5b84a80
Remove isFeaturePlugin and flag code from FeatureGating class (#47866) 2024-05-30 02:50:09 +12:00
Manish Menaria bb3f38a3d8
Fix: Product Collection block does not display when editing template/post (#47871)
* Fix issue where Product Collection wasn't showing anything

- Moved queryId logic to a new `useQueryId` custom hook to encapsulate the logic.
- Simplified attribute setting in `useEffect` by using a default attributes value.
- Utilized `fastDeepEqual` to check for attribute equality

These changes fix the issue where the Product Collection block did not display properly in the template editor, ensuring consistent rendering of products.

* Add comment

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

* Remove leftover comment

* Add e2e tests for Product Collection block visibility after refresh

Added end-to-end tests to verify the visibility of the Product Collection block after page refresh in both Product Archive and Post contexts.

- Added tests to ensure the Product Collection block remains visible after refreshing the template or post editor.
- Updated existing tests to use `BLOCK_LABELS` for better readability and maintainability.

* Improve E2E tests

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-29 16:35:36 +05:30
Niels Lange dec873926d
Partially revert #45767 (#47867)
* Partially revert #45767

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

* Add test for description on checkout order summary block

* Add another test back in for order summary description

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
2024-05-28 18:25:34 +07:00
Karol Manijak 92fec889f7
Specify Product Price ancestor and simplify Product Elements ancestors (#47802)
* Extend product elements sharedConfig ancestor with Product Collection and Products (Beta)

* Utilise sharedConfig ancestor in Image block

* Utilise sharedConfig ancestor in Price block

* Utilise sharedConfig ancestor in Rating block

* Utilise sharedConfig ancestor in Sale Badge block

* Utilise sharedConfig ancestor in SKU block

* Utilise sharedConfig ancestor in Stock Indicator block

* Add changelog

* Bring back original ancestors for Summary and Title blocks

* Remove Product Price from a test as it's no longer available in global context
2024-05-27 09:15:32 +02:00
Sam Seay 756bb8ccfa
Allow experimental blocks to be enabled WC Admin Features as part of removing WC_BLOCKS_PHASE (#47701) 2024-05-25 00:13:24 +12:00
Alexandre Lara 5d645d94e6
Product Gallery block: Fix error on revisiting template without reloading the page (#47636)
* Detect template ID from URL

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

* Add E2E test to check if block is displayed after revisiting Single Product template

* Fix E2E tests

* Fix E2E tests

* Fix lint error

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-23 13:39:31 -03:00
Karol Manijak c318bf50f8
Fix incompability of Query Pagination block with Product Collection (#47749)
* Amend Query Pagination parent OR ancestor array and include product collection

* Rename the function and amend comment

* Add changelog

* Remove some leftovers

* Tets if it's possible to insert multiple Pagination blocks in Product Collection

* Add awaits to expects

* Update plugins/woocommerce-blocks/assets/js/blocks/product-collection/utils.tsx

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

* Add comment explaining the condition

---------

Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
2024-05-23 13:01:57 +02:00
Seghir Nadir 34f8c65f53
only make order summary sticky when it's not longer than view (#47680)
* only sticky summary when it's not longer than view

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

* fix tests

* correctly check for height

* switch how to get top

* remove from editor

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-22 22:09:50 +00:00
Seghir Nadir 6c136e4e1a
normalize IDs for form fields in Checkout (#47650)
* normalize IDs for form fields and fix types

* update docs as well

* update rest of docs

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

* fix linting for document

* also align classnames

* revert to correct classname

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-22 22:54:03 +02:00
Seghir Nadir d2ac6ff953
Correctly attribute focus back when opening the mini cart several times (#47683)
* allow focusedOnMount element to be reset

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-22 17:03:22 +02:00
Thomas Roberts b7643b9b7a
Change Checkout form step numbering so it can only be toggled for all blocks, not individually per-step (#47479) 2024-05-22 07:03:48 -07:00
Karol Manijak f55e25b009
Filter by Attribute: fix potential reading property of undefined error (#47699)
* Fix reading from undefined error in attribute-filter

* Add changelog
2024-05-22 11:57:53 +02:00
Karol Manijak 313ab0eb74
Rename classic template blocks to avoid confusion (#44931)
* Rename  blocks to  to distinguish them from new blocks

* Add changelog

* Change the naming convention to XYZ (Classic)

* Update classic templates descriptions

* Fix package.json lint error
2024-05-22 10:53:43 +02:00
Alba Rincón 1d0ec79d43
Use the term attribute sort order for the "Filter by attribute" block (#47616)
* Use the term attribute sort order for the "Filter by attribute" block

* Allow `id` and `name_num` orderby values

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-21 15:44:08 +02:00
Niels Lange 5168a21920
Block-based checkout - Update address fields display logic (#47160)
* Add “Address line 2” toggle

* Allow apartment field to be required

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

* Rename “Apartment, suite, etc.” to “Address line 2”

* Remove unused dependency

* Add key to fragment

* Simplify keys

* Address failing e2e tests

* Change “Optional (Recommended)” to “Optional”

* Toggle address line 2 visibility in editor

* Add e2e tests

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

* Update e2e tests

* Update e2e tests

* Ensure the address 2 field stays open when the seller empties it

* Optimise hasAddress2FieldValue

* Move address 2 filed related functionality into separate component

* Rmove + sign from address 2 field links

* WIP: Introduce AddressField component

* Update AddressFields component

* Refactor AddressFields and Address2Field components

* Fix CSS lint error

* Fix JS lint error

* Fix failing e2e tests

* Fix typo in e2e tests

* Improve e2e selector

* Fix core e2e tests

* Use address line 2 label for the link text

* Lazy initialise the “isFieldVisible” state

* Remove obsolete code

* Add inline comments for clarity

* Fix JS lint error

* Improve e2e tests

* Revert "Remove obsolete code"

This reverts commit 027d6adc89.

* Adjust visibility toggle

* Delete obsolete changelog file

* Add inline comment

* Fix TS error

* Remove obsolete parts

* Solve TS warning

* Remove obsolete “fieldsRef”

* Remove obsolete “setHasFieldBeenModified”

* Address various TS warnings

* Fix link styling issue on mobile

* Fix JS lint error

* Refactor and simplify address components

* Optimise Address2Field component

* Improve inline docs

* Move ‘+’ from CSS to i18n

* Rename rest of values and pass correct onChange

* force component to remount

* remove unsed useEffect

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
2024-05-21 15:48:24 +07:00
Karol Manijak 929564da82
Product Collection: remove Beta label (#47572)
* Remove Beta label from Product Collection

* Remove unnecessary dependency in Product Collection page object

* Add changelog

* Udpate block references
2024-05-21 08:36:40 +02:00
Ilyas Foo 7c1802fefa
Update coming soon pages to use cardo and inter fonts via editor (#47613)
* Add type safety, update coming soon entire site changes for fonts

* Add conditional font to support TT24 and other themes

* Revert unnecessary change

* Changelog

* Lint
2024-05-21 13:35:12 +08:00
Manish Menaria 3a3a386e34
Fix: Product Collection block should respects 'Out of stock visibility' setting (#47537)
* Fix: Ensure Product Collection Block Respects "Hide Out of Stock Items" Setting

- Added logic to include the "Out of stock visibility" setting in the Product Collection block.
- Modified `ProductTemplateEdit` component to use the `getDefaultStockStatuses` function.
- Ensured that out-of-stock products are hidden in the Product Collection block when the "Hide out of stock items from the catalog" option is enabled.

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-21 10:50:05 +05:30
Thomas Roberts d7ca80d6c8
Make shipping total in Cart/Checkout block order summaries show FREE if shipping price is 0 (#47553)
* Make shipping total show FREE if price is 0

* Make free text uppercase in order summary

* Add test to check free/paid shipping displays as free or shows price

* Add changelog

* Update E2E test to make sure shipping is selected correctly

* Update shipping cost e2e tests

* Further fixes to e2e tests
2024-05-20 18:42:54 +02:00
Seghir Nadir 1ae7ca5179
Make checkout sidebar (order summary) sticky on desktop (#47376)
* Make sidebar sticky on desktop

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

* limit sidebar sticky to cart only

* add useless new line

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-17 13:13:01 +02:00
Seghir Nadir edb930e04b
Fix a11y issues in Cart/Checkout (#47470)
* return focus on drawer

* adjust notice button color

* adjust cart/checkout input label color

* return focus for shipping form button

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-16 18:32:22 +02:00
Seghir Nadir 4f348eb540
remove the generic incompatible notice from Checkout block. (#47475)
* remove the generic incompatible notice

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-16 16:52:06 +02:00
Seghir Nadir 9b1e9344e0
Turn Cart change address link to button (#47460)
* Turn Change address link to button

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

* fix lint

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-16 16:51:03 +02:00
Sam Seay fcc421d550
Update cart/checkout usage of the @wordpress/components Slot Fill (#47105) 2024-05-16 21:46:24 +12:00
Manish Menaria a7a1264fec
Fix input clearing issue in PriceTextField with improved currency parsing (#47354)
* Fix input clearing issue in PriceTextField with improved currency parsing

This commit addresses a usability issue in the PriceTextField component, highlighted by @dinhtungdu, where the input field would clear itself if users omitted a space between the numeric value and the currency symbol when the currency is configured to appear on the right with a space (e.g., "20$" instead of "20 $"). The problem was rooted in the strict parsing logic that did not account for variations in user input related to currency formatting.

The fix involves an enhancement to the numeric parsing function, which now effectively handles various user inputs regardless of space or placement of the currency symbol. The revised parsing logic uses a regular expression to strip out any characters that are not numeric or the designated decimal separator, and then replaces the locale-specific decimal separator with a period for standard numeric conversion. This approach not only fixes the specific issue but also improves the robustness of the component against similar input variations.

* Refactor currency parsing and improve handling in PriceTextField

1. Renaming `formatValueAsCurrency` to `formatNumberAsCurrency` to better
   reflect its functionality.
2. Moving the `convertCurrencyStringToNumber` function outside of the
   PriceTextField component, enhancing readability and reusability.
3. Changing the internal state handling from `newValue` to `inputValue`,
   directly managing the string input and parsing it as needed for further
   processing. This will force input field to re-render.

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

* Fix: Handle empty string in price conversion to prevent 0 value

This commit fixes an issue where an empty string in the price conversion function resulted in a value of 0. Now, empty strings are properly handled and do not convert to a numerical value.

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-16 13:23:47 +05:30
Manish Menaria 1233fb4745
Fix: handle undefined templateSlug in Product Collection tracking utils (#47504)
* fix: handle undefined templateSlug in Product Collection tracking utils

The modification introduces a check for templateSlug before attempting to access its properties or use it in further logic. This change addresses a bug that manifested when users tried to edit a synchronized Product Collection block, resulting in a JavaScript error because templateSlug could be undefined.

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

* Update types to better reflect reality

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Karol Manijak <20098064+kmanijak@users.noreply.github.com>
2024-05-16 11:17:52 +05:30
Chi-Hsuan Huang a120b99d7d
Fix coming soon page mobile UI issues (#47491)
* Update styles for WooCommerce coming soon page

- Add min-width to container for better responsiveness
- Adjust padding for smaller screens
- Update font size and text wrapping for banner

* Add changelog

* Improve readability
2024-05-16 12:46:26 +08:00
Alexandre Lara 7abb996017
[Experimental] Product Filters Redesign: Add the Product Filters block (#47294)
* Add Product Filters block

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

* Add the blocks template for the Product Filters block

* Dynamically add the highest product count attribute to the block template

* wip: Add E2E tests for the Product Filters block

* Add E2E tests for the Product Filters block

* Add CSS file to Product Filters block

* Fix css error lint

* Fix lint error

* Fix lint errors

* Remove unnecessary styles for the Product Filters block

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-15 18:09:48 -03:00
Sam Seay 3ef7a01840
Update blocks JS tests to React 18 (#47383) 2024-05-15 21:33:36 +12:00
Manish Menaria 9f5f93cba6
Product Collection: Implement Preview Mode (#46369)
* POC: Preview Mode using HOC

* Add explanation as comments

POC: Implement preview mode for Product Collection block in editor
- Added extensive commentary to clarify the mechanism and usage of the `handlePreviewState` function
- Implemented an internal state within `ProductCollectionContent` to manage preview status and messages, serving as a foundational example of how preview mode can enrich block functionality.
- Showcased the application of `handlePreviewState` by incorporating it as a prop in `BlockEdit`, illustrating the potential for extending the block's capabilities for dynamic and interactive previews.

This POC demonstrates a flexible approach to managing preview states within the editor, paving the way for further development and integration based on feedback and use-case analysis.

* Refactor preview state handling and collection registration

This commit introduces a centralized approach for registering product collection variations and managing their preview states. It abstracts the registration logic into a dedicated function and enhances the flexibility of preview state handling across different collection types.

* Rename file

* Minor improvements

* Don't pass previewState to handlePreviewState

I don't see any good use of it in handlePreviewState. Also, We will be going to call handlePreviewState only once
therefore, it will always have the same value as the initial value of the previewState. If in future, we decide to run it
multiple times then we can pass the previewState as an argument to handlePreviewState.

* Add comment

* Use JS closure to inject handlePreviewState

This commit introduces a refined approach for injecting the `handlePreviewState` function into product collection blocks, utilizing JavaScript closures to streamline the process. This method replaces the previous global registry mechanism, offering a more direct and efficient way to manage preview states.

Advantages of This Approach:
- Utilizing JavaScript closures for injecting `handlePreviewState` simplifies the overall architecture by directly modifying block edit components without relying on an external registry. This method enhances code clarity and reduces the cognitive load for developers.
- The conditional application of `withHandlePreviewState` ensures that the preview state handling logic is only added to blocks that require it, optimizing performance and maintainability.

* Refactor preview state management into custom hook

This commit enhances the organization and readability of the product collection content component by abstracting the preview state management into a custom hook named `usePreviewState`. This change streamlines the component's structure and aligns with React best practices for managing state and side effects.

Key Changes:
- Introduced `usePreviewState`, a custom hook responsible for initializing and managing the preview state (`isPreview` and `previewMessage`) of the product collection block. This hook encapsulates the state logic and its side effects, including the conditional invocation of `handlePreviewState`.
- Modified `ProductCollectionContent` to utilize `usePreviewState` for handling its preview state. This adjustment makes the component cleaner and focuses it more on presentation and behavior rather than state management details.

* Replace useEffect with useLayoutEffect

* Add cleanup function in handlePreviewState function

Based on [this discussion](https://github.com/woocommerce/woocommerce/pull/45703#discussion_r1535323883), I added a cleanup function support for handlePreviewState. `handlePreviewState` can return a function which will be called on cleanup in `useLayoutEffect` hook.

* Fetching random products in Preview mode

* Allow collection to set initial preview state

* Pass location & all attributes to handlePreviewState function

* Handling collection specific query for preview mode

- Consolidated `handlePreviewState` and `initialPreviewState` into a single `preview` prop in `register-product-collection.tsx` and `product-collection-content.tsx` to streamline prop passing and improve the component interface.
- Updated the `queryContextIncludes` in `constants.ts` to include 'previewState'
- Enhanced the `ProductCollection` PHP class to handle preview-specific queries more effectively, introducing a new method `get_preview_query_args` that adjusts query parameters based on the collection being previewed, thereby improving the relevance and accuracy of products displayed in preview mode.

* Always set initialPreviewState on load

* Refine preview state handling

- Renamed `HandlePreviewStateArgs` to `SetPreviewStateArgs` in `featured.tsx` to better reflect its purpose, which is now more focused on setting rather than handling states. The implementation details within `featured.tsx` have also been refined to include async operations and cleanup functions, demonstrating a more sophisticated approach to managing state.

Overall, these updates make the preview state logic more understandable and maintainable.

* Rename "initialState" to "initialPreviewState"

* Fix: Correct merging of newPreviewState into previewState attribute

This commit addresses an issue in the product-collection-content.tsx where the newPreviewState was not properly merged into the existing previewState attribute. Previously, the spread operator was incorrectly applied, leading to potential loss of existing state attributes. By changing the order of operations and correctly spreading the existing attributes before merging the newPreviewState, we ensure that all state attributes are preserved and updated correctly.

* Initial refactor POC code to productionize it

* Move `useSetPreviewState` to Utils

* Implement preview mode for Generic archive templates

Implemented a new useLayoutEffect in `utils.tsx` to dynamically set a preview message in the editor for product collection blocks located in generic archive templates (like Products by Category, Products by Tag, or Products by Attribute).

* Remove preview mode from Featured and On sale collection

* Remove preview query modfication for On Sale collection

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

* Fix: hide/show preview label based on value of "inherit"

If user change the toggle "Sync with current query", then it should reflect for the preview label as well.
- If the toggle is on, then the preview label should be shown.
- If the toggle is off, then the preview label should be hidden.

* Minor improvements

* 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

* Refactor: Simplify SetPreviewState type definition in types.ts

This commit refines the SetPreviewState type definition by eliminating the previously used intermediate interface, SetPreviewStateArgs. The change streamlines the type definition directly within the SetPreviewState type, enhancing readability and reducing redundancy.

* Update import syntax for ElementType in register-product-collection.tsx

This commit updates the import statement for `ElementType` from `@wordpress/element` to use the more modern and concise `import type` syntax. This change does not affect functionality but aligns with TypeScript best practices for importing types, ensuring that type imports are distinguished from regular imports. This helps in clarity and in optimizing the build process by explicitly indicating that `ElementType` is used solely for type checking and not included in the JavaScript runtime.

* Refactor: Update TypeScript usage in Product Collection

This commit introduces several TypeScript refinements across product-collection components:

1. **DEFAULT_ATTRIBUTES** in `constants.ts` now uses `Pick` to explicitly define its shape, ensuring only relevant attributes are included and typed accurately.
2. **ProductCollectionAdvancedInspectorControls** and **ToolbarControls** in the `edit` subdirectory now use `Omit` to exclude the 'preview' property from props, clarifying the intended prop usage and improving type safety.

These changes collectively tighten the type definitions and improve the codebase's adherence to best practices in TypeScript.

* Refactor: Update dependencies of useSetPreviewState hook in utils.tsx

This change enhances the stability and predictability of the hook's behavior, ensuring it updates its internal state accurately when its dependencies change, thus aligning with best practices in React development.

* Refactor preview button CSS and conditional rendering

1. **CSS Refactoring:** Moved the positioning styles of the `.wc-block-product-collection__preview-button` from inline styles in the JSX to the `editor.scss` file. This separation of concerns improves maintainability and readability, aligning the styling responsibilities solely within the CSS file.
2. **Conditional Rendering Logic:** Updated the rendering condition for the preview button. Now, it not only checks if `isPreview` is true but also if the block is currently selected (`props.isSelected`). This prevents the preview button from appearing when the block is not actively selected, reducing visual clutter and enhancing the user experience in the editor.

* Enhance: Update preview button visibility logic in ProductCollectionContent

This commit enhances the visibility logic of the preview button in the `ProductCollectionContent` component:

1. **Added `isSelectedOrInnerBlockSelected`:** Introduced a new `useSelect` hook to determine if the current block or any of its inner blocks are selected. This ensures that the preview button is visible when either the product collection block or any of its inner blocks are selected.
2. **Updated Conditional Rendering:** Adjusted the conditional rendering of the preview button to use the new `isSelectedOrInnerBlockSelected` value, providing a more intuitive user experience by ensuring the preview button remains visible when any relevant block is selected.

* use __private prefix with attribute name

* Add E2E tests for Preview Mode

1. **Template-Specific Tests:** Each template (tag, category, attribute) undergoes a test to ensure the preview button behaves as expected when replacing products with product collections in these contexts.
2. **Visibility Checks:** The tests verify that the preview button is visible when the block or its inner blocks are selected and hidden when the block is not selected. This helps confirm the correct implementation of the preview button visibility logic across different use cases.
3. **Interaction with Inner Blocks:** Additional checks are included to ensure the preview button's visibility toggles appropriately when interacting with inner blocks, reinforcing the dynamic nature of block selection and its effect on UI elements within the editor.

* Add setPreviewState to dependencies

* Add data-test-id to Preview button and update e2e locator

Modifications:
- Added `data-test-id="product-collection-preview-button"` to the Preview button in `product-collection-content.tsx`.
- Updated the corresponding e2e test locator in `product-collection.block_theme.side_effects.spec.ts` to use the new `data-test-id` instead of the class name.

By using `data-test-id`, we ensure that the e2e tests are not affected by changes in the styling or restructuring of the DOM that might alter CSS classes but do not affect functionality.

* Enhance: Localize preview message in useSetPreviewState hook

* Don't show shadow & outline on focus

* Make preview button font same as Admin

* Fix SCSS lint errors

* Add missing await keyword

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-15 13:18:43 +05:30
Thomas Roberts 35f07934a4
Remove bold text from selected payment method in Checkout block (#47412) 2024-05-14 02:00:30 -07:00
Karol Manijak bf2d622a66
Product Collection: telemetry for filter usage (#46545)
* Create trackInteraction function and pass it to query Insprector Controls

* Add tracking to Attribute filter

* Add tracking to Created filter

* Add tracking to Featured filter

* Add tracking to Handpicked Products filter

* Add tracking to Inherit Query filter

* Add tracking to Keyqord filter

* Add tracking to On Sale filter

* Add tracking to Order By option

* Add tracking to Stock Statusoption

* Add tracking to Price Range filter

* Add tracking to Taxonomies filter

* Fix lint errors

* Add changelog

* Rearrange the logic of recognising the tracks location so it's more reliable
2024-05-14 09:45:33 +02:00
Christopher Allford b8aabe9005
Fixed Taxonomy Term Limit On Product Collection Filters (#47155)
In the interest of avoiding pagination this refactor swaps the current term loading with one that doesn't require a cache of all terms. We've removed the need for the cache by storing the ID and term name together in the token/suggestion list and using a display transformation to hide any unnecessary information.
2024-05-13 16:00:24 -07:00
Roy Ho f5dc46a385
Product Filters: add individual clear button (#47101)
* Product Filters: add individual clear button

* Remove unused style.scss

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

* Simplify searching for the tag

* Convert to use button instead of anchor

* Try using iAPI to show/hide clear button

* Use local context instead of global state

* Fix linting error

* Remove unneeded context

* Update clear button block description

* Fix frontend PHP error

* Add e2e tests for attributes filter clear button

* Add e2e tests for price filter clear button

* Add e2e tests for rating filter clear button

* Add e2e tests for stock status filter clear button

* Address feedback and use built in locators

* Address feedback and replace the use of timeouts

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-13 15:19:56 -03:00
Seghir Nadir b5850bbfc1
Select a shipping rate after they load (#47120)
* select a shipping rate if there are no shipping rates on mount

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

* move code and explain it

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-13 15:29:04 +00:00
Seghir Nadir b256336176
reset state and postcode if it's not valid for the current country (#47369)
* reset state if it's not valid for the current country

* reset postcode as well

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

* update logic so its in Checkout block instead of store api

* fix linting

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-13 16:46:08 +02:00
Seghir Nadir 76a9e2eb27
Move country to top of form for all countries (#47375)
* Move country to top of form for all countries

* adjust styling

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-13 16:24:40 +02:00
Niels Lange e7aff9428f
[Enhancement]: Block-based checkout - Pickup section updates (#47173)
* Change “Pickup options” to “Pickup locations”

* Always show pickup location and truncate pickup details

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

* Adjust spacing between pickup details and more link

* Hide pickup details of unselected pickup location

* Adjust line height of truncated text

* Show “Read more/less” instead of “more/less”

* Ensure both lines are equally filled with text

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-08 17:58:09 +07:00
Niels Lange 99bed6d7ba
Display price in place order button (#47083)
* WIP: Display price in place order button

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

* Fix JS lint error

* Update e2e tests

* Display default place order button including placeholder in page editor

* Update plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-actions-block/constants.tsx

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

* Optimise i18n using sprintf

* Wrap cart totals in “useSelect”

* Temporary skip failing e2e test

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2024-05-08 16:18:48 +07:00
Niels Lange b6d9b3a013
Fix broken checkout address forms layout (#47131)
* Fix broken checkout address forms layout

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-08 10:30:12 +07:00
Sam Seay a8be4f3330
Checkout: fix a bug where the local pickup / shipping buttons are rendered incorrectly in the editor (#47157) 2024-05-06 20:57:52 +12:00
Luigi Teschio 2d87573a76
Product Reviews: not use useBlockProps twice (#47136)
* Product Reviews: not use useBlockProps twice

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-06 10:13:53 +02:00
ianlv 6ff0463f24
chore: remove repetitive words (#47158)
* chore: remove repetitive words

Signed-off-by: ianlv <sunlvyun@outlook.com>

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

---------

Signed-off-by: ianlv <sunlvyun@outlook.com>
Co-authored-by: github-actions <github-actions@github.com>
2024-05-06 03:43:39 +00:00
Luigi Teschio e750b0ff3a
Product Details: not use `useBlockProps` twice (#46785)
* Product Details: not use  twice

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-05-03 10:21:06 +02:00
Sam Seay 3a5721c0d8
Replace @wordpress/components Button, Radio, RadioGroup with Ariakit Button (#45974) 2024-05-03 15:28:39 +12:00
Niels Lange 1d93ba0b6a
Block-based checkout - Shipping section changes (#46083)
* Refactor shipping sections

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

* Refactor various files and adjust e2e tests

* Display expected styles for “Ship” and “Pickup” in the page editor

* Use exact selector

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-04-30 19:59:03 +07:00
Ilyas Foo 35c50ebdb4
Try wrapping entire coming soon page under cover block to fix layout issue (#46914)
* Refactor to wrap everything under cover block

* Changelog

* Cleanup and fix classic theme

* Wrap center with stack for ease of adding elements nearby

* Update styles

* Fix dynamic background color

* Style clean up
2024-04-30 16:56:59 +08:00
Sam Seay 1e225f701f
Add aria label to the customer account block link (#46899) 2024-04-29 13:35:47 +12:00
Paul Sealock d5d25d3bfe
[LYS] Comin soon block - Refactor and hide Styles block on Store Only (#46854) 2024-04-26 16:43:08 +12:00
Alex Florisca 7dc8dd63ba
Update Order Summary Design (#45767)
* Add border around order summary on cart & checkout

* Group subtotal, discount, fees, taxes and shiping block

* Move the coupon form in order summary

* Move the coupon form in order summary

* Manage state externally in Panel component and refactor Coupon form to use the Panel component

* Remove descriptions from order summary items

* increase font weight of order summary title

* Tidy up design for desktop and add separator back in for blocks on checkout order summary

* Remove border around order summary on mobile

* Revert "Move the coupon form in order summary"

This reverts commit 4a8044cdcf.

* Change heading styles for cart

* Change font weight to 500 of order summary heading on checkout block

* Remove padding and border between order summary totals items

* Refactor css for cart & checkout totals to work in the editor

* Adjust cart totals heading in the editor

* Last adjustment to checkout totals style to work in editor

* Add changelog

* Change the cursor to pointer for the panel component

* remove unused short and full description from OrderSummaryItem

* Fix failing e2e tests

* Fix lint issues

* Vertically align order summary title in the editor

* Fix e2e tests

* Fix linting issues

* Fix unit tests

* Remove changes from woocommerce.php

* Fix checkout block test

* fix eslint errors in checkout block test

---------

Co-authored-by: Niels Lange <info@nielslange.de>
2024-04-25 12:03:31 +07:00
Seghir Nadir 742cbbda9d
Graduate Additional Fields to stable and rename it. (#46805)
* graduate woocommerce_blocks_register_checkout_field

* graduate filters

* Migrate Additional to Order and Other

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

* fix markdown lint

* update tests to use old value

* fix lint issue

* pass field options by reference

* update test helpers

* update tests to use latest api

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-04-23 16:47:32 +02:00
Paul Sealock b9a1b67991
[LYS] Reapply styles from 46619 (#46813)
* copy styles over from 46619

* Fix header padding

* login/out

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

* typo

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-04-23 19:26:35 +12:00
Paul Sealock 89c330f03e
[Launch Your Store] Use Block to handle template styles (#46751) 2024-04-23 16:07:56 +12:00
Leif Singer d1be68b88c
Update @woo.com email addresses to @woocommerce.com (#46387)
* update @woo.com email addresses

* update %40woo.com email address

* add changelog file

* update docs manifest
2024-04-19 21:11:01 +00:00
Thomas Roberts 9e0fab4ebc
Reset shipping rate font size to match other elements (#46345) 2024-04-17 13:54:43 -07:00
Alex Florisca 3089b1888e
Refactor the Order Summary of the Cart & Checkout blocks (#46386)
* Added new OrderSummaryTotals Block

* Refactor order summary and totals block to contain the inner children

* Add migration for Order Summary Block

* Migration to handle older order summary without totals block

* Remove empty lines from order summary migration

* block editor migration for order summary

* Fix isEligible function

* Update Totals title

* Add checkout totals

* Remove echos and dies

* replace individual checkout blocks with totals block

* Change parent of totals inner blocks and add totals block to innerBlockAreas map

* change CART_ORDER_SUMMARY_TOTALS to CHECKOUT_ORDER_SUMMARY_TOTALS

* Fix linting issues

* fix lint warnings

* Add  changelog

* Lock movement of the taxes block in attributes.tsx

* Less indentation in the render function of CartOrderSummaryBlock and CheckoutOrderSummaryBlock

* Rename webpack chunkName for order summary totals
2024-04-17 10:28:30 +01:00
Thomas Roberts ab60527d6b
Update `PackageRates` component to show single rates as a radio button (#46284)
* Show a single shipping option as radio button

* Add changelog

* Update unused dependency
2024-04-16 13:39:55 +01:00
Thomas Roberts fb481bdce5
Increase shipping/payment borders to prevent half pixel issues on high-resolution screens (#46525)
* Replace pixel box shadow with em to prevent half pixels

* Add changelog

* Apply 2px border

* Make padding around shipping options bigger
2024-04-16 09:50:54 +01:00
Wesley Rosa fed46ed1e7
Adding support for co-branded credit cards (#45903) 2024-04-15 22:59:05 +01:00
Karol Manijak 7efd3d4652
Product Collection: break taxonomies filter into multiple menu items per each taxonomy (#46160)
* Split taxonomies filter into seperate filter per taxonomy

* Add changelog

* Improve onDeselect function

* Update tests

* Fix lint

* Satisfy TS by returning single React element rather than array of elements

* Remove unused variable
2024-04-11 08:13:42 +02:00
Roy Ho deef144a43
Add translation context to ambiguous words (#46382)
* Add translation context to ambiguous words

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-04-10 06:17:14 -07:00
Thomas Roberts 255a45911c
Update shipping and payment radio controls to use borders on selected items (#46150) 2024-04-10 02:54:05 -07:00
Thomas Roberts e111784e60
Ensure local pickup "enabled" setting is read correctly on client-side (#46334)
Co-authored-by: Niels Lange <info@nielslange.de>
2024-04-09 06:31:04 -07:00
Leif Singer 8ee74ede0e
Update Woo.com references to WooCommerce.com (#46259)
* replace capitalized Woo.com with WooCommerce.com

* replace http URLs

* replace https URLs

* replace developer.woo.com

* add missing version in `@since` tag

* unslash the HTTP_REFERER

* WordPress.Security.ValidatedSanitizedInput.InputNotSanitized

* add changelog file

* add more changelog files

* address linter errors

* address more linter errors

* fix test

* more linter errors
2024-04-09 09:50:15 +01:00
Sam Seay 803a62c50a
Remove all references to the product add to cart block. (#46220) 2024-04-09 14:01:32 +12:00
Thomas Roberts 9f159f7141
Use address format from server in address card (#45852) 2024-04-08 01:43:42 -07:00
Sam Seay f9c4b284ce
Remove the base tabs component from blocks. It is no longer used. (#46219) 2024-04-06 15:03:07 +13:00
Tung Du 11ec7c6255
Fix: broken contract in StoreAPI ProductCollectionData endpoint (#45247)
* revert: use original implementation

* fix: price query clause

* chore: changelog

* fix: passing full query state to get the correct count and avoid cache issue

* Replace references to woo-gutenberg-products-block

* fix php cs error

* fix php cs error

* Fix e2e tests for attributes count

* Separated out and/or query type tests for attrs count

---------

Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
Co-authored-by: roykho <roykho77@gmail.com>
2024-04-05 15:50:19 -03:00
Karol Manijak 0c1e4efc89
Rename the "other" location from `generic` to `site` (#46228)
* Rename the useGetLocation generic option to site

* Add changelog

* Adjust tests to change
2024-04-05 15:54:56 +02:00
Karol Manijak 1c4b793f06
Product Collection: fix "Reset All" button in Editor filters (#46226)
* Add deselect callabck to attribute filter

* Add deselect callabck to created filter

* Add deselect callabck to featured filter

* Add deselect callabck to handpicked filter

* Cleanup deselect callabck to keyword filter

* Add deselect callabck to on salefilter

* Add deselect callabck to order by option

* Add deselect callabck to stock status filter

* Add deselect callabck to price range filter

* Add deselect callabck to price taxonomies filter

* Call all the reset filer callbacks on reset

* Add changelog

* Remove unused variable

* Replace hardcoded default filter values with the DEFAULT_FILTERS constant
2024-04-05 13:16:00 +02:00
Karol Manijak 92e99d4cad
Product Collection: telemetry choosing collection (#45827)
* Use templateSlug context in Product Collection

* Implement util recognising the location for track events

* Implement the track event when user chooses a collection in Product Collection

* Add changelog

* Remove incorrect import

* Cover cases with specific Product or Specific Taxonomy

* Update event name

* Adjust Product Filters tests

* Revert wrong commit
2024-04-02 14:12:20 +02:00
Thomas Roberts 893c7ddb04
Sync Local Pickup title between Checkout block and shipping settings UI and vice/versa (#45720) 2024-04-02 11:34:32 +00:00
Karol Manijak 1f49f712b5
Unify Product Elements inserter category to "WooCommerce Product Elements" (#46064)
* Unify the category for all Product Elements

* Add changelog

* Bring back category to product elements that don't use shared confiug

* Add specific category to some Product Elements blocks registered only for Single Product template
2024-04-02 13:04:13 +02:00
Karol Manijak 5d47c769a4
Recognise if Product Collection is located inside Cart or Checkout blocks (#46059)
* Recognise if Product Collection is inside Cart or Checkout blocks

* Upgrade priority block recognition over templates

* Update the comments to better depict the flow

* Add changelog

* Simplify the logic
2024-04-02 09:05:17 +02:00
Manish Menaria a1a0128904
Product Collection: fetch all products for hand-picked products control (#45931)
* Fetch all products for hand-picked products control

This commit modifies the `getProducts` function usage within the Hand-Picked Products control, aiming to fetch all products regardless of catalog size.

The change involves explicitly setting `queryArgs` to include `per_page: 0` in the function call. This adjustment overrides the default behavior based on the `isLargeCatalog` condition, ensuring that all available products are fetched from the Store API for selection within the control.

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-04-01 14:17:12 +05:30
Roy Ho e3b1dd6a10
Remove clickable cursor on post title (#45998)
* Remove clickable cursor on post title

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

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

Co-authored-by: Karol Manijak <20098064+kmanijak@users.noreply.github.com>

* Add missing semicolon

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Karol Manijak <20098064+kmanijak@users.noreply.github.com>
2024-03-29 08:35:01 -07:00
Niels Lange cad1aa6c2b
Ensure that each <CheckboxControl> component has a unique ID (#45655)
* Ensure that each <CheckboxControl> component has a unique id

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

* Optimise setup and teardown settings

* Wrapping setup and teardown in act()

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-03-29 12:46:13 +01:00
Thomas Roberts dbf0938fdd
Fix styling bug with saved payment methods in Checkout block (#46019) 2024-03-29 02:30:55 -07:00
Tom Cafferkey 271da399cc
Customer Account block: Remove margin-left from label (#45934)
Co-authored-by: github-actions <github-actions@github.com>
2024-03-27 10:24:11 +00:00
Tom Cafferkey 0cb3b4a9ad
Block Hooks API: Add CustomerAccount block to header (#43267)
Co-authored-by: github-actions <github-actions@github.com>
2024-03-26 08:38:06 +00:00
Alexandre Lara 207a5b43d2
Single Product Block: Add missing allowed inner blocks to fix nesting placement restrictions (#45530)
* Add missing allowed inner blocks to Single Product block

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

* Remove unnecessary attribute from Single Product block template

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-03-25 10:59:57 -03:00
Seghir Nadir 401737994f
Use state name in Checkout block address card (#45799)
* Use state name in address card

* fix linting issue

* remove extra check for checkout endpoint

* address review feedback
2024-03-22 15:14:14 +01:00
Manish Menaria ca7aed0a95
Product Collection: Don't show publicly non-queryable taxonomies (#45781)
* Don't show publicly non-queryable taxonomies

The main enhancement involves adding a visibility filter to the taxonomies query. Now, the query considers the `publicly_queryable` property of each taxonomy. Only taxonomies marked as publicly queryable are included in the final list returned by the `useTaxonomies` hook. This change ensures that the Product Collection block's taxonomy controls only display taxonomies relevant and accessible to the public, enhancing both the usability for content creators and the relevance of taxonomy selections for site visitors.

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-03-22 15:01:58 +05:30
Christopher Allford b8bd480faf
Ensure Product Collection Block's `queryId` Uniqueness (#44522)
Since we don't need it to be _perfectly_ stable,
we can just set the `queryId` to the instance ID
on every component mounting. This is fine and
won't mark the attribute as dirty unless a
collection block is added, deleted, or moved
in just the right way. The exception to this
is collection blocks in sync patterns.
In this case the ID cannot change
because it can cause update loops in some
cases that freeze the browser.
2024-03-22 01:40:15 -07:00
Christopher Allford 5002b62d00
Reset Product Collection Pagination When Filtering (#45693)
Since we can't be sure that a page exists once the filters have been
changed we should reset the page when they do.
2024-03-21 14:03:13 -07:00
Roy Ho 5acef655b8
Add gap between quantity field and add to cart button when stacked (#45758)
* Add gap between quantity field and add to cart button when stacked

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

* Add specificity to quantity

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-03-20 15:41:10 -07:00
Niels Lange be63107c92
Improve local pickup flow (#45614)
* Update shipping calculation copy

* Update shipping calculation copy

* Update shipping calculation copy

* Update legacy local pickup copy

* Remove ‘target="_blank"’ and ‘rel="noopener noreferrer"’

* WIP: Conditional message and display of legacy local pickup option

* Make util function static

* Make texts translatable

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

* Fix PHPCS errors

* Fix PHPCS errors

* Update plugins/woocommerce/includes/class-wc-shipping.php

Co-authored-by: Gerhard Potgieter <potgieterg@gmail.com>

* Remove duplicate helper method

* Improve helper method

* Replace “esc_html__” with “wp_kses” to keep URL clickable

* Optimise is_legacy_local_pickup_active() method

* Adjust CSS definitions

* Refactor is_cart_block_default() and is_checkout_block_default()

* Ensure that Rest of the World shipping methods are available

* Remove obsolete space

* Adjust text spacing

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Gerhard Potgieter <potgieterg@gmail.com>
2024-03-20 14:54:12 +00:00
Roy Ho 3ef4fc88a5
Rating filter: fix misaligned count (#45674)
* Rating filter: fix misaligned count

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-03-20 05:24:47 -07:00
Niels Lange fa49848cf9
Fix broken CSS classes and update JS unit snapshots (#45732)
* Fix broken CSS classes and update JS unit snapshots

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-03-20 17:42:05 +07:00
Erik Golinelli 49b92070cc
Removes the star icon font (#31670)
* removes the star font
The WooCommerce font can hold many other icons there isn't the reason to load a font for a single icon

* updates custom templates stylesheets

* adds woff2 font format to themes customized stylesheets

* fix the star font size diff

* removes WooCommerce.eot and SVG file that are no longer needed and updates the template style in order to import from font.scss

* Optimized font import
Unifies the import of fonts by extending it to the twenty-twenty-three theme

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

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

* Svg font minification (WooCommerce.svg)

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

* "star" font phasing out
The font family 'star' was replaced in all files. However, it continues to remain physically in the repo but not in the style files

* Removes the `.eot` font file since nowdays it's completely useless

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-03-20 11:28:27 +01:00
Paulo Arromba 0a3cf74c06
Validate and present custom error for not in allowed emails coupons (#43872)
* Removed deprecated WC_COUPON::is_valid() method usage from CartController.php

* Reverted wrongly changed line.

* Added validate_coupon_allowed_emails() to WC_Discounts

* Added soft validation for allowed emails coupons, with custom notice via WC_Coupon::add_coupon_message()

* Fixed log warning

* Refactored add_coupon_message()

* Prevent duplicate coupon notices.

* Changed coupon soft validation notice type.

* Tweaks

* Run coupon soft validations only on cart validation.

* Reverted soft validation, and added email information for coupon validation

* Removed unused coupon message

* PHP lint fixes.

* Added changelog.

* PHP lint fix

* Updated allowed coupon validation error message

* Updated PW tests

* Updated PW tests

* Updated email restricted coupon message.

* Small change for readability.

* Different error messages for shortcode cart and shortcode checkout

* Simplified CartApplyCoupon::get_post_route_response()

* Revert "Simplified CartApplyCoupon::get_post_route_response()"

This reverts commit 43f185b59a.

* Expose additional error data in error API response

* Simplified AbstractCartRoute::get_route_error_response()

* Linting

* Restored comment deleted by mistake.

* Introduced API context based coupon errors

* Fixed Doc Block

* Linting

* Reverted deprecated method removal

* Reverted deprecated method removal

* WIP

* Display context based errors on cart and checkout for allowed emails coupons.

* Small code fixes.

* Removed coupon_error_code from api response.

* Tweaks and used 'details' on the API response

* Fixed indent.

* Set coupon errors using the validation store rather than local state

* Revert import to original state.

* Updated tests.

* Updated tests.

* Simplified comments

* Added testing for Cart page

* Lint fixes

---------

Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
2024-03-20 10:19:06 +00:00
Karol Manijak 5a54dd6527
Product Collection: Disable client side navigation if blocks incompatible with Interactivity API are detected (#45435)
* Add dummy Force Page Reload control to Inspector Advanced Control

* Add enhancedPagination attribute that decides if client side navigation is enabled

* Consume the enhancedPagination attribute

* Force client side navigation when incompatible blocks detected

* Dummy util to detect incompatible blocks

* Detect incompatible blocks in the Editor

* Switch to WordPress Interactivity package in Product Collection

* Add initial implementation of the incompatible blocks detection in frontend

* Remove leftover

* Revert to using internal version of interactivity API

* There's no Interactivity store config available in the internal Interactivity implementation so remove it

* Disable client side navigation if the incompatible block is detected

* Add default attribute value

* Switch from enmhancedPagination attribute to forcePageReload

* Fixed some misclicked line order change

* Switch from enhancedPagination to forcePageReload in PHP code

* Apply the correct filter

* Fix the incorrect condition to detect incompatible block

* Initial implementation of orange dot to bring attention

* Cleanup

* Remove the orange dot indicator

* Refactor checking for unsupported blocks

* Add changelog

* Fix PHP lint errors

* Bring back empty line at the end of pnpm-lock

* Bring pnpm-lock.yaml file to original state

* Fix incorrect function call

* Add visibility description to function

* Switch private method to public

* More linted fixes
2024-03-18 08:24:03 +01:00
Alexandre Lara 21f2a15e97
Product Filter: Price (Beta) block - Disable block interactions within the editor (#45602)
* Disable block interactions within the editor

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-03-15 17:18:25 -03:00
Alexandre Lara 85ec4a8cc1
Product Filter: Attribute (Beta) block - Fix block preview (#45558)
* Pass isPreview prop to inner blocks of the Product Filter block

* Add logic to render preview block when in Preview mode

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-03-15 16:27:01 -03:00
Christopher Allford 23a148aa18
Added Result Count Client Navigation (#45556)
Since the product collection block uses the interactivity router,
it reloads the page in the background and replaces sections
with a `data-wc-navigation-id` set. This adds the attribute
to the count block so that it can also live reload regardless
of where it is in the tree.
2024-03-14 09:48:02 -07:00
Tung Du 50beebe3e5
[Experimental] Display the formatted price in price filter text input fields (#45409)
* fix: display the formatted price in price filter text input fields

* chore: changelog

* Display formatted price within the Product Filter: Price input fields

---------

Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
2024-03-13 09:47:36 -03:00
Niels Lange 6b07ca44f5
Add totalValue filter (#45170)
* Add totalValue filter

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

* Remove nowrap to prevent text overflow

* Start docs for ‘totalValue’ filter

* Fix *.md lint issues

* Ignore .md lint errors for now

* Update code example and add screenshots

* Fix failing JS unit tests

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-03-13 00:42:24 +07:00
Alexandre Lara b162c9fab0
[Experimental] Product Filter: Price (Beta) block: Prevent invalid price range selection in Product Filter Price block (#45403)
* Prevent invalid price range selection in Product Filter Price block

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-03-08 16:08:20 -03:00
Bhupesh Mishra 319408bb67
changed filter by attribute filter options order (#44799)
* changed filter by attribute filter options order

In filter by attribute, order of the filter conditions "ALL" and "ANY" reversed as requested.

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

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-03-08 13:45:53 +01:00
Karol Manijak a3811fa007
Product Collection: Set initial value of Created filter for New Arrivals collection (#45355)
* Set initial vlaue of Created filter for New Arrivals collection

* Add changelog

* Remove a check for products in tests as they may not really be displayed

* Adjust the New Arrivals test

* Adjust the tests logic after the change

* Bring back previous formatting

* Bring back function closure removed by mistake
2024-03-08 08:33:21 +01:00
Alexandre Lara 8163b83bf7
Price Filter: Fix styling issue when Inline input fields is enabled (#45197)
* Fix styling issue in the Editor when Inline input fields is enabled

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

* Fix styling issue on the Frontend when Inline input fields is enabled

* Fix css lint errors

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-03-06 17:10:12 -03:00
Alexandre Lara be9b3ab4f0
Filter blocks: Add block preview (#45258)
* Add block preview to filter blocks

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-03-06 16:55:04 -03:00
Christopher Allford e2ed2a9fdb
Removed Product Collection Unique ID (#44625)
With the availability of other unique characteristics
for identifying collection blocks, it is no longer necessary
to keep this attribute. Since it has not been used it is safe
to remove it without a deprecation cycle.
2024-03-05 14:08:17 -08:00
Seghir Nadir 9f7a6779f6
Fix styling for select in Site Editor (#45252)
* Fix styling for select in Site Editor

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-03-05 14:49:33 +01:00
Tung Du 91272dde6f
[Experimental] Fix: regression introduced in #44757 that breaks the inspector settings of the new attribute filter block (#45276)
Fix: regression introduced in #44757 that breaks the inspector settings of the new attribute filter block
2024-03-05 11:09:36 +07:00
Alexandre Lara 9d57f891eb
With Product Variations HOC > Convert to TypeScript (#44785)
* Add with-product-variations.tsx

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

* Add types for ProductVariationItem

* Fix ESLint errors

* Remove JS file

* Replace Product with ProductResponseItem interface

Initially, a Product interface was created to add the required types; however,
it was pointed out that the @woocommerce/types alias already provided an interface
for products (the ProductResponseItem interface).

* Remove returning types definition

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-02-26 10:26:21 -03:00
Alexandre Lara 56e6772af5
Reviews by Product > No Reviews Placeholder: Refactor component from JavaScript to TypeScript (#44664)
* Refactor No Reviews Placeholder component from JavaScript to TypeScript

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

* Fix file import

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-02-22 22:23:53 -03:00
Sam Seay ccb1fb3d76
[Experimental] Fix a bug in new attribute filter where we didn't set the attribute from content panel (#44757) 2024-02-21 19:53:15 +13:00
Alexandre Lara 319c2637eb
Reviews block: Convert editor-block.js to editor-block.tsx and replace propTypes with TypeScript definitions (#44594)
* Convert Reviews Editor code to TypeScript

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-02-20 10:58:52 -03:00
Luigi Teschio 5fe5aef5a0
Product Image block: show the setting to control the imageSizing attribute and add the attribute to the `Product Catalog` and `Product Search Results` templates (#44691)
* add imageSizing attribute to the product catalog template

* add attribute for the product search results template

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-02-20 10:50:42 +01:00
Karol Manijak 5b420159cb
Product Collection: disable "Sync with current query" option for 2nd+ block on archive (#44577)
* Refactor store usage

* Prepare function resolving inherit property for additional check

* Add logic to disable sync with query if there's already one Product Collection on archive that does that

* Add changelog

* Cover the post editor case

* Add E2E test for that and small refactor in tests

* Remove duplicated import

* Fix lint problems

* Fix typo in test description

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

* Replace confusin abbreviation with other description

* Update the logic to be more robust and covering also the case where Product Collection blocks are nested

* Add issue reference to the comment

* Add eslint disable before ts-ignore

---------

Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
2024-02-19 17:51:42 +01:00
Manish Menaria ce00f299ea
Improve Accessibility in Product Collection Navigation (#44599)
* Add animation for client-side pagination

This includes:
- Addition of animation state management in the frontend file to control the visual transition between pagination states.
- Introduction of new SCSS rules for the start and finish animations, ensuring a seamless and visually appealing pagination experience.
- Modification of the PHP logic to inject necessary HTML for the animation to be applied.

These updates aim to provide a more engaging and responsive interface for users navigating through product collection.

* Enhance accessibility for product collection navigation

This commit introduces several improvements to enhance accessibility and user experience. Specifically, it adds new context properties to manage accessibility messages during the navigation process, including messages for loading and when a page has loaded. These changes ensure that screen reader users receive appropriate feedback during navigation.

Changes made:
- Added `accessibilityMessage`, `accessibilityLoadingMessage`, and `accessibilityLoadedMessage` properties to the `ProductCollectionStoreContext`. These properties store messages to be announced by screen readers during different stages of page navigation.
- Implemented logic in the product collection store to update the `accessibilityMessage` during the start of navigation (showing a loading message) and upon completion (showing a loaded message).
- Utilized a technique to ensure that consecutive identical messages are still announced by screen readers, by appending a no-break space to the message if it is the same as the previous one. This follows a pattern similar to the `@wordpress/a11y` package.
- In `ProductCollection.php`, enhanced the block's HTML output to include these new accessibility messages and integrated them with the existing interactive data attributes. This ensures that the front-end components are fully prepared to handle these accessibility enhancements.
- Added a new `div` with `class="screen-reader-text"` and `aria-live="polite"` attributes, which dynamically displays the accessibility message based on the navigation state. This div complements the visual pagination animation with an accessibility-focused mechanism for announcing the page load states to screen reader users.

By addressing accessibility considerations with these enhancements, we're making Product Collection navigation more inclusive and user-friendly for all users.

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-02-19 11:35:14 +05:30
Tarun Vijwani 4e6476a996
Adjust spacing in/between elements on the Cart and Checkout block pages (#44160)
* Add spacing in Checkout block page

* Add spacing in Order summary block

* Update responsive styles for order summary panel

* Update styles for cart and cart line items table

* Update styles for order summary and cross-sells products

* Remove unnecessary CSS styles from cart line items table and cart block

* Remove unused CSS class from cart line items table

* Fix linting errors

* Add changelog

* Fix changelog lint

* Update quantity selector style

* Increase the line-height of the set description and remove margin top from email field

* Add margin-top to order summary image and express payment margin adjustment

* Update styles for cart and checkout components

* Fix linting error

* Fix margin units in cart-cross-sells-products

* Replace em with px

* Add margin-top to payment method container

* Update styles for Cart block for mobile screen

* Update padding in cart style.scss
2024-02-17 01:50:11 +04:00
Tarun Vijwani 7528a7d65e
Fix removal of express payment method from state (#44633)
* Fix removal of express payment method from state

- Correct the logic for removing an express payment method from the availableExpressPaymentMethods state object.
- Previously, the deletion targeted the incorrect object, leading to incorrect change in state. Now, the correct entry is removed using destructuring and rest parameters, ensuring the express payment method is properly deleted.

* Revert "Fix removal of express payment method from state"

This reverts commit 8e24553794.

* Fix typo error in the reducer

* Add unit to make sure correct express payment method is removed

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

* Remove payment method descriptions from express and fix changelog

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-02-16 23:00:42 +04:00
Tarun Vijwani 506499dec4
Prevent prefilling of the billing address with the shipping address in the Checkout block for the Guest Shopper (#44347)
* Clear billing address when useShippingAsBilling checkbox is unchecked

* Add billing address sync with server

* Add useRef hook to store previous billing address and update sync functions

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

* Revert "Add useRef hook to store previous billing address and update sync functions"

This reverts commit 7bc3312ab7.

* Added condition to clear address only for guest users

* Add E2E test to check billing address form is empty for Guest shopper

* Fix typo

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

* Updated docs-manifest.json

* Revert "Updated docs-manifest.json"

This reverts commit 20d578a9d6.

* Include company field in the E2E test

* Replace beforeAll with beforeEach

* Skip country reset to keep consistency with Shortcode Checkout

* Remove sync billing address on server

* Update E2E test to include the shipping address check

* Remove unsed  imports

* Clear address fields except country and state

* Optimize the billing and shipping address check with switch statement

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
2024-02-16 16:10:51 +04:00
Manish Menaria e210302e8a
Product Collection: Add loading indicator for client-side pagination (#44571)
* Add animation for client-side pagination

This includes:
- Addition of animation state management in the frontend file to control the visual transition between pagination states.
- Introduction of new SCSS rules for the start and finish animations, ensuring a seamless and visually appealing pagination experience.
- Modification of the PHP logic to inject necessary HTML for the animation to be applied.

These updates aim to provide a more engaging and responsive interface for users navigating through product collection.

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

* Allow user clicks under product collection's loading animation

This commit enhances the user experience of the loading animation for the product collection block. Changes include:

- Specifying `transform-origin: 0% 0%;` directly within the block's initial style to indicate the animation should start from the left
- Adding `pointer-events: none;` to allow user interactions with elements underneath the loading animation, thus improving usability by not blocking clicks.

Additionally, redundant `transform-origin` properties were removed from the `@keyframes` declaration to clean up the code and avoid unnecessary repetition. This simplification contributes to both the maintainability and readability of the stylesheet.

* Fix linting errors in SCSS file

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-02-16 15:43:58 +05:30
Tung Du 0425857b7f
[Experimental] Fix Active Filter chips style (#44682) 2024-02-16 10:09:49 +00:00
Sam Seay f513ce7c25
[Experimental] Refresh product collections that don't support the interactivity API (#44631) 2024-02-16 15:51:42 +13:00
Alexandre Lara 452c522b95
[DOC] Resolve incorrect branch references in Gutenberg links (#44566)
* Fix Gutenberg links in the docs pointing to the wrong branch

* Add changefile(s) from automation for the following project(s): @woocommerce/notices, @woocommerce/eslint-plugin, @woocommerce/dependency-extraction-webpack-plugin, @woocommerce/components, woocommerce-blocks, woocommerce-beta-tester, woo-ai

* Fix markdown lint errors

* Fix wrong link in the docs

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-02-15 14:13:28 -03:00
Mike Jolley b94c14e745
[Experiment] Fix additional address field validation notices (#44615) 2024-02-14 10:02:30 -08:00
Karol Manijak 2750e79224
Getting the Product Collection location/context (#43997)
* Early implementation of getting the Product Collection location/context

* Solve the problem of async fetch in the hook

* Improve typing

* Import core data store instead of hardcoding store name

* Recognise Product Category and Product Tag

* Remove attr property from archive location data

* Unify states naming

* Add TODO entry

* Display the info about the location of Product Collection

* Improve the typing

* Recognise if Product Collection is nested in Single Product block

* Improve cases descriptions and add some defaults to potentially undefined values

* Change the taxonomies sourceData

* Recognise Mini Cart as Cart context

* Recognise attribute as archive contect but no taxonomy

* Refactor the function into single useEffect and clean it up

* Fix typo

* Remove unnecessary import

* Stop rendering the output in Editor (it was for demo purposes)

* Pass location data to Product Template query in Editor

* Replace templateSlugs literal strings with object reference

* Rename parseResponse function to more specific name getIdFromResponse

* Add dpeendency array to useEffect

* Refactor templates detection

* Use full taxonomy names instead of shortcuts

* Write down scenarios to test

* Working scenario

* Change the verification way for more robust

* Add more robust methods to include Single Product block

* Add test Product Collection in Single Product block in a Single Product Template

* Imprvoe the order of veryfing the requests

* Fix linter issues. Although that makes code less readable

* Improve the useGetLocation typing so it's more generic

* Rework the E2E tests regarding location of Product Collection and limit their number

* Bring back necessary eslint-disable

* Remove unused imports

* Uncomment line required for other tests

* Add changelog

* Rename constant from BLOCK_NAME to BLOCK_SLUG as it's a slug

* Add a BLOCK_NAME constant and replace the literal block name usages in E2E tests

* Fix post merge issues

* Fix test after merge

* Adjust the tests to kick off waiting for request before action that triggers them
2024-02-12 20:59:40 +01:00
Sam Seay 143388dae8
[Experimental] Add (Beta) suffix to block name of new filter blocks (#44487) 2024-02-12 11:15:49 +00:00
Manish Menaria 4ae60196ea
Product Collection: Make attributes available in rest_product_query hook (#44150)
* Make attributes available in rest_product_query hook

This commit introduces the 'includeInQueryContext' attribute to the 'woocommerce/product-collection' block and updates the 'woocommerce/product-template' block to consume this new attribute.

Key Changes:
1. `woocommerce/product-collection` Block:
   - A new attribute 'includeInQueryContext' is added in `block.json`. This attribute is designed to hold a list of attribute names relevant for the query context.
   - The 'includeInQueryContext' attribute is included in the `providesContext` field to ensure its availability to child blocks.
   - In `constants.ts`, default values for 'includeInQueryContext' are defined, specifying 'collection' and 'id' as initial attributes.
   - The `types.ts` file is updated with a comment explaining the purpose of 'includeInQueryContext'.

2. `woocommerce/product-template` Block:
   - Modified `block.json` to utilize the 'includeInQueryContext' context provided by the parent `woocommerce/product-collection` block.
   - The `edit.tsx` file is updated to handle the new context. It uses a newly added utility function `useProductCollectionBlockAttributes` from `utils.tsx` to access parent block attributes.
   - The `utils.tsx` file is introduced, containing the `useProductCollectionBlockAttributes` hook. This hook is responsible for finding the parent 'woocommerce/product-collection' block and returning its attributes.
   - Within `edit.tsx`, logic is added to create a query context object based on the attributes specified in 'includeInQueryContext', enhancing the block's ability to dynamically adapt to changes.

* Remove commented code

* Rename query context attribute and optimize parent block detection

This commit introduces two significant changes aimed at improving code readability and efficiency.

1. **Renaming of Query Context Attribute:**
   - The attribute `includeInQueryContext` has been renamed to `queryContextIncludes` across various files, including block JSON configurations and TypeScript definitions. This change makes the attribute's purpose more intuitive, indicating it specifies which attributes to include in the query context.

2. **Optimized Parent Block Detection:**
   - Replaced the use of `getBlockParents` with `getBlockParentsByBlockName` in utility functions to find the closest Product Collection block. This optimization allows for a more direct and efficient way to identify the relevant parent block by specifying the block name, reducing unnecessary iterations and improving code performance.

* Streamline query context construction in product template

Key Changes:
- **Introduction of `useProductCollectionQueryContext` Hook:** This new hook takes the `clientId` and `queryContextIncludes` as inputs and returns a query context object. It encapsulates the logic for fetching parent product collection block attributes and constructing the query context accordingly. This abstraction simplifies the edit component's logic, focusing on the essentials and improving code readability.
- **Optimization of Parent Block Detection:** The hook uses `getBlockParentsByBlockName` to accurately and efficiently find the closest parent `Product Collection` block, minimizing the overhead previously associated with traversing the block hierarchy.

* Always include `collection` and `id` in query context

* Minor refactor

* Enhance query context handling for more maintainable code

- Introduced `DEFAULT_QUERY_CONTEXT_ATTRIBUTES` in `edit.tsx` to maintain a clear list of default query context attributes.
- Modified `ProductTemplateEdit` to automatically include these default attributes in `queryContextIncludes`, ensuring they are always part of the query context without manual initialization.
- Simplified `useProductCollectionQueryContext` in `utils.tsx` by removing static initialization of 'collection' and 'id', relying instead on the dynamic addition of necessary attributes from `queryContextIncludes`.

This refactor enhances the maintainability and clarity of the code, ensuring a solid foundation for future enhancements and features.

* Add E2E tests for Product Collection query context

- Added a new test suite 'Query Context in Editor' to validate the correctness of query context parameters when the Product Collection block is used. This suite ensures that:
  - For the 'Product Catalog', only the ID is sent in the query context, confirming that collection-specific parameters are excluded when not relevant.
  - For collections such as 'On Sale', the collection name is correctly passed in the query context, validating that the block dynamically adjusts query parameters based on its settings.

- Introduced a new utility method `setupAndFetchQueryContextURL` in `product-collection.page.ts`. This method automates the setup of a post with the Product Collection block and fetches the URL with query context parameters, facilitating the validation of query context handling.

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

* Fix edge case when `queryContextIncludes` is not defined

- Initializing `queryContextIncludes` with a default empty array directly in the destructuring assignment of the component's props. This approach ensures that `queryContextIncludes` is always an array, simplifying downstream logic.
- Creating a new constant `queryContextIncludesWithDefaults` to hold the combination of `queryContextIncludes` and `DEFAULT_QUERY_CONTEXT_ATTRIBUTES`. This step avoids directly mutating the `queryContextIncludes` prop, aligning with best practices for functional purity and making the code easier to understand and debug.
- Updating the `useProductCollectionQueryContext` hook call to use `queryContextIncludesWithDefaults`. This ensures that the default query context attributes are consistently included without altering the original prop.

These adjustments not only enhance the code's maintainability but also ensure more predictable behavior by avoiding side effects related to parameter mutation.

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-02-12 14:15:24 +05:30
Alexandre Lara 7ec1b7f3a1
Product Gallery block: Add logic to trap keyboard focus within the Product Gallery Pop-Up (#44439)
* Add logic to trap keyboard focus inside the Product Gallery Pop-Up

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

* Remove unnecessary condition

* Fix issue with keyboard focus trap not working within the Pop-Up

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-02-09 13:43:51 -03:00
Alexandre Lara 74c6fcad2d
Product Gallery block > Pop-Up: Fix overlay sizing issue (#44479)
* Fix overlay issue when Product Gallery Pop-Up is open

* Fix stylelint error

* Add changelog

* Fix e2e tests for Product Gallery Pop-Up
2024-02-09 11:38:41 -03:00
Karol Manijak db082421ad
Product Collection: fix assymmetrical padding in Editor (#44403)
* Import editor.scss styles of Product Templayte and increase specificity

* Add changelog

* Add ts ignore

* Revert changing eslint-disable as it conficts with another rule creating more errors
2024-02-09 09:42:29 +01:00
Chris Lilitsas 60c17eb126
Include the selected collection in the product collection block context (#43247)
* Include collection attribute in the block context

* add 'collection' to useContext for Product Template

* Changelog

---------

Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
2024-02-08 10:55:05 +02:00
Alexandre Lara f7b92e8b6b
Product Gallery block: Focus should return to trigger element when closing pop-up (#44414)
* Return focus to trigger element when closing pop-up

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

* Fix php cs error

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-02-07 17:18:41 -03:00
Alexandre Lara 0654fa1997
Product Gallery block: Announce Pop-Up Opening with Voiceovers (#44332)
* Add aria attributes to product gallery pop-up

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

* Fix Interactivity API store import

* Announce Dialog opening with VoiceOver

* fix php cs lint error

* Remove unnecessary data-wc-watch directive from Product Gallery block

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-02-06 14:28:33 -03:00
Mike Jolley 45923dc5f3
[Experiment] Handle customer session meta data (#44181)
* Update data store to bail if there is no customer ID

* Use WC_Data meta functions

* Save and load meta in session class

* Customer session handling

* CheckoutFields - only persist customer data to accounts

* Inline docs for session handling

* Handle meta data in session

* Document wc->customer inline

* Store only additional fields in session

* Prevent notice in WC_Data

* Organise keys and remove duplicates

* Correctly save fields to account

* Fix notices on checkout

* Remove unnecessary diff

* Changelog

* Go back to previous way to loading session handler to avoid 3rd party breakage

* No need to track is_session

* white space

* Remove changes to customer data store

* Update class-wc-customer-data-store.php

* Populate client from additional values from api

* Additional fields in session

* Add woocommerce_customer_allowed_session_meta_keys hook

* Put back legacy keys for tests

* Remove key fixes

* Don't save additional fields to customer object

* Remove duplicate init call

* Only persist contact fields
2024-02-06 15:16:00 +00:00
Alexandre Lara b4928ed46a
Product Gallery block: Enable keyboard navigation for thumbnails (#44236)
* Add ability to select thumbnails using keyboard

* Add ability to open the Product Gallery pop up using the keyboard

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

* Fix outline border not showing on Thumbnails on some browsers

* Prevent firefox browser from focusing on UL tag of the Large Image block

* Enable usage of 'Space' and 'NumpadEnter' keys to navigate between the thumbnails

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-02-06 08:55:03 -03:00
Mike Jolley 35630bb52b
Update combobox validation message to be more generic (#44229)
* Update combobox validation message

* Changelog
2024-02-06 11:51:09 +00:00
Alexandre Lara 560f0e933d
Product Gallery block: Prevent block error when a user inputs a decimal number for the Number of Thumbnails setting (#44282)
* fix error on decimal input for the Number of Thumbnails setting

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-02-05 15:17:35 -03:00
Manish Menaria 1d8007b822
Product Collection: Return to top after page change (#43817)
* Initial working version

* Update scrolling behavior in product collection block frontend

This commit updates the scrolling behavior in the product collection block's frontend script.

Previously, the code focused on the first anchor or button within a product collection block. This approach was taken to maintain accessibility and ensure that the focused element was scrolled into view. However, this behavior has been changed to improve the user experience.

The updated code now directly scrolls to the first product in the collection. This is achieved by selecting the product using a new selector that targets the `.wc-block-product` class within the `.wc-block-product-template` of the specified `data-wc-navigation-id`. Once the product is selected, the `scrollIntoView` method is used with smooth behavior and start block alignment, offering a more visually appealing scroll effect.

This change enhances the user experience by smoothly directing attention to the beginning of the product collection, making it easier for users to browse products.

* Remove code related to animation

* Fix the issue related to pagination block rendering

- I have improved the code by breaking it into smaller functions
- Added unique `data-wc-key` to each anchor tag

* Enhance Product Collection Block with Interactive Prefetching

* Refine Prefetch Logic & other improvements

This commit further refines the prefetch logic and interactivity in the Product Collection block. It focuses on enhancing code clarity and improving the prefetch behavior based on user interactions.

Key changes include:
1. Renamed 'isPrefetchNextAndPreviousLink' to 'isPrefetchNextOrPreviousLink' in ProductCollectionStoreContext for better readability and accuracy.
2. Modified the scrollToFirstProductIfNotVisible function to accept a wcNavigationId as a parameter instead of a reference
3. Introduced checks for the existence of wcNavigationId in scrollToFirstProductIfNotVisible to prevent unnecessary executions.
4. Updated comments throughout frontend.tsx for enhanced clarity, explaining the prefetch logic and its triggers in detail.
5. Adjusted the logic in the navigate and prefetch functions to align with the new context structure and prefetch strategy.
6. In ProductCollection.php, updated data attributes to align with the revised prefetch strategy.
7. Refined the attribute setting in process_pagination_links function to correctly implement the updated interactivity and prefetch logic.

These changes aim to optimize the prefetch functionality, reduce unnecessary prefetching on initial page load, and ensure a smoother and more efficient navigation experience within the Product Collection block.

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

* Improve comments

* Use wp_json_encode for data-wc-interactive attribute

This commit updates the `ProductCollection` class to use `wp_json_encode` for setting the `data-wc-interactive` attribute value. Previously, the attribute value was hardcoded as a JSON string. Now, by utilizing `wp_json_encode`, we ensure the JSON encoding is handled correctly by WordPress standards, enhancing readability and maintainability of the code.

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-02-02 12:07:29 +05:30
Karol Manijak 84f2de633d
Fix incorrect product data displayed in Product Collection in context of Single Product block (#44123)
* Initial approach to fix incorrect product data displayed in Product Collection in context of Single Product block

* Remove the BlockCOntextProvider

* Add Block context for title and summary

* Add changelog

* Improve typing

* Add E2E test with Product Collection inside Single Product block

* Improve insertBLock function description

* Make productPrices selector in Product Collectionmore specific

* Extract components props into a types
2024-02-01 17:55:38 +01:00
Thomas Roberts 1130380f73
[Experimental] Allow Additional Information block to be moved but not removed (#44193)
Co-authored-by: github-actions <github-actions@github.com>
2024-02-01 02:58:05 -08:00
Thomas Roberts 77d2dd9453
Make combobox suggestions have same border as main input (#44183)
Co-authored-by: github-actions <github-actions@github.com>
2024-02-01 02:57:57 -08:00
Sam Seay 08d5cc05aa
[Experimental] Fix a bug where new attribute filter block flickers in editor. (#44147) 2024-01-31 01:10:12 +13:00
Sam Seay cfd8f36578
[Experimental] Utilize WP generated class names to style rating filter block. (#44072) 2024-01-29 19:50:47 +13:00
Sam Seay 067cdef753
[Experimental] Utilize WP generated class names to style interactivity stock filter block. (#44073) 2024-01-26 19:29:39 +13:00
Sam Seay 1ce39d98fb
[Experimental] Utilize WP generated class names when styling new active filters block. (#44069) 2024-01-26 19:06:50 +13:00
Tung Du 1abefd5eee
[Experimental] Filter block: replace custom upgrade panel by Transforms API (#44024) 2024-01-25 15:28:09 +07:00
Tung Du b50431d9af
[Experimental] Filter block: refactor visibility control, context passing, and filter data processing (#43996) 2024-01-25 13:55:45 +07:00
Tarun Vijwani 0c79d1b6a7
Display shipping calculator link in the Cart block when fallback shipping options available (#43803)
* Hide the shipping rates in editor to match front-end

- If there are no shipping rates, hide the shipping rates in editor to match front-end.

* Add get_shipping_zones method to CartCheckoutUtils

* Display change address like for fallback shipping zone

- If cart has multiple and default shipping zones without shopper address, display the change address link

* Update shipping address label

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

* Fix linting errors

* Update plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/shipping/shipping-address.tsx

Co-authored-by: Niels Lange <info@nielslange.de>

* Display shipping calculator for locations outside all other zones

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

* Update typescript for activeShippingZones

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Niels Lange <info@nielslange.de>
2024-01-24 20:40:53 +04:00
Sam Seay 42e77d4938
[Experimental] Product Filter - Reintroduce Wrapper Block (#43688) 2024-01-23 18:29:24 +13:00
Tarun Vijwani 139150134f
Add store notices to the Cart and Checkout block templates (#43753)
* Fix session notices in Cart and Checkout block pages

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

* Update plugins/woocommerce-blocks/assets/js/base/components/notice-banner/style.scss

Co-authored-by: Niels Lange <info@nielslange.de>

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Niels Lange <info@nielslange.de>
2024-01-22 21:25:42 +04:00
Thomas Roberts 7dabf2b031
[Experimental] Add `$request` to additional fields validation filter (#43789)
* Add $request to additional fields filter

* Add changelog entry

* Add data to additional message
2024-01-19 23:21:47 -08:00
Niels Lange 32282a00ce
Add tracking for incompatible extensions (#42816)
* Add tracking for incompatible extensions

* Separate tracking data
2024-01-19 13:03:33 +07:00
Thomas Roberts bf61e57ce4
Ensure "email" field id does not include the section ID (#43734)
Co-authored-by: github-actions <github-actions@github.com>
2024-01-18 04:33:50 -08:00
Manish Menaria 8c284a5074
[Product Collection] Add unique ID attribute (#43314)
* Add unique ID attribute to Product Collection block

In this update, we introduced a unique identifier for each instance of the Product Collection block. This change involves several key modifications:

1. **Block JSON Update**: Added a new `id` attribute in `block.json` to store the unique identifier for each block instance.

2. **Product Collection Content Update**: In `product-collection-content.tsx`, we utilized the `uuid` library to generate a unique ID. This is done in a `useEffect` hook, ensuring that each block instance receives a distinct ID upon initialization.

3. **Type Definitions**: The `ProductCollectionAttributes` interface in `types.ts` was updated to include the new `id` attribute, aligning with our enhanced data structure.

4. **Package Dependencies**: To support this feature, `@types/uuid` and `uuid` were added to `package.json`, ensuring we have the necessary tools for ID generation.

This enhancement is pivotal for uniquely identifying each Product Collection block, paving the way for more robust and individualized block handling in the future.

* Rename uniqueId to id

* Add lock file

* Add 'id' context to product collection and template

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

* Merge trunk with 42861-introduce-a-unique-identifier-for-each-product-collection-block

* Regenerate the lockfile

* Remove autogenerated change in plugins/woocommerce/package.json

* Regenerate lock file

* Rerun CI actions

* Delete pnpm-lock.yaml file & regenerate it using pnpm install command

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-01-18 15:30:57 +05:30
Alexandre Lara 8258919e22
Product Gallery block: Remove the experimental flag from the Product Gallery block (#43586)
* Remove the experimental flag from the Product Gallery block

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-01-16 21:05:47 -03:00
Mike Jolley 1dee94362f
[Experimental] Surface additional checkout fields on Order Confirmation page (#43449)
* Get default attributes on front end

* Remove console log

* Show notice about 0 registered fields in editor

* Do not show block in editor if no fields are registered

* Wrapper block

* Styling/spacing

* Update webpack config

* Register heading pattern

* Wrapper block type definition

* get_fields_for_location return fields in array format

* Use wrapper in default content

* Separate fields from the hook block

* Hide when no custom fields exist

* Address and contact fields

* Shared form fields in settings

* remove info block from wrapper

* Revert render_content to original

* rename block

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

* Update styling

* Create shared get_order_additional_fields_with_values to format values

* Update block names and descriptions

* Show address placeholders

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

* Unused import

---------

Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: github-actions <github-actions@github.com>
2024-01-16 13:17:28 +00:00
Thomas Roberts c776fb63bc
[Experimental] Add custom validation hooks for additional checkout fields (#43435)
Co-authored-by: github-actions <github-actions@github.com>
2024-01-16 03:01:51 -08:00
Karol Manijak c531067daf
Improve the selector determining the products are loaded in Product Collection tests (#43464)
* Improve the selector determining the products are loaded in Product Collection tests

* Add changelog

* Update plugins/woocommerce/changelog/test-42038-make-product-collection-e2e-tests-more-robust

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

---------

Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
2024-01-16 08:31:22 +01:00
Thomas Roberts 23db3eff69
[Experimental] Handle adding attributes during fields registration (#43379)
Co-authored-by: github-actions <github-actions@github.com>
2024-01-15 14:59:36 -08:00
Danny Dudzic 43be71a52f
[Experimental] Product Gallery: Update div elements to ul/li for better accessibility (#43612)
* Product Gallery: Update div elements to ul and li for better accessibility

* Product Gallery: Add changelog files

---------

Co-authored-by: roykho <roykho77@gmail.com>
2024-01-15 13:04:03 -08:00
Alexandre Lara 4b5c6982e4
[Experimental] Product Gallery block: Prevent page from scrolling when pop-up is open (#43378)
* Prevent body from scrolling when pop-up is open

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

* Add namespace to the modal-open css class

* Fix class name for the Product Gallery block

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-01-12 15:10:33 -03:00
Albert Juhé Lluveras aa661f2234
Fix Mini-Cart price disappearing on hover (#43550)
* Fix Mini-Cart price disappearing on hover

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-01-12 13:39:34 +01:00
Roy Ho 5d87130b43
[Experimental] Product gallery/remove default (#43487)
* Remove Product Gallery block as default

* Add beta label to Product Gallery block title

* Add changelog files
2024-01-11 18:03:58 -08:00
Sam Seay 5fdbe63530
[Experimental] Rename Collection Filters to Product Filters (#43363)
---------
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2024-01-12 00:27:33 +13:00
Thomas Roberts d8331dc3f1
Add additional information block for custom checkout fields (#43274)
Co-authored-by: Mike Jolley <mike.jolley@me.com>
Co-authored-by: github-actions <github-actions@github.com>
2024-01-10 06:20:06 -08:00
Chris Lilitsas e24aabff04
Introduce a new block style for the Product Details block and set it as default (#42965)
* Introduce the minimal block style for productDetails block

* Change the default style in the template

* Change the default template when using the transform-to-blocks button

* Cleanup

* Organize CSS selectors

* Add opacity on hover

* Fix specificity and add explanation

* Cleanup

* Changelog
2024-01-10 14:08:48 +02:00
Karol Manijak 30888d7f1b
Product Collection: Rename "Inherit query from template" option and make description contextual (#43270)
* Update the copy of Inherit Query from template and make it contextual

* Add changelog
2024-01-10 12:40:05 +01:00
Daniel Dudzic 3be8264c5d
[Experimental] Product Gallery Pager: Improve accessibility (#43348)
* Product Gallery Pager: Improve accessibility

* Product Gallery Pager: Fix number pager styling
2024-01-09 10:48:49 +01:00
Alexandre Lara 65d9c6764c
[Experimental] Product Gallery block: Rename media setting to "Open pop-up when clicked" (#43302)
* Rename media setting to "Open pop-up when clicked"

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-01-08 16:58:27 -03:00
Karol Manijak 8d4f1cecec
Product Collection: Make sure all variations are taken into account when choosing collection (#43273)
* Make sure all variations are taken into account when choosing collection

* Add changelog
2024-01-08 10:55:42 +01:00
Tung Du aab950e27a
[Experimental] Add: Filter blocks migration (#43218)
* add: upgrade panel

* add: toolbar upgrade button

* add: downgrade panel

* chore: changelog

* refactor: move the upgrade component to `Collection Filters` block
2024-01-08 16:31:06 +07:00
Tung Du 823a35a9f2
[Experimental] Add: notice informing users about the usage of filter blocks (#43262) 2024-01-08 13:43:12 +07:00
Sam Seay 1eba9c62a8
Add lint config to blocks to lint imports (#43310) 2024-01-08 18:32:15 +13:00
Seghir Nadir e50e7799c0
Support additional fields in the Contact step for Checkout (#43088)
* add custom fields to contact info step

* fix linting

* add changelog

* adjust fields validation

* address review changes

* address sanization and validation

* fix billing address shape

* address schema issues

* cast address to array

* dont sanitize stuff that will validated

* fix linting issues

* fix cart unit test

* revert test

* fix the email issue
2024-01-05 18:35:28 +01:00
Roy Ho 8bbb35d63e
[Experimental] Product Gallery: Use @container rule to adjust overlay link count font size (#43294)
* Product Gallery: Use @container rule to adjust overlay link count font size

* Add changelogs

* Remove em from line height

* Make view all link smaller
2024-01-05 07:23:19 -08:00
Tung Du af2dedb137
[Experimental] Filter blocks: add the navigate function back (#43287)
* fix: add the navigate function back

* fix: move the navigate function to a dedicate file only for frontend use
2024-01-05 14:33:43 +07:00
Tarun Vijwani 2b0da27fd0
Update generic incompatibility notice (#42751)
* Move the switch to classic shortcode block button to separate component

- Move modal component file from incompatible-extension-notice component folder to switch-to-classic-shortcode-button folder.
- Rename modal component file to model-content component file.
- Move the switch to classic shortcode block button to separate component folder

* Update generic incompatibility notice

- Update the notice description.
- Add switch to classic shortcode block button to the notice.

* Fix margin in editor.scss

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

* Update class names in switch-to-classic-shortcode-button component

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

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

* Update plugins/woocommerce-blocks/assets/js/editor-components/switch-to-classic-shortcode-button/editor.scss

Co-authored-by: Niels Lange <info@nielslange.de>

* Refactor SwitchToClassicShortcodeButton component

* Fix css lint erros

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

* Add type property to notice events

* Refactor switch to classic shortcode button logic

* Use isCart for switchButtonLabel and snackbarLabel

* Remove empty div in sidebar compatibility notice component

* Refactor switch to classic shortcode button event handling

* Adjust wording

* Adjust marging and readability

* Introduce union for SwitchToClassicShortcodeButtonProps type prop

* Simplify logic

* Use proposed text

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Niels Lange <info@nielslange.de>
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
2024-01-05 10:47:34 +07:00
Karol Manijak 4128bff64c
Fix incorrect layout of Product Collection placeholder on Firefox (#43264)
* Fix incorrect layout of Product Collection placeholder on Firefox

* Add changelog
2024-01-04 11:20:57 +01:00
Sam Seay faf1c6f09e
[Experimental] Use variations to provide all the product filters wrapped by CollectionFilters block (#43216)
---------
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2024-01-04 18:33:59 +13:00
Tung Du de1d60ebe4
[Experimental] Add Widget support to new collection filter blocks (#43153) 2024-01-04 11:56:24 +07:00
Sam Seay 73160b3c41
[Experimental] Filter out filter options that would result in 0 products. (#43220) 2024-01-04 17:23:40 +13:00
Daniel Dudzic 7163d610e5
Product Gallery: Fix Large Image snapping position on window resize (#43251)
* Product Gallery: Fix Large Image snapping position on window resize

* Product Gallery Snap Fix: Add changelog
2024-01-03 17:46:43 +01:00
Sam Seay 187780905f
[Experimental] Use CheckboxList component in interactivity attribute filter (#43217) 2024-01-03 22:58:57 +13:00
Sam Seay 161bf51bd3
[Experimental] Allow overriding placeholder in interactivity Dropdown::render (#43211)
* add: multiple select support to attribute dropdown
* fix: remove active filter from dropdown
* chore: remove unused extractBuiltinColor

---------
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2024-01-03 20:52:45 +13:00
Tung Du 97e4c55aeb
[Experimental] Rating Filter block: fix wrong import path (#43198) 2024-01-03 09:31:50 +07:00
Sam Seay 5de0f4a274
[Experimental] Refactor the interactivity dropdown to remove dependence on FormTokenField (#43183)
* Also fix https://github.com/woocommerce/woocommerce/issues/43154
2024-01-02 17:13:27 +13:00
Tung Du bd9ddc830a
[Experimental] Add: QueryFilters class to calculate filter data for product queries (#42811)
* add: query filters count class

* chore: method comments

* refactor: rename class to QueryFilters

* fix: price filter count

* fix: price filter url

* chore: remove unnecessary transformation

* chore: remove unused meta query filter

* chore: put public methods on the top of the class

* fix: passing $wp_query

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

* fix: stock query clause

* fix: handle and query type for attribute filter

* fix: ensure passing non null value to floor/ceil

* [Experimental] Collection Filter blocks: ensure the namespace is always rendered (#43112)

* fix: ensure the namespace is always rendered

* fix: target only wc queries

* fix: properly reset part of query to make new filter blocks work with Product Collection block
2024-01-01 10:18:50 +07:00
Albert Juhé Lluveras c58b0cf936
Fix error when adding to cart from the Product Collection block if Google Analytics plugin is enabled (II) (#43177)
* Revert "Trigger event `experimental__woocommerce_blocks-cart-add-item` in the SSR Product Button vis Interactivity API (#42946)"

This reverts commit 4fec136da1.

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2023-12-29 17:23:35 +01:00
Alexandre Lara 4efd2123a3
[Docs] Update links from WooCommerce.com to Woo.com for the Woo Blocks documentation (#43055)
* Update woocommerce.com URLs in documentation and code files

* Add changelog

* Fix github repository link in extend-rest-api-add-custom-fields.md

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

* Add github reporter (#42974)

* Add github reporter

* Add changelog

---------

Co-authored-by: Jon Lane <jon.lane@automattic.com>

* Fix product task redirect to support grouped and external products (#43051)

* Rearrange product redirection logic to better accept grouped and external produc types

* Add changelog

* Modify feedback modal actions (#43005)

* Adapt feedback modal actions

* Add changelogs

* Modify comments

* Fix tests

* Fix test

* Update class-wc-gateway-bacs.php (#43054)

* Update class-wc-gateway-bacs.php

Fix typo in textdomain

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

---------

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

* [Product Block Editor]: Add `Linked product` tab (#43009)

* add linked-products to group IDs

* add Linked Products tab

* tweak hideConditions condition

* changelog

* fix typo in doc comment

* Introduce a product type selection within the new experience (#41823)

* Create a relation between the product type and the product block template

* Add 'patterns' to name the kind of products that can be created for a specific template

* Resolve template using its id as a template query param

* Rename ProductEditPattern to ProductTemplate

* Rename get_patterns hook to woocommerce_product_editor_get_product_templates

* Return the list of templates to the client

* Set layout template events as array

* Register the layout template based on the product template or the post type in case of product variations

* Registering non supported product types

* Create and register the woocommerce/product-details-section-description block

* Add the product type to the section description

* Create product type selector

* Fix menu item style

* Highlight selected menu item

* Set the selected product template

* Set product template title to lowercase in the content description

* Rename blocks by blockTemplates under the AbstractBlockTemplate class

* Rename to woocommerce_product_editor_product_templates filter

* Remove product_template_ prefix from the supported_product_types map

* Rename get_formatted to to_JSON and convert the props to client side like

* Refactor get_product_templates

* Fix icon resolution

* Add a confirmation modal for unsupported product templates

* Add changelog files

* Remove product types using for testing

* Fix redirection when changing to a non supported product template

* Set the change button state to busy when it is saving the product

* Fix php linter errors

* Fix rebase conflict

* Move ProductTemplate to Automattic\WooCommerce\Admin\Features\ProductBlockEditor namespace

* Add the to_json definition to the BlockTemplateInterface

* Create default product template by custom product type if it does not have a template associated yet

* Fix some comments and product template creation validation

* Add support to load the product template icon from an external resource

* Fix php linter

* Fix the changelog description

* [Experimental] Interactivity Dropdown multi-select mode, ratings filter and introduce each directive (#42981)


---------
Co-authored-by: David Arenas <david.arenas@automattic.com>

* Introduce the transient files engine (#42877)

Co-authored-by: Corey McKrill <916023+coreymckrill@users.noreply.github.com>

* Change marketplace install API request to POST instead of GET (#43033)

* Change marketplace install API to using POST instead of GET
* Fix linting error
* Add changefile(s) from automation for the following project(s): woocommerce

---------

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

* Prep trunk for 8.6 cycle (#43021)

Prep trunk for 8.6 cycle with version bump to 8.6.0-dev

Co-authored-by: WooCommerce Bot <no-reply@woo.com>

* Add Playwright tests for All Reviews, Reviews by Product and Reviews by Category blocks (#42903)

* Remove Reviews blocks Puppeteer tests

* Minor code cleanup

* Typos

* Create publishAndVisitPost() editor util

* Fix subcategories when importing products in Playwright and add reviews

* Add Reviews blocks tests in Playwright

* More typos

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

* Create a 'reviews' object in data.ts so we can store reviews data in one single place

* Update test so instead of creating a new post in each test, we go to the already-created post

* Add source comments to reviews data to match it with the script

---------

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

* Release: Remove 8.5 change files (#43022)

Delete changelog files from 8.5 release

Co-authored-by: WooCommerce Bot <no-reply@woo.com>
Co-authored-by: Alex López <alex.lopez@automattic.com>

* Delete changelog files based on PR 43033 (#43079)

Delete changelog files for 43033

Co-authored-by: WooCommerce Bot <no-reply@woo.com>

* Delete changelog files based on PR 43051 (#43081)

Delete changelog files for 43051

Co-authored-by: WooCommerce Bot <no-reply@woo.com>

* Interactive Price Filter: use `context` instead of `state` (#42980)

* feat: use context instead of state

* fix: temporary move the context to inner element for diffing to work

* fix: update context before navigation for optimistic UI

* Load google analytics gtag script asynchronously in WooCommerce Blocks (#43040)

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

* set WOOCOMMERCE_BLOCKS_PHASE to 1 for the production build (#43074)

* set WOOCOMMERCE_BLOCKS_PHASE to 1 for the production build

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

---------

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

* Revert "Fix schedule sales error" (#43094)

Revert "Fix schedule sales error (#42700)"

This reverts commit 9b800aa179.

* [Product Block Editor]: add Linked product sections. First approach. (#43013)

* add Linked products, Upsell section

* changelog

* add Cross-lens section

* add links to the Upsell sections

* changelog

* fix lint issues

* fix lint issus

* fix linting issue :-|

* check whether the linked product group is defined

* [Product Block Editor]: introduce ShoppingBags component (#43042)

* add ShoppingBags component

* Add ShoppingBag story

* changelog

* Fix: Collection data being leaked between Collection Filters blocks (#43044)

* fix: CYS - change heading color (#43076)

* fix: CYS - change heading color

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

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com>

* Delete changelog files based on PR 43074 (#43118)

Delete changelog files for 43074

Co-authored-by: WooCommerce Bot <no-reply@woo.com>

* [Product Block Editor]: fix feature flag to hide the Linked products (#43119)

* fix flag to hide/show product editor

* changelog

* Add changelog

---------

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Jonathan Lane <lanej0@users.noreply.github.com>
Co-authored-by: Jon Lane <jon.lane@automattic.com>
Co-authored-by: louwie17 <lourensschep@gmail.com>
Co-authored-by: Fernando Marichal <fernando.marichal@automattic.com>
Co-authored-by: Marc Guay <marc.guay@gmail.com>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Damián Suárez <rdsuarez@gmail.com>
Co-authored-by: Maikel David Pérez Gómez <maikel.perez@automattic.com>
Co-authored-by: Sam Seay <samueljseay@gmail.com>
Co-authored-by: Néstor Soriano <konamiman@konamiman.com>
Co-authored-by: Corey McKrill <916023+coreymckrill@users.noreply.github.com>
Co-authored-by: Kyle Nel <22053773+kdevnel@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: WooCommerce Bot <no-reply@woo.com>
Co-authored-by: Alex López <alex.lopez@automattic.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com>
2023-12-29 12:28:11 -03:00
Manish Menaria 1ed5d0872a
Fix: Enable Pagination Block Visibility in Product Collection Block (#43132)
* Fix: Enable Pagination Block Visibility in Product Collection Block

This commit resolves an issue where the Pagination block was not visible in the block insertor within the Product Collection block.

- The core query pagination block name, initially hardcoded, is now declared as a constant `coreQueryPaginationBlockName` in `constants.ts`. This change not only improves code readability but also ensures consistency in using the block name across different files.

- In `index.tsx`, the `addProductCollectionBlockToParentOfPaginationBlock` utility function from `utils.tsx` is imported and executed. This function plays a crucial role in the fix. It dynamically adds the Product Collection block to the parent array of the Core Pagination block, ensuring the latter's visibility in the insertor when editing the Product Collection block.

- The utility function employs WordPress hooks and version checks to gracefully handle different WordPress environments. This careful approach maintains backward compatibility while addressing the current issue.

With these changes, merchants can now easily add a Pagination block from the insertor while working on the Product Collection block, enhancing the user experience and functionality.

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2023-12-29 15:45:29 +05:30
Sam Seay eabb27c72b
[Experimental] Add block text color support to interactivity filter blocks (#43068)
* [Experimental] Render headings as inner blocks of collection filters (#43109)
2023-12-29 03:06:35 +13:00
Niels Lange 8e7c5cca1c
Show rating stars for the cross-sells products (#43069)
* Show rating stars for the cross-sells products

* Fix typo introduced in #43116 (#43148)

* Fix typo introduced in #43116

* Add changefile(s) from automation for the following project(s): @woocommerce/product-editor

---------

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2023-12-28 16:20:07 +07:00
Karol Manijak 37155abb0c
New flow of adding Product Collection and basic set of Collections (#42696)
* Migrate PR to Core

* Migrate test changes

* Add Custom Collection with inherit query attribute disabled

* Update copy of Product Catalog collection

* Don't choose default active collection in polaceholder and remove highlight

* Remove inherit query option from inspector controls

* Add collection names to Product Catalog and Custom one

* Unify Collection Chooser between Modal and Placeholder

* Bring back util removed by accident

* Replace the translations domain with woocommerce

* Remove leftovers after merge

* Add pagination and no results to Product Catalog and Custom collections

* Revert textdomain change

* Fix lint error

* Add changelog entry

* Change collection label

* Bring back Inherit query from template

* Remove Custom collection and bring back single Product Collection

* Simplify applying collection

* Make sure Inherit query from template is enabled in archive templates by default and disbaled in posts/pages

* Change incorrect Playwright locator

* Add test for Product Catalog inheriting the query in product archive

* Add tests for recommendation collection hiding the predefined filters

* Add reviews to multiple products

* Update expected products in Top Rated

* Remove rating creation in test env and skip undeterministic tests

* Add skip to Best Sellers test

* Update README.md

* Add more keywords to collections, like 'product collection' to recommendation collections

* Rephrase the README note about Collections registration

* Simplify types

* Rename unchangeableFilters to hideControls

* Fix typo in file name

* Remove 'pattern' references from toolbar files

* Replace hardcoded SCSS color with wc variable

* Remove changelog file from different PR

* Move hideControls to Product Collection ayttributes

* Improve responsiveness of columns in Product Collection Placeholder

* Use admin color pallette in Product Collection Placeholder

* Move Inherit query from template to the top of Inspector Controls

* Change the Collection prefix to woocommerce rather than woocommerce-blocks

* Simplify Placeholder and Modal styles
2023-12-27 11:07:27 +01:00