Commit Graph

5644 Commits

Author SHA1 Message Date
Daniel Dudzic 2240504d51 Mini Cart: Fix styling of the Start Shopping button in the drawer. Fixes woocommerce/woocommerce-blocks#10035 (https://github.com/woocommerce/woocommerce-blocks/pull/10169) 2023-07-14 11:47:23 +00:00
Luigi Teschio 9e9425b092 fix migration (https://github.com/woocommerce/woocommerce-blocks/pull/10205) 2023-07-14 11:16:06 +00:00
Karol Manijak 041d4ad4b1 Stop reading Product IDs from asset store in filter blocks (https://github.com/woocommerce/woocommerce-blocks/pull/10195)
* Remove queries that fetch all products for manipulating the results returned by the Store API for certain use-cases.

* Remove the code that's supposed to read product ids for filter context and logic around that in useCollectionData

* Fix incorrect merge

---------

Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com>
2023-07-14 11:18:10 +02:00
Patricia Hillebrandt 53668eb066 Product Filters > Fix Performance issue and Fatal error on stores with a high volume of products (https://github.com/woocommerce/woocommerce-blocks/pull/10198)
* Remove queries that fetch all products for manipulating the results returned by the Store API for certain use-cases.

* Keep support for Product Collection block
2023-07-14 10:34:55 +02:00
Alba Rincón 3d8331363c `Rating Stars` block improvements (https://github.com/woocommerce/woocommerce-blocks/pull/10148)
* Rating start block improvements

Fix classes, register in single product, remove unused code

* Allow to use block on product & product collection

* Fix star missalignment

* Restrict the block to be insertable only in single product
2023-07-14 09:41:58 +02:00
Alba Rincón d82a4b671f Add new `Ratings counter` block (https://github.com/woocommerce/woocommerce-blocks/pull/10114)
* Add new rating counter block

* Fix colors and register globally

* Add missing import

* Remove unused file

* Reorder blocks alphabetically

* Remove unnecessary html

* Change registration, fix classes

* Fix margin

* Remove icon from block.json, add ancestors

* Move icon and remove unused constants

* Fix classes

* Remove condition

* Allow to use block on product & product collection

* Enable block only on single product

* Move ancestors to block.json
2023-07-14 08:57:19 +02:00
Manish Menaria bd892c4781 Add E2E tests for 'Inherit query from template' control in Product Collection block (https://github.com/woocommerce/woocommerce-blocks/pull/10174)
Key updates:

1. Additional CSS class to Inherit Query Control: A CSS class named `wc-block-product-collection__inherit-query-control` has been added to the ToggleControl component. This provides a precise target for E2E tests and potential custom styles.

2. E2E tests for 'Inherit query from template' control: Numerous scenarios have been covered to ensure the control's correct behavior. These scenarios include verifying visibility under different circumstances and checking its functionality in a Product Catalog template.

3. E2E test code enhancements: The E2E test code now exports the `SELECTORS` object to assist in locating different elements during the tests. This includes the new 'Inherit query from template' control. The `setShowOnlyProductsOnSale()` function has been refactored to improve readability and provide more granular control over its operations.

4. Test scenario for 'Show only products on sale': The existing E2E test for this functionality has been extended to check that it retains its state when the 'Inherit query from template' control is toggled.

These changes increase the robustness of our E2E tests, providing better coverage for the 'Inherit query from template' control in the Product Collection block.
2023-07-14 10:52:19 +05:30
Bernie Reiter 1aaf7384d2 README: Update required Node version to 16.15, add note on version management tools (https://github.com/woocommerce/woocommerce-blocks/pull/10175)
* README: Set required Node version to v16.15

* Add note about Node version management tools.
2023-07-12 18:10:13 +02:00
Karol Manijak de0cc88147 Automatic migration path from Products to Product Collection - step 3 - allow reverting migration (https://github.com/woocommerce/woocommerce-blocks/pull/10144)
* Add logic to revert migration from Product to Product Collection
2023-07-12 17:01:49 +02:00
Alex Florisca 52506cbe81 Fix margin issue with the Proceed to checkout button on the site editor (https://github.com/woocommerce/woocommerce-blocks/pull/10182)
* Fix margin issue with the Proceed to checkout button on the site editor

* Remove unecessary selector
2023-07-12 15:28:37 +01:00
Patricia Hillebrandt 64405c7a43 Mini Cart block > Update block registration to rely on a metadata file. (https://github.com/woocommerce/woocommerce-blocks/pull/10168)
* Introduce the block.json file for the mini-cart block.

* Update the index.tsx file to use the new metadata file for registering the mini cart.
2023-07-12 16:20:19 +02:00
Darren Ethier 2efe99126f Account for classic theme support of template parts (https://github.com/woocommerce/woocommerce-blocks/pull/9780)
* allow for handling classic theme template part support

Note this logic is currently not right - just a quick implementation for testing POC

* Account for classic theme support of template parts

* Update supports_block_templates signature so it accepts the template type instead of a bool

* Simplify logic in supports_block_templates

* Test

* Fix supports_block_templates check to test correct template type

---------

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2023-07-12 15:51:30 +02:00
Karol Manijak dbfa57bd67 Automatic migration path from Products to Product Collection - step 2 - display notice (https://github.com/woocommerce/woocommerce-blocks/pull/10139)
* Display upgrade notice after successful replacement
2023-07-12 11:19:35 +02:00
Karol Manijak 9b0c610ced Automatic migration path from Products to Product Collection - step 1 - automatic migration (https://github.com/woocommerce/woocommerce-blocks/pull/10115)
* Foundation of the Products block replacement with Product Collection

* Provide logic to replace Products with Product Collection

* Make sure the blocks can be replaced

* Add types and refactor replacement a bit

* Fix the query attributes transform

* Add upgrade Notice to the Product Collection block

* Force upgrade notice to be displayed at the top of the Inspector Controls

* Externalise migration code so it can be reused in both ways

* Add util to get block IDs byt its name

* Add a way to revert the Product Collection blocks to Products

* Move the subscription to another place where it's triggered only once

* Add default values

* Remove attributes from Products block if they're not used to avoid incorrect query

* WIP logic of unseen/seen/reverted notice

* Change the state reading

* Revert changes regarding notice displaying logic

* Change the logc of firing replacement and bail early if there's no core/query blocks

* Add todos

* Implement inner blocks migration

* Implement the revert transformation of inner blocks

* Refactor types

* Add layout transformation from Products to Product Collection

* Add layout migration from Product Collection to Products

* Disable migration by default

* Simplify some parts of code

* Remove additional keyword from Product Collection to move it to another PR

* Adjust the logic to introduce the first step: conversion from Products to Product Collection

* Disable automatic migration
2023-07-12 10:01:36 +02:00
Luigi Teschio 98a61d3a4d Enable declaration-block-no-duplicate-properties stylelint rule (https://github.com/woocommerce/woocommerce-blocks/pull/10163) 2023-07-11 13:03:05 +00:00
Karol Manijak d7d550f983 Product Collection - check the value before consuming it to avoid frontend warning (https://github.com/woocommerce/woocommerce-blocks/pull/10162) 2023-07-11 14:40:15 +02:00
Luigi Teschio 45d994d47f Revert "Fix image over content (https://github.com/woocommerce/woocommerce-blocks/pull/10092)" (https://github.com/woocommerce/woocommerce-blocks/pull/10160)
This reverts commit b82c0de69d.
2023-07-11 12:16:12 +00:00
DAnn2012 edd3588ef2 Fix minimum required PHP version in readme.txt file (https://github.com/woocommerce/woocommerce-blocks/pull/10085) 2023-07-11 14:04:57 +02:00
Niels Lange 73f1ebf605 Return null or object for ImageAttachmentSchema response (https://github.com/woocommerce/woocommerce-blocks/pull/9962)
* Return null or object for ImageAttachmentSchema response

* Adjust docblock

* Update unit tests for ImageAttachmentSchema
2023-07-11 13:43:58 +02:00
Karol Manijak c55343b736 Product Collection - refactor inspector controls props (https://github.com/woocommerce/woocommerce-blocks/pull/10154)
* Refactor Columns Control inspector controls in Product Collection

* Refactor Order By inspector controls in Product Collection

* Reorder imports in Product Collection Inspector Controls

* Refactor On Sale inspector controls in Product Collection

* Refactor Stock Status inspector controls in Product Collection

* Refactor Keyword inspector controls in Product Collection

* Unify interface of query controlling Inspector Controls

* Unify interfaces of Inspector Controls that modify Query in Product Collection

* Unify other Query modifying Controls

* Simplify types
2023-07-11 13:05:49 +02:00
Manish Menaria d4c3d43f9d Product Collection - Add more E2E tests (https://github.com/woocommerce/woocommerce-blocks/pull/10090)
* Add E2E tests for category-based product filtering

This commit refactors the product filtering in the product collection E2E tests and adds the ability to filter products based on their category.

Changes:
1. The method `setHandpickedProducts` was renamed to `setFilterComboboxValue` to reflect the fact that it's now used for more than just handpicked products. This method is now used to set the values of different filters.
2. The `addFilter` method was extended to support the 'Show Taxonomies' filter. It also includes a delay to ensure the correct rendering of the UI before further interactions.
3. A new test was added for filtering products based on their category using the 'Show Taxonomies' filter.
4. The tests for filtering products by handpicked selection and keyword were updated to use the new `setFilterComboboxValue` method.

These changes improve the robustness of the E2E tests and increase their coverage by including category-based filtering.

* Add product attribute filters to end-to-end tests

- A new test case has been added in the `product-collection.block_theme.spec.ts` to test the functionality of filtering products based on their attributes like color and size. This is done using the `addFilter` and `setProductAttribute` methods.

- Additionally, the `addFilter` method in `product-collection.page.ts` has been updated to include the 'Show Product Attributes' filter.

- A new method `setProductAttribute` has been introduced to set the attribute value which will trigger the filter action.

These updates enhance the test coverage by verifying the functionality of product attribute filters in the product collection.

* Add responsiveness test for product collection block

This commit introduces a new end-to-end test to ensure that the product collection block responds correctly to changes in screen size.

The new test in `product-collection.block_theme.spec.ts` verifies that the number of product columns adjusts as expected for different viewport sizes. In the initial viewport size, the width of a product should be less than the parent width as multiple columns are expected. When the viewport size is reduced, the product width should be approximately equal to the parent width, indicating a single column layout.

These changes provide more robust testing of the product collection block's responsiveness, helping to ensure a consistent user experience across different device sizes.

* Refactor product assertions and add setViewportSize method in ProductCollection tests

This commit refactors the Product Collection tests to enhance test readability and consistency. It switches the product count checks from `productImages` to `products` which is more semantically correct.

Additionally, a new method `setViewportSize` has been added in the `ProductCollectionPage` class for adjusting the viewport size in the tests.

- Changed product count assertions to use `products` instead of `productImages`
- Added `setViewportSize` method to `ProductCollectionPage`
- Updated existing tests to use the newly added `setViewportSize` method

* Add test case for product filtering based on stock status in Product Collection tests

This commit adds a new test case in the Product Collection suite to test product filtering based on their stock status. The test case checks if the filter for 'Out of stock' status works correctly.

Note: This test case is currently commented out because there are no products with 'Out of stock' status in the test data. The assertions will need to be uncommented once the test data includes 'Out of stock' products.

* Add new test case for toolbar settings

This commit does two main things:

1) Adds a new test case under 'Toolbar settings' to test 'Items per page', 'offset' & 'max page to show' settings in the product collection block.

2) It extends the ProductCollectionPage class to add methods for setting display settings and for handling pagination. It also defines a new 'pagination' locator to find the pagination navigation on the page.

This update will allow us to more effectively test the behavior of the product collection block when dealing with large collections and pagination. Note: the 'Product can be filtered based on stock status' test has been marked as skipped until there are products with 'Out of stock' status in the test data.

* Refactor e2e test files for Product Collection

Changes in `product-collection.block_theme.spec.ts`:
- Marked the test 'Products can be filtered based on category' as a 'fixme'. This test is currently failing due to a bug in the product collection block.

Changes in `product-collection.page.ts`:
- Reorganized constant block data into a more extensive set of selectors.
- Introduced a new method `locateSidebarSettings` to locate the sidebar settings region, improving readability and reusability.
- Used the new method `locateSidebarSettings` in various places where settings values are being set.
- Refactored other methods to better locate elements based on the reorganized selectors.
- Adjusted the product-related locators to rely on these newly defined selectors.

* Fix: Frontend Category Filtering in Product Collection Block (https://github.com/woocommerce/woocommerce-blocks/pull/10132)

* Fix: Product collection - Product category filter isn't working on frontend

* Remove fixme from test

* Refactor variables names
2023-07-11 16:05:29 +05:30
Alexandre Lara 3f97a61a38 Update experimental flags 2023-07-10 11:50:05 -03:00
Alexandre Lara 052d21259b Add php experimental flag for Product Gallery block (https://github.com/woocommerce/woocommerce-blocks/pull/10141) 2023-07-10 11:40:12 -03:00
Karol Manijak fd378be6eb Add "grid" and "list" view switch for Product Collection (https://github.com/woocommerce/woocommerce-blocks/pull/10145)
* Add Display Layout controls to Product Collection

* Adjust the layout type name

* Add explicit display layout types

* Change the function name to setDisplayLayout so it's more explicit

* Pass only the necessary props to nested inspector controls

---------

Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
2023-07-10 13:39:09 +02:00
Manish Menaria 708ed47a85 Enhance: Bring back user to 1st page when filters are changed (https://github.com/woocommerce/woocommerce-blocks/pull/9952)
* Add support for filter blocks

This commit updates the `ProductCollection` block implementation to add support for filter blocks, including the Price filter, Attributes filter, Rating filter, and In stock filter.

The changes include:

1. Adding a new property `$attributes_filter_query_args` to store the query arguments related to the filter by attributes block.

2. Adding a new method `add_support_for_filter_blocks()` to enable support for filter blocks. This method sets the necessary asset data to enable filtering and refreshes the page when a filter is applied.

3. Adding new methods to handle specific filter queries, including `get_filter_by_price_query()`, `get_filter_by_attributes_query()`, `get_filter_by_stock_status_query()`, and `get_filter_by_rating_query()`. These methods generate the respective queries based on the applied filters.

4. Refactoring the `get_final_query_args()` method to include the newly added filter queries using the `get_queries_by_applied_filters()` method.

These changes enhance the functionality of the `ProductCollection` block by allowing users to filter products based on price, attributes, rating, and stock status.

* Go to first page when filters are updated

* Enhance ProductCollection block to support filter blocks

This commit enhances the ProductCollection block to support various filter blocks such as Price filter block, Attributes filter block, Rating filter block, and In stock filter block.

The `build_query` method has been refactored into two separate methods: `build_frontend_query` and `get_final_frontend_query` to make the code more modular and readable. The `add_support_for_filter_blocks` method has been modified to support the generation of product IDs for filter blocks.

The method `update_rest_query` has been renamed to `update_rest_query_in_editor` for better clarity and understanding of its function. Similarly, `get_final_query_args` has been refactored to include the `$is_exclude_applied_filters` parameter which helps in generating product IDs for the filter blocks.

Moreover, the filter hook `pre_render_block` has been added to support the filtering of blocks before they are rendered.

This update will enhance the user experience by providing more filtering options in the ProductCollection block.

* Remove changes related to redirect to 1st page

* Go to first page when filters are updated

This commit refactors the changeUrl function in the `filters.ts` file. The purpose of this refactor is to remove the page number from the URL whenever filters are changed. This ensures that the user is always taken to the first page of results.

The commit includes the following changes:
- Added comments explaining the different page number formats in the URL.
- Updated the `newUrl` parameter by removing the page number using regular expressions.
- The page is then reloaded with the updated URL using `window.location.href`.

These changes improve the URL handling in the `changeUrl` function and enhance the user experience when interacting with filters.

* Optimize URL updates to prevent unnecessary page reloads

This commit optimizes the `changeUrl` utility function to prevent unnecessary page reloads.

Changes:
1. It checks if there are no query parameters in the URL and the URL ends with a '?'.
2. If these conditions are met, it removes the trailing '?' from the URL.

The reason for this change is that a '?' in the URL typically indicates that query parameters will follow. If there are no query parameters, the '?' is unnecessary and can cause the page to reload, which can negatively affect performance. Therefore, by removing the '?', we prevent this unnecessary page reload.

* Simplify trailing '?' removal in URL handling

This commit simplifies the removal of trailing '?' characters from URLs.
The previous implementation checked if there were any query parameters
before removing a trailing '?'.

However, upon review, it was determined that this check was unnecessary,
as a trailing '?' could be removed safely even if query parameters were
present, without any negative impact.

This change simplifies the code and prevents unnecessary computation
checking for the existence of query parameters.
2023-07-10 11:34:11 +05:30
Karol Manijak bf157c5996 Add additional Products (Beta) keyword to Product Collection so it appear next to Products in the inserter (https://github.com/woocommerce/woocommerce-blocks/pull/10112) 2023-07-07 15:50:29 +02:00
Thomas Roberts 074a502612 Regenerate composer.lock after release 2023-07-07 13:52:26 +01:00
Thomas Roberts a214bd6f6c Bump versions post-release. 10.7.0-dev 2023-07-07 12:14:02 +01:00
Thomas Roberts 516238df96 Bump versions, readme, changelog, and testing notes 2023-07-07 12:12:56 +01:00
Alba Rincón 3309fb309e Adjust `Banner` padding to improve mobile experience (https://github.com/woocommerce/woocommerce-blocks/pull/10107) 2023-07-07 11:49:47 +02:00
Patricia Hillebrandt 6ea6687144 Call wc_setup_product_data if the global product variable is not an instance of WC_Product. (https://github.com/woocommerce/woocommerce-blocks/pull/10128) 2023-07-07 11:40:46 +02:00
Alba Rincón 5a9b13295a Fix image to avoid overlapping on mobile devices (https://github.com/woocommerce/woocommerce-blocks/pull/10108) 2023-07-07 08:26:34 +02:00
Albert Juhé Lluveras cc0cf1a905 Load product-query stylesheet when rendering the Products block (https://github.com/woocommerce/woocommerce-blocks/pull/10109)
* Load product-query stylesheet when rendering the Products block

* Simplify code
2023-07-06 17:16:33 +02:00
Daniel Dudzic f6a4b3c143 Product Gallery: Add Large Image inner block (https://github.com/woocommerce/woocommerce-blocks/pull/10045)
* Product Gallery: Add an new block base code

* Product Gallery: Add experimental flag

* Product Gallery: Add Large Image block code

* Product Gallery Large Image: Remove unsed types

* Product Gallery: Move the block from registerBlockType to registerBlockSingleProductTemplate

* Product Gallery: Update icon

* Product Gallery: Add missing icon import

* Product Gallery Large Image: Add experimental mode check

* Product Gallery Large Image: Deregister unnecessary block settings

* Product Gallery Large Image: Add experimental flag to the Product Gallery Large Image and remove the icon override

* Product Gallery Large Image: Add zoom and correct styling

* Product Gallery Large Image: Remove commented out unnecessary code

* Product Gallery Large Image: Re-add the removed action after capturing the large image html

* Product Gallery Large Image: Update Large Image icon and description. Move metadata to the block.json file.
2023-07-06 15:08:39 +00:00
Albert Juhé Lluveras ad973e9b46 Fix Filter blocks e2e tests (https://github.com/woocommerce/woocommerce-blocks/pull/10116)
* Revert "fix save method"

This reverts commit f6623c55320bf55ee7fa3c23eb294f06d79ee4a5.

* Revert "Revert "fix save method""

This reverts commit 739db2e3b0b62e10fbe1ebabd1ec6bbae8425b3c.

* Update Filter by Attribute and Filter by Stock e2e test fixtures

* Update Filter by Attribute 'can hide product count' test
2023-07-06 16:39:19 +02:00
Alba Rincón 3ccfec1eee Fix `Product Rating` styles & alignment (https://github.com/woocommerce/woocommerce-blocks/pull/10097)
* Fix alignment not working on the editor

* Fix style regression on rating
2023-07-06 09:25:29 +02:00
Roy Ho 5c72cfdb4d Update/fixtures html (https://github.com/woocommerce/woocommerce-blocks/pull/10080)
* Remove data attributes from fixture for active filters

* Remove data attributes from fixture for filter by price

* Remove data attributes from fixture for filter by attribute

* Remove data attributes from fixture for filter by stock
2023-07-05 06:16:36 -07:00
Mike Jolley 599274e3d6 Fix cart and checkout conditionals when using a block based theme and templates (https://github.com/woocommerce/woocommerce-blocks/pull/10098)
* Update conditionals to deal with templates instead of cart/checkout page objects

* Include notice style in main entrypoint
2023-07-05 04:02:27 -07:00
Karol Manijak 283dfc652f Add feedback form to the Product Collection block (https://github.com/woocommerce/woocommerce-blocks/pull/10079)
* Add feedback form to the Product Collection block

* Change the airtable link to the new one related to Product Collection
2023-07-05 10:34:25 +02:00
Alba Rincón b82c0de69d Fix image over content (https://github.com/woocommerce/woocommerce-blocks/pull/10092) 2023-07-05 10:30:20 +02:00
Luigi Teschio 78d320bc47 Products block: Improve stability E2E tests (https://github.com/woocommerce/woocommerce-blocks/pull/10075) 2023-07-05 07:45:38 +00:00
Luigi Teschio 7ca65db5b0 Fix filter count display toggle (https://github.com/woocommerce/woocommerce-blocks/pull/10096)
* fix save method

* improve check

* Only display counts if showCounts is true

---------

Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
2023-07-05 08:51:02 +02:00
Tarun Vijwani 6b8e4c38e0 Fix notice banner links for Legacy notices (https://github.com/woocommerce/woocommerce-blocks/pull/9996) 2023-07-04 04:16:26 -07:00
Albert Juhé Lluveras df3ff6793e Per block stylesheets (https://github.com/woocommerce/woocommerce-blocks/pull/9831)
* Clean up blank lines

* Update Webpack config

* Update PHP logic to load block styles

* Style fixes

* Style fixes (II)

* Style fixes (III)

* Style fixes (IV)

* Fix missing stylesheets in the Site Editor

* Fix wrong return values in some PHP method docs

* Fix missing ProductPrice stylesheet causing 404 in tests

* Fix missing ProductGallery stylesheet causing 404 in tests
2023-07-04 13:06:48 +02:00
Paulo Arromba 50aee9846b Render Checkout on Pay for Order for FSE themes with checkout flow templates (https://github.com/woocommerce/woocommerce-blocks/pull/10076)
* Render Checkout on Pay for Order for FSE themes with checkout flow templates.
Few typos corrected

* Render Checkout on Pay for Order for FSE themes with checkout flow templates.
Few typos corrected

* Backup and restore notices so they display on the pay page still

* Cache and restore notices during hydration to avoid breaking real notices on pages/shortcodes

---------

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2023-07-04 11:34:24 +01:00
Alba Rincón 25a5737ec7 Fix image not rendering on the editor and empty styles (https://github.com/woocommerce/woocommerce-blocks/pull/10089) 2023-07-04 11:02:35 +02:00
Mike Jolley d6037a2efb Check for gutenberg_render_block_core_template_part (https://github.com/woocommerce/woocommerce-blocks/pull/10078) 2023-07-03 15:43:24 +01:00
Daniel Dudzic 3700c1c42d Product Gallery: Add an new block base code (https://github.com/woocommerce/woocommerce-blocks/pull/9937)
* Product Gallery: Add an new block base code

* Product Gallery: Add experimental flag

* Product Gallery: Move the block from registerBlockType to registerBlockSingleProductTemplate

* Product Gallery: Update icon
2023-07-03 14:21:31 +00:00
Roy Ho 48f7a9fdda Remove attributes data from save function for active filters (https://github.com/woocommerce/woocommerce-blocks/pull/10047) 2023-07-03 06:52:31 -07:00
Roy Ho f8cf9fe97a Remove attributes data from save function for filter by price (https://github.com/woocommerce/woocommerce-blocks/pull/10039) 2023-07-03 05:39:45 -07:00
Luigi Teschio aa48386834 Mark order confirmation template E2E test as flaky (https://github.com/woocommerce/woocommerce-blocks/pull/10041) 2023-07-03 12:26:47 +00:00
Niels Lange 0b01b8c60d Remove the word ‘beta’ from the compatibility notice (https://github.com/woocommerce/woocommerce-blocks/pull/10019)
* Remove the word ‘beta’ from the compatibility notice

* Optimise wording
2023-07-03 12:56:12 +02:00
Daniel Dudzic 8cacfce738 Rating: Fix TS error (https://github.com/woocommerce/woocommerce-blocks/pull/10001) 2023-07-03 10:50:06 +00:00
Alba Rincón b1bc51e3f0 Add new `Product Rating Stars` block (https://github.com/woocommerce/woocommerce-blocks/pull/10005)
* Add new `Product Rating Stars` block

* Make block experimental

* Fix dep
2023-07-03 11:48:50 +02:00
Alba Rincón fd86fd2e57 Add size settings to the `Product Image` block (https://github.com/woocommerce/woocommerce-blocks/pull/10034)
* Add height & width setting to the image sidebar settings

* Extract settings and add scale options

* Add width settings

* Apply settings on the frontend

* Style placeholder image

* Replace post featured image with product image

* Allow the width to be wider than container

* Fix image on top of other elements
2023-07-03 11:33:44 +02:00
Mike Jolley a6b8e0e542 Hide "collection from" text when a location has an incomplete address. (https://github.com/woocommerce/woocommerce-blocks/pull/9808)
* Hide "collection from" text when a location has an incomplete address.

* Fix display on confirmation page

* has_valid_pickup_location helper

* Missing isset

* Update test

* Fix pickup text assertion

---------

Co-authored-by: Niels Lange <info@nielslange.de>
2023-07-03 10:10:18 +01:00
Hritik Chaudhary c1f2949a5d Converted product-tag and removed its proptypes (https://github.com/woocommerce/woocommerce-blocks/pull/9758)
* Converted product-tag and removed its proptypes

* addressed review comments

---------

Co-authored-by: Niels Lange <info@nielslange.de>
2023-07-03 10:54:46 +02:00
Albert Juhé Lluveras 74e39331fb Cleanup code to lazy-load wc-settings in the Mini-Cart block (https://github.com/woocommerce/woocommerce-blocks/pull/10042) 2023-07-03 09:26:31 +02:00
Albert Juhé Lluveras b5080e379d Prevent prefetched Cart payload causing wrong values with cached Mini-Cart block (https://github.com/woocommerce/woocommerce-blocks/pull/10029)
* Prevent prefetched Cart payload causing wrong values with cached Mini-Cart block

* Pass Cart Totals object entirely

* Code cleanup

* Fixes and code cleanup

* Update Mini-Cart local storage when adding or removing products from cart
2023-06-30 16:05:27 +02:00
Luigi c5f3728060 Merge branch 'release/10.4.0' of https://github.com/woocommerce/woocommerce-blocks into trunk 2023-06-30 14:56:28 +02:00
github-actions[bot] 80fabe4991 Release: 10.4.5 (https://github.com/woocommerce/woocommerce-blocks/pull/10038)
* Product Rating block > Ensure the customer reviews text is linked to the relevant reviews (https://github.com/woocommerce/woocommerce-blocks/pull/9998)

* Fix reviews count not showing on Single Product page

* Fix css style

* Product Rating block: Ensure the Customer reviews text is linked to the relevant reviews when used within the Single Product Template. When used within the Single Product Block, the link directs the user to the product template. Additionally, clear out\ PHPCS warnings.

* remove unnecessary call to wc_get_star_rating_html

---------

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

* Product Rating block: Fix reviews count not showing on Single Product page (https://github.com/woocommerce/woocommerce-blocks/pull/9995)

* Fix reviews count not showing on Single Product page

* Fix css style

* Single Product: Fix Product SKU not loading for different variations (https://github.com/woocommerce/woocommerce-blocks/pull/9990)

* Single Product: Fix incorrect add to cart form markup (https://github.com/woocommerce/woocommerce-blocks/pull/9986)

* Product Image Gallery block: Fix overflow when multiple images are used (https://github.com/woocommerce/woocommerce-blocks/pull/10013)

* Fix Product Image Gallery block overflow when multiple images are used

* Increase css specificity for the Product Image Gallery images

* Fix whitespace

* Fix style issue when using smaller images in the product image gallery

* Empty commit for release pull request

* update version

* add testing instructions

* update zip link

* Product Rating: append #reviews on the Single Product Block (https://github.com/woocommerce/woocommerce-blocks/pull/10040)

* Product Rating: append #reviews on the Single Product Block

* refactor after feedback

* fix version

* update zip link

* Single Product Block: avoid to register incompatibility blocks with the Single Product Block on the post/page editor (https://github.com/woocommerce/woocommerce-blocks/pull/10044)

* update testing instructions

* update zip link

---------

Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com>
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Luigi <gigitux@gmail.com>
2023-06-30 14:53:38 +02:00
Luigi Teschio cf8b73d79f Single Product Block: avoid to register incompatibility blocks with the Single Product Block on the post/page editor (https://github.com/woocommerce/woocommerce-blocks/pull/10044) 2023-06-30 14:06:12 +02:00
Luigi Teschio 6a35063dd1 Product Rating: append #reviews on the Single Product Block (https://github.com/woocommerce/woocommerce-blocks/pull/10040)
* Product Rating: append #reviews on the Single Product Block

* refactor after feedback
2023-06-30 11:31:14 +02:00
Luigi Teschio a06dd1d7c9 Add FrontendUtils class (https://github.com/woocommerce/woocommerce-blocks/pull/10033)
* Add FrontendUtils class

* fix conflicts

* use locator

* restore click usage

* fix util
2023-06-30 09:08:14 +02:00
Alexandre Lara 388605027b Product Image Gallery block: Fix overflow when multiple images are used (https://github.com/woocommerce/woocommerce-blocks/pull/10013)
* Fix Product Image Gallery block overflow when multiple images are used

* Increase css specificity for the Product Image Gallery images

* Fix whitespace

* Fix style issue when using smaller images in the product image gallery
2023-06-29 20:24:33 +02:00
Paulo Arromba f1df8fb975 Add Cart/Checkout/Order-Received Templates (https://github.com/woocommerce/woocommerce-blocks/pull/9301)
* WIP: dirty attempt to dry run Cart & Checkout templates

* Added Cart and Checkout to the template hierarchies

* Merge branch 'trunk' into poc/cart_and_checkout_fse_templates

* Updated cart & Checkout templates

* Order Received FSE template (https://github.com/woocommerce/woocommerce-blocks/pull/8937)

* Order Received template bootstrap

* typo

* WIP: new block

* add logic here

* Order received classic template

* reverted constants.ts

* Added the post title (buggy)

* Corrected page title

* Updated constants.ts

* Fixed template typo

* removed placeholder for order received block

* add order-received template description

* updated placeholder description

* Formatting fixes

* Template description.

* replaced hardcoded string with OrderReceivedTemplate::SLUG

---------

Co-authored-by: Luigi <gigitux@gmail.com>

* Code formatting (https://github.com/woocommerce/woocommerce-blocks/pull/8350)

* Code formatting

* page_template_hierarchy priority to 1 (https://github.com/woocommerce/woocommerce-blocks/pull/9323)

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

* Migrate Cart and Checkout Pages to the Template Editor when using a FSE theme (https://github.com/woocommerce/woocommerce-blocks/pull/9339)

* Introduce woocommerce_blocks_template_content hook

* Migrate cart and checkout page content to the template editor

* Add redirection from edit page to edit template

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

* Removed header and footer from checkout template. (https://github.com/woocommerce/woocommerce-blocks/pull/9378)

* Removed header and footer from checkout template.

* Removed header and footer from checkout template migration

* Permalink solution for the checkout endpoint/template (https://github.com/woocommerce/woocommerce-blocks/pull/9406)

* Checkout endpoint work

* Move setting field to util

* Include link to edit the template

* Remove todo

* Refactor checkout templates to share logic (https://github.com/woocommerce/woocommerce-blocks/pull/9411)

* Sync endpoints with pages (https://github.com/woocommerce/woocommerce-blocks/pull/9426)

* Switch to page syncing

* Update settings descriptions

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

* Migrate pages to templates once (https://github.com/woocommerce/woocommerce-blocks/pull/9488)

* Migrate content on init, once

* Skip migration if page does not exist

* Put back HTML for header and footer parts

* Fix page redirect due to wrong ID

* fix loading template part

* Removed unnecessary var

* update cart and checkout html templates

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

* Include a notice to redirect user to template editor (https://github.com/woocommerce/woocommerce-blocks/pull/9508)

* Template Placeholder Design for the Order Received Template (https://github.com/woocommerce/woocommerce-blocks/pull/9602)

* Load frontend styles in editor iframe

* Update placeholder to include skeleton and updated icons

* Update classic template configs

* 1px border for .wp-block-woocommerce-classic-template__placeholder-copy

* Show copy on focus

* Sample data

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

* Add simplified header on checkout template (https://github.com/woocommerce/woocommerce-blocks/pull/9607)

* Added simplified header on checkout template

* Moved simplified header to template part

* updated constants.ts

* added template part to checkout.html

* Add missing translation

* frontpage_template_hierarchy no longer needed

* Allow plugin based template parts (https://github.com/woocommerce/woocommerce-blocks/pull/9667)

* Merge branch 'trunk' into add/9288_cart-checkout-order-received_fse_templates

* Synced templates on blockified folder

* Add blockified order-received.html

* removed WooCommerce prefix

* Refactor/rebrand order received template to order confirmation (https://github.com/woocommerce/woocommerce-blocks/pull/9734)

* rebrand order received to order confirmation

* updated descriptions for templates

* updated descriptions for order confirmation placeholder

* Resolve merge conflict

* Resolve merge conflicts

* Resolve more merge conflicts after rebase

* Fix formatting

* Use patterns for localisation (https://github.com/woocommerce/woocommerce-blocks/pull/9883)

* e2e tests for cart and checkout templates (https://github.com/woocommerce/woocommerce-blocks/pull/9939)

* Merge branch 'trunk' into poc/cart_and_checkout_fse_templates

* Merge branch 'trunk' into add/9288_cart-checkout-order-received_fse_templates

* Resolve merge conflicts

* Add e2e for permalink settings

* Test that templates exist

* Add test to check that templates can be edited

* Add tests to confirm templates can be edited

* Ensure cart has contents before running tests on frontend views

* Commend out problem test

* Make sure search has multiple results

* Remove useThrottle - bad rebase

* Revert changes to docs after rebase

* Revert function call for noReviewsPlaceholder

* Bad rebase

* Reverts

* Remove revertTemplate

* Spacing

* Wait for networkidle after navigation

* Always wait for network

* Use button roles in site editor

* More specific button locator

* Update option comparison

* Fix template content

* Disable failing tests

* Disable failing classic template tests

* Use enterEditMode

* More enterEditMode usage

* enterEditMode

* Use test.skip

* More robust selectors

* Alt iframe selector

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

* Skip flakey test

---------

Co-authored-by: Luigi <gigitux@gmail.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
2023-06-29 14:41:22 +01:00
Roy Ho 6d36b2547b Make filter by rating preview consistent with default settings (https://github.com/woocommerce/woocommerce-blocks/pull/10007)
* Make filter by rating preview consistent with default settings

* Remove unneeded classnames
2023-06-29 06:15:52 -07:00
Albert Juhé Lluveras 559f712e35 Avoid usage of __experimentalUseFocusOutside (https://github.com/woocommerce/woocommerce-blocks/pull/10017)
* Avoid usage of __experimentalUseFocusOutside

* Remove unnecessary fix in QuantitySelector

* Add explanatory comment
2023-06-28 14:43:03 +02:00
Alba Rincón 6de8172053 Use the single product block on the Hero Product pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9935)
* Use the single product block on the Hero Product pattern

* Use the add to cart button block

* Use featured image and fix alignment
2023-06-28 14:34:51 +02:00
Thomas Roberts d76fa0a6cc Prevent saved payment methods showing if their main method `canPay` function returns `false` (https://github.com/woocommerce/woocommerce-blocks/pull/9917)
* Change type of payment requirements to string[]

* Add CanMakePaymentArgumentCart type and update CanMakePaymentArgument

* Add getCanMakePaymentArg function to get the arg, allows reusability

* Check saved methods gateway's to see if they can make payment

* Make canMakePaymentArg a dependency of the useMemo

* Remove await from sync function call

* Update variable names to better reflect what they store

* Add tests to ensure saved payment methods don't show if canPay is false

* Rename save-payment-method-options to tsx

* Update saved payment method options to TS

* Fix TS error in saved-payment-method-options test
2023-06-28 01:43:38 -07:00
Daniel Dudzic 254c7e8086 Product Rating: Remove empty markup if no ratings are present (https://github.com/woocommerce/woocommerce-blocks/pull/9822)
* Product Rating: Remove empty markup if no real or mocked ratings are present

* Fix TS errors

* Remove unrelated TS fixes
2023-06-27 19:14:47 +00:00
Daniel Dudzic a2d09319a7 Single Product: Fix Product SKU not loading for different variations (https://github.com/woocommerce/woocommerce-blocks/pull/9990) 2023-06-27 20:29:54 +02:00
Luigi Teschio 0441e10623 Single Product Template: fix compatibility layer logic when the blocks aren't wrapped in a group block (https://github.com/woocommerce/woocommerce-blocks/pull/9982) 2023-06-27 18:16:18 +02:00
Patricia Hillebrandt ff04f46ed0 Remove opinionated style for the price list in grouped products from the Add to Cart with Options block. (https://github.com/woocommerce/woocommerce-blocks/pull/9988) 2023-06-27 16:34:06 +02:00
Patricia Hillebrandt 8510615169 Product Rating block > Ensure the customer reviews text is linked to the relevant reviews (https://github.com/woocommerce/woocommerce-blocks/pull/9998)
* Fix reviews count not showing on Single Product page

* Fix css style

* Product Rating block: Ensure the Customer reviews text is linked to the relevant reviews when used within the Single Product Template. When used within the Single Product Block, the link directs the user to the product template. Additionally, clear out\ PHPCS warnings.

* remove unnecessary call to wc_get_star_rating_html

---------

Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
2023-06-27 14:50:58 +02:00
Daniel Dudzic 35f73b4130 Single Product: Fix incorrect add to cart form markup (https://github.com/woocommerce/woocommerce-blocks/pull/9986) 2023-06-27 12:20:56 +00:00
Alexandre Lara 00725124b8 Product Rating block: Fix reviews count not showing on Single Product page (https://github.com/woocommerce/woocommerce-blocks/pull/9995)
* Fix reviews count not showing on Single Product page

* Fix css style
2023-06-27 07:50:48 -03:00
Siddharth Thevaril 09439560b2 move to TypeScript (https://github.com/woocommerce/woocommerce-blocks/pull/9801)
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2023-06-27 12:48:26 +02:00
Tung Du f364aa41fb Product Image: use WC Core function to render image (https://github.com/woocommerce/woocommerce-blocks/pull/9984) 2023-06-27 17:31:19 +07:00
David Arenas 5a3f6e2e2e Update the Interactivity API files to include latest changes (https://github.com/woocommerce/woocommerce-blocks/pull/9924)
* Update Interactivity API JS files

* Disable TS checks in the Interactivity API for now

* Add new SSR files

* Replace wp_ prefixes with wc_ ones

* Replace wp- prefix with wc-

* Replace guternberg_ prefix with woocommerce_

* Remove file comments from Gutenberg

* Rename files with `wp` prefix

* Fix code to load Interactivity API php files

* Remove TODO comments

* Replace @wordpress with @woocommerce

* Update Webpack configuration

* Fix directive prefix

* Remove interactivity folder from tsconfig exclude

* Add client-side navigation meta tag code

* Remove unneeded blocks.php file

* Fix store tag id

* Register Interactivity API runtime script

* Fix Interactivity API runtime registering

* Remove all files related to directive processing in PHP

* Move json_encode to Store's render method
2023-06-27 12:22:12 +02:00
Luigi Teschio 1a77ce0da4 Fix Products block tests (https://github.com/woocommerce/woocommerce-blocks/pull/9951)
* fix Products block test

* test now

* fix test

* improve E2E test

* restore pw configuration

* change order

* remove timeout

---------

Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
2023-06-27 12:01:38 +02:00
Alexandre Lara 96e9b14cf6 Update the release testing notes for release 10.2.4 2023-06-26 17:32:45 -03:00
Alba Rincón f8a13d6afb Add new `Product collection banner` pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9953)
* Add new `Product collection banner` pattern

* Hard code black color

* Add new image

* Update pattern image
2023-06-26 15:01:19 +02:00
Luigi Teschio 5ee166c983 Single Product Block: update testing instructions about notice (https://github.com/woocommerce/woocommerce-blocks/pull/9955) 2023-06-26 09:17:54 +02:00
github-actions[bot] ee8cfdc304 Release: 10.4.4 (https://github.com/woocommerce/woocommerce-blocks/pull/9973)
* Empty commit for release pull request

* Add back filter blocks frontend scripts (https://github.com/woocommerce/woocommerce-blocks/pull/9954)

* Update changelog and bump version to 10.4.4

* Add testing notes for 10.4.4 release

* Update testing notes for release 10.4.4

* Replace Automated tests badge with Unit and E2E tests badge

* Wait for cart to be removed when emptied (https://github.com/woocommerce/woocommerce-blocks/pull/9829)

* Temporarily skip PHP Unit Tests for PHP 8.1 and 8.2 (https://github.com/woocommerce/woocommerce-blocks/pull/9859)

* Allow failure of the PHP Unit Tests

* Limit the PHP versions to 7.4 and 8.0 to run unit tests

* Don't allow failing fast

* Add a comment explaining the skipped part

* Cancel jobs later

* Cancel all the steps in workflow based on the same condition

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
Co-authored-by: Karol Manijak <karol.manijak@automattic.com>
2023-06-23 15:30:05 -03:00
Alexandre Lara 273a6b4fa6 Update changelog and testing notes for 10.4.4 release 2023-06-23 12:24:59 -03:00
Alba Rincón 38cbf3af74 Add new `Small discount banner with image` pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9947)
* Add new `Small discount banner with image` pattern

* Rename and improve mobile view
2023-06-23 15:22:52 +02:00
Patricia Hillebrandt c70c13c9a8 Single Product Block > Ensure the Product Summary and Title are always rendered with the correct context independent of their position (https://github.com/woocommerce/woocommerce-blocks/pull/9968)
* Ensure the Product Summary and Product Title blocks are always rendered independent of their position in the editor.

* Update docblock with note informing where the global post variable is restored for the post title and excerpt blocks.
2023-06-23 12:27:29 +02:00
Alba Rincón 9368060d79 Add new `Discount banner with image` pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9957)
* Add new `Discount banner with image` pattern

* Improve mobile view

* Increase size
2023-06-23 11:33:41 +02:00
Alba Rincón c0ddfa68d8 Update rating filter test to match the new logic (https://github.com/woocommerce/woocommerce-blocks/pull/9974) 2023-06-23 11:18:47 +02:00
Luigi Teschio b31d6cf23c Update testing instruction for woocommerce/woocommerce-blocks#9573 (https://github.com/woocommerce/woocommerce-blocks/pull/9965)
* Adjust docblock

* update testing instructions for 9573 PR

---------

Co-authored-by: Niels Lange <info@nielslange.de>
2023-06-23 09:15:15 +02:00
Hsing-yu Flowers 4e9ddb5206 Add order number to checkout schema (https://github.com/woocommerce/woocommerce-blocks/pull/9927)
* Add order number to checkout schema

* Update description
2023-06-22 13:06:12 -07:00
Alexandre Lara e5c8002d55 Add changelog and testing notes for 10.2.4 release 2023-06-22 15:17:03 -03:00
Alexandre Lara ea147019ad Fix testing steps version number 2023-06-22 15:17:03 -03:00
Albert Juhé Lluveras 9283b6c48b Add back filter blocks frontend scripts (https://github.com/woocommerce/woocommerce-blocks/pull/9954) 2023-06-22 16:09:37 +02:00
Roy Ho aff69cda89 Add/attributes filter count display toggle (https://github.com/woocommerce/woocommerce-blocks/pull/9833)
* Default show product counts to false for filter by attributes block

* Default show product counts to false for filter by stock block

* Default show product counts to false for filter by rating block

* Refactor deprecation

* Refactor deprecation

* Refactor deprecation
2023-06-22 06:38:28 -07:00
Roy Ho a81a8b830d Allow customer account block to center align (https://github.com/woocommerce/woocommerce-blocks/pull/9750)
* Allow customer account block to center align

* Convert to using Flexbox

* Use mixins to DRY

---------

Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
2023-06-22 05:41:06 -07:00
Alba Rincón ce253c24ec Add new `Discount banner` pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9936)
* Add new `Discount banner` pattern

* Add shop link

* Fix copy

* Fix colors
2023-06-22 12:32:53 +02:00
Manish Menaria 697a6d0e49 Product Collection: Make it compatible with filter blocks (https://github.com/woocommerce/woocommerce-blocks/pull/9928)
* Add support for filter blocks

This commit updates the `ProductCollection` block implementation to add support for filter blocks, including the Price filter, Attributes filter, Rating filter, and In stock filter.

The changes include:

1. Adding a new property `$attributes_filter_query_args` to store the query arguments related to the filter by attributes block.

2. Adding a new method `add_support_for_filter_blocks()` to enable support for filter blocks. This method sets the necessary asset data to enable filtering and refreshes the page when a filter is applied.

3. Adding new methods to handle specific filter queries, including `get_filter_by_price_query()`, `get_filter_by_attributes_query()`, `get_filter_by_stock_status_query()`, and `get_filter_by_rating_query()`. These methods generate the respective queries based on the applied filters.

4. Refactoring the `get_final_query_args()` method to include the newly added filter queries using the `get_queries_by_applied_filters()` method.

These changes enhance the functionality of the `ProductCollection` block by allowing users to filter products based on price, attributes, rating, and stock status.

* Go to first page when filters are updated

* Enhance ProductCollection block to support filter blocks

This commit enhances the ProductCollection block to support various filter blocks such as Price filter block, Attributes filter block, Rating filter block, and In stock filter block.

The `build_query` method has been refactored into two separate methods: `build_frontend_query` and `get_final_frontend_query` to make the code more modular and readable. The `add_support_for_filter_blocks` method has been modified to support the generation of product IDs for filter blocks.

The method `update_rest_query` has been renamed to `update_rest_query_in_editor` for better clarity and understanding of its function. Similarly, `get_final_query_args` has been refactored to include the `$is_exclude_applied_filters` parameter which helps in generating product IDs for the filter blocks.

Moreover, the filter hook `pre_render_block` has been added to support the filtering of blocks before they are rendered.

This update will enhance the user experience by providing more filtering options in the ProductCollection block.

* Remove changes related to redirect to 1st page
2023-06-22 15:27:27 +05:30
Alba Rincón db45e85bc3 Shop by Price pattern: add price filters to buttons (https://github.com/woocommerce/woocommerce-blocks/pull/9915)
* Add price filters to buttons

* Add links to the titles

* Update title for the first blog
2023-06-22 08:04:54 +02:00
Hritik Chaudhary 73c7312969 removed proptypes from feedback-promt (https://github.com/woocommerce/woocommerce-blocks/pull/9838) 2023-06-21 18:02:19 +02:00
Karol Manijak ad0509f767 Adjust the Dependabot GitHub username (https://github.com/woocommerce/woocommerce-blocks/pull/9931) 2023-06-21 16:53:00 +02:00
Daniel W. Robert 9ec3779439 Remove caret range specifier from fast-xml-parser. (https://github.com/woocommerce/woocommerce-blocks/pull/9894) 2023-06-21 09:18:10 -04:00
Luigi a53e623f73 bump version 2023-06-21 14:36:02 +02:00
Luigi ee3eabe5d0 Merge branch 'release/10.5.0' of https://github.com/woocommerce/woocommerce-blocks into trunk 2023-06-21 14:34:39 +02:00
DAnn2012 2de1129e9d Removed the second keyword (which previously denoted the text domain) from two blocks (https://github.com/woocommerce/woocommerce-blocks/pull/9816)
* Update block.json

* Update block.json
2023-06-21 14:30:57 +02:00
Luigi Teschio 0cd274d1cf Update docs/internal-developers/testing/releases/1050.md
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2023-06-21 14:27:54 +02:00
Luigi Teschio 31a2fd77dd CI: Ensure that the CI returns an error if PHP code doesn't respect phpcs configuration (https://github.com/woocommerce/woocommerce-blocks/pull/9920) 2023-06-21 12:51:30 +02:00
Brian 249dcb74f2 Consistent Pattern Titles (https://github.com/woocommerce/woocommerce-blocks/pull/9814)
* Update featured-category-cover-image.php

* Update featured-category-focus.php

* Update featured-category-triple.php

* Update featured-products-5-cols.php

* Update filters.php

* Update footer-large-dark.php

* Update footer-large.php

* Update footer-simple-dark.php

* Update footer-simple.php

* Update footer-simple-menu-and-cart.php

* Update footer-with-2-menus-dark.php

* Update footer-with-2-menus.php

* Update footer-with-3-menus.php

* Update header-centered-search-pattern.php

* Update header-essential-dark.php

* Update header-essential.php

* Update header-large-dark.php

* Update header-large.php

* Update header-minimal.php

* Update hero-product-3-split.php

* Update hero-product-chessboard.php

* Update hero-product-split.php

* Update just-arrived-full-hero.php

* Update no-products-found.php

* Update product-collections-featured-collection.php

* Update product-collections-featured-collections.php

* Update product-collections-newest-arrivals.php

* Update product-details-listing.php

* Update product-details-pattern.php

* Update product-featured-2-columns.php

* Update product-hero-2-col-2-row.php

* Update product-hero.php

* Update product-listing-with-gallery-and-description.php

* Update product-query-1-1-image-4-column-products-row.php

* Update product-query-3-column-product-row.php

* Update product-query-4-column-product-row.php

* Update product-query-large-image-product-gallery.php

* Update product-query-minimal-5-column-products-row.php

* Update product-query-minimal-product-list.php

* Update product-query-product-gallery.php

* Update product-query-product-list-with-1-1-images.php

* Update product-query-product-list-with-full-product-description.php

* Update product-search-form.php

* Update shop-by-price.php

* Update store-info-alt-image-and-text.php

* Update testimonials-3-columns.php

* Update testimonials-single.php

* Create readme.md

* Update featured-category-cover-image.php

* Update featured-category-focus.php

* Update featured-category-triple.php

* Update featured-products-5-cols.php

* Update filters.php

* Update footer-large-dark.php

* Update footer-large.php

* Update testimonials-single.php

* Update testimonials-3-columns.php

* Update store-info-alt-image-and-text.php

* Update shop-by-price.php

* Update readme.md

* Update product-search-form.php

* Update product-query-product-list-with-full-product-description.php

* Update product-query-product-list-with-1-1-images.php

* Update product-query-product-gallery.php

* Update product-query-minimal-product-list.php

* Update footer-simple-dark.php

* Update footer-simple-menu-and-cart.php

* Update footer-simple.php

* Update footer-with-2-menus-dark.php

* Update footer-with-2-menus.php

* Update footer-with-3-menus.php

* Update product-query-minimal-5-column-products-row.php

* Update product-query-large-image-product-gallery.php

* Update product-query-4-column-product-row.php

* Update product-query-3-column-product-row.php

* Update product-query-1-1-image-4-column-products-row.php

* Update product-listing-with-gallery-and-description.php

* Update product-hero.php

* Update product-hero-2-col-2-row.php

* Update product-featured-2-columns.php

* Update product-details-pattern.php

* Update product-details-listing.php

* Update product-collections-newest-arrivals.php

* Update product-collections-featured-collections.php

* Update product-collections-featured-collection.php

* Update no-products-found.php

* Update just-arrived-full-hero.php

* Update hero-product-split.php

* Update hero-product-chessboard.php

* Update hero-product-3-split.php

* Update header-minimal.php

* Update header-large.php

* Update header-large-dark.php

* Update header-essential.php

* Update header-essential-dark.php

* Update header-centered-search-pattern.php

* Update readme.md

* Update and rename readme.md to README.md

* Update patterns/README.md

Co-authored-by: Karol Manijak <karol.manijak@automattic.com>

---------

Co-authored-by: Karol Manijak <karol.manijak@automattic.com>
Co-authored-by: Niels Lange <info@nielslange.de>
2023-06-21 09:50:12 +02:00
Luigi 2731b73954 Merge branch 'release/10.4.0' of https://github.com/woocommerce/woocommerce-blocks into trunk 2023-06-21 08:45:38 +02:00
github-actions[bot] 28535000db Release: 10.4.3 (https://github.com/woocommerce/woocommerce-blocks/pull/9919)
* Empty commit for release pull request

* Update Hero Product 3-split pattern image

* Update Banner Pattern To Replace Unsplash Image (https://github.com/woocommerce/woocommerce-blocks/pull/9760)

* Update Banner to replace Unsplash image.

Replaces the Unsplash image with a CCO licensed image from Pxhere. Also
updates the CTA button to link to the Shop page, by default.

* Remove extra padding from top of test column.

Vertical alignment was off on the text column due to 60px of top
padding. This aligns everythign, as expected.

* Update Chessboard pattern images (https://github.com/woocommerce/woocommerce-blocks/pull/9761)

* Updathe the Hero Product Split (https://github.com/woocommerce/woocommerce-blocks/pull/9762)

* Remove unused pattern image (https://github.com/woocommerce/woocommerce-blocks/pull/9763)

* Update Images for the Product Details Patterns (https://github.com/woocommerce/woocommerce-blocks/pull/9764)

* Update image for the Product Hero pattern.

Replace the Unsplash image with a CCO licensed image from Pxhere.

* Update images for Prod List Gallery Desc pattern

Replace the Unsplash image with a CCO licensed image from Pxhere for the
Product Listing with Gallery and Description pattern.

* Remove unneeded Unsplash images.

* Update copy for Prod Listing Gallery Desc pattern.

* Optimize new image exports.

* Update image for the Product Listing pattern.

Replace the Unsplash image with a CCO licensed image from Pxhere.

* Update images for Product Details pattern.

Replace the Unsplash images with CCO licensed images from Pxhere.

* Remove unneeded Unsplash image.

* Use Relative URLs for Images in the Product Listing Pattern

This commit replaces hardcoded URLs with dynamic ones for image placeholders in the `product-listing-with-gallery-and-description.php` pattern file.

- The `plugins_url()` function is now used to generate URLs, which correctly points to the images folder within the WooCommerce Blocks plugin directory. This approach provides better flexibility and portability since it doesn't rely on a specific domain or path. The `esc_url()` function is used to ensure the URL is safe to use in the HTML context.

- The change is made for a total of four images in the pattern.

---------

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

* Update/patterns featured category product collection (https://github.com/woocommerce/woocommerce-blocks/pull/9765)

* Update image for featured category focus pattern

* Update image for featured category cover image pattern

* Update images for featured category triple pattern

* Change to wide width

* Update links to buttons

* Fix typo in hex color value.

There was an extra `f` in the hex color value, causing the text to
unexpectedly render black.

---------

Co-authored-by: Daniel W. Robert <danielwrobert@gmail.com>

* Update/collection pattern images (https://github.com/woocommerce/woocommerce-blocks/pull/9766)

* Update featured collections images

* Add shop link to shop by price pattern

* Update hero product pattern title (https://github.com/woocommerce/woocommerce-blocks/pull/9769)

* Remove unused pattern image (https://github.com/woocommerce/woocommerce-blocks/pull/9770)

* Add 10.4.2 changelog in readme.txt

* Update version number to 10.4.2

* Add testing instructions for 10.4.2

* Add 9769 PR testing steps

* WooCommerce Classic Template block: Fix error on clearing customizations on Woo Templates (https://github.com/woocommerce/woocommerce-blocks/pull/9759)

* Fix Classic Template block error on clearing customizations on template

* Add link to issue in JS Doc

* Change the way of debug check of tests-mysql container (https://github.com/woocommerce/woocommerce-blocks/pull/9794)

* Add alt text to images used in patterns describing their purpose (https://github.com/woocommerce/woocommerce-blocks/pull/9788)

* Add alt text to images used in patterns describing their purpose

* Replace 1/3 notation with 1 out of 3, so it's better handled byt screen readers

* Update testing instructions to include 9759 PR

* Update zip to include 9759 PR

* Remove 9759 PR from testing instructions

* Mini Cart Block: show the total price, including tax, according to the option (https://github.com/woocommerce/woocommerce-blocks/pull/9878)

* Mini Cart Block: show the total price, including tax, according to the option

* Fix tests in PR 9878 (https://github.com/woocommerce/woocommerce-blocks/pull/9880)

* add unit test

---------

Co-authored-by: Karol Manijak <karol.manijak@automattic.com>

* Mini-Cart: don't include shipping price (https://github.com/woocommerce/woocommerce-blocks/pull/9914)

* Products Block: fix grid view with Gutenberg 16 (https://github.com/woocommerce/woocommerce-blocks/pull/9916)

* Revert "fix products block layout on gutenberg 16 (https://github.com/woocommerce/woocommerce-blocks/pull/9886)"

This reverts commit 53665a5bde.

* add post_template_has_support_for_grid_view setting

* add testing instructions

* bump version

* update zip link

* Empty commit for release pull request

* update link

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Alba Rincón <alba.rincon@automattic.com>
Co-authored-by: Daniel W. Robert <danielwrobert@users.noreply.github.com>
Co-authored-by: Alba Rincón <albarin@users.noreply.github.com>
Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
Co-authored-by: Roy Ho <roykho77@gmail.com>
Co-authored-by: Daniel W. Robert <danielwrobert@gmail.com>
Co-authored-by: Tarun Vijwani <tarun.vijwani@automattic.com>
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
Co-authored-by: Karol Manijak <karol.manijak@automattic.com>
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2023-06-21 08:38:10 +02:00
Daniel Dudzic d981395148 Mini Cart: Hide template part from the block inserter. Closes woocommerce/woocommerce-blocks#9753 (https://github.com/woocommerce/woocommerce-blocks/pull/9906) 2023-06-20 22:28:16 +02:00
Albert Juhé Lluveras ddacb581bb Remove unnecessary white space from Testimonials 3 Columns pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9786) 2023-06-20 17:44:02 +02:00
Chris Jayden d9b87d5a56 docs: add link to batching cart item (https://github.com/woocommerce/woocommerce-blocks/pull/9776) 2023-06-20 08:41:16 -07:00
Karol Manijak bc2bcf2ec4 Fix PHP CS warnings (https://github.com/woocommerce/woocommerce-blocks/pull/9857) 2023-06-20 16:19:43 +02:00
Luigi b19213cabd Merge branch 'release/10.5.0' of https://github.com/woocommerce/woocommerce-blocks into release/10.5.0 2023-06-20 16:14:53 +02:00
Luigi 2349af5216 update zip link 2023-06-20 16:14:39 +02:00
Luigi Teschio eb24313fb0 Products Block: fix grid view with Gutenberg 16 (https://github.com/woocommerce/woocommerce-blocks/pull/9916)
* Revert "fix products block layout on gutenberg 16 (https://github.com/woocommerce/woocommerce-blocks/pull/9886)"

This reverts commit 53665a5bde.

* add post_template_has_support_for_grid_view setting
2023-06-20 16:12:43 +02:00
Luigi Teschio e285dd0879 Products Block: fix grid view with Gutenberg 16 (https://github.com/woocommerce/woocommerce-blocks/pull/9916)
* Revert "fix products block layout on gutenberg 16 (https://github.com/woocommerce/woocommerce-blocks/pull/9886)"

This reverts commit 53665a5bde.

* add post_template_has_support_for_grid_view setting
2023-06-20 14:12:30 +00:00
Alba Rincón fe8330d2a8 `Featured Products 5-item grid` fix alignment (https://github.com/woocommerce/woocommerce-blocks/pull/9913)
* Styling and improvements

* Fix pattern alignment

---------

Co-authored-by: roykho <roykho77@gmail.com>
2023-06-20 15:49:43 +02:00
Roy Ho a5271fcbe3 Styling and improvements (https://github.com/woocommerce/woocommerce-blocks/pull/9893) 2023-06-20 06:09:12 -07:00
Roy Ho 93a43b791a Make use of product search (https://github.com/woocommerce/woocommerce-blocks/pull/9890) 2023-06-20 06:08:04 -07:00
Luigi Teschio e92393684c Update docs/internal-developers/testing/releases/1050.md
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2023-06-20 14:52:31 +02:00
Luigi Teschio 70cb05b991 Update docs/internal-developers/testing/releases/1050.md
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2023-06-20 14:52:23 +02:00
Luigi 50998bc9fa update testing instructions 2023-06-20 14:46:37 +02:00
Albert Juhé Lluveras 25f8137e9c Mini-Cart: don't include shipping price (https://github.com/woocommerce/woocommerce-blocks/pull/9914) 2023-06-20 14:45:30 +02:00
Albert Juhé Lluveras 99dd12e6c7 Mini-Cart: don't include shipping price (https://github.com/woocommerce/woocommerce-blocks/pull/9914) 2023-06-20 14:41:37 +02:00
Luigi 20be12a52c update zip link 2023-06-20 11:58:01 +02:00
Niels Lange e39cc21444 Reference Mini Cart drawer preview dynamically (https://github.com/woocommerce/woocommerce-blocks/pull/9912)
* Reference Mini Cart drawer preview dynamically

* Update assets/js/blocks/mini-cart/edit.tsx

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

---------

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2023-06-20 11:56:36 +02:00
Niels Lange 532393fe07 Reference Mini Cart drawer preview dynamically (https://github.com/woocommerce/woocommerce-blocks/pull/9912)
* Reference Mini Cart drawer preview dynamically

* Update assets/js/blocks/mini-cart/edit.tsx

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

---------

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2023-06-20 11:52:53 +02:00
Alba Rincón df5f1d21d1 Improve spacing and centering in responsive designs (https://github.com/woocommerce/woocommerce-blocks/pull/9877) 2023-06-20 10:30:51 +02:00
Luigi 08842ef392 update screenshot 2023-06-20 10:30:27 +02:00
Luigi 8b1cfe6c87 update testing instructions 2023-06-20 10:26:41 +02:00
Alba Rincón 5aa3779a62 Add shop link to the button (https://github.com/woocommerce/woocommerce-blocks/pull/9879) 2023-06-20 09:12:32 +02:00
Luigi 8f0d480f73 update testing instruction for woocommerce/woocommerce-blocks#9809 2023-06-20 09:12:05 +02:00
Luigi 6443868725 update zip link 2023-06-20 09:01:26 +02:00
Luigi 6b9c38dfc7 add woocommerce/woocommerce-blocks#9886 PR 2023-06-20 09:00:08 +02:00
Luigi Teschio b8d072b291 fix products block layout on gutenberg 16 (https://github.com/woocommerce/woocommerce-blocks/pull/9886) 2023-06-20 08:57:31 +02:00
Luigi Teschio 53665a5bde fix products block layout on gutenberg 16 (https://github.com/woocommerce/woocommerce-blocks/pull/9886) 2023-06-20 08:56:55 +02:00
Manish Menaria a6c1a2de52 Add E2E tests for Product Collection Block (https://github.com/woocommerce/woocommerce-blocks/pull/9825)
* Add E2E tests for Product Collection Block

This commit does the following changes:

1. Adjusts the .gitignore file to ignore the test-results and artifacts directories under all subdirectories named 'e2e-pw'.

2. Adds new E2E tests for the Product Collection block, specifically testing:
   - If the block renders correctly, including validating the number of product images, titles, prices, and 'Add to Cart' buttons.
   - If the sidebar settings correctly control the number of displayed columns.

3. Implements the 'ProductCollectionPage' class, providing methods to perform actions such as creating a new post, inserting a block, publishing a post, and locating various elements on the page.

4. Adjusts the directory structure for the E2E tests to improve organization and readability.

* Minor improvements

* Update E2E tests for Product Collection block sidebar settings

This commit updates the E2E tests for the sidebar settings of the Product Collection block. The changes include:

1. Refactoring the test assertions to use property accessors instead of method calls for the `ProductCollectionPage` class. This improves readability and consistency.

2. Updating the `ProductCollectionPage` class to initialize locators for editor and frontend elements separately. This allows easier differentiation between editor and frontend locators.

The test file `sidebar-settings.block_theme.spec.ts` has been deleted, as its functionality is now covered by the updated tests in `product-collection.block_theme.spec.ts`.

* Don't update package.json files

* Don't update gitignore file

* Add E2E test for order by control

This commit updates the E2E tests for the sidebar settings and order by control of the Product Collection block. The changes include:

1. Refactoring the test assertions and descriptions for improved readability and clarity.

2. Adding a new test case to verify the correct sorting of products by title in descending order.

3. Updating the `ProductCollectionPage` class to include a new method `setOrderBy()` to set the order by value in the order by control.

4. Adding a new method `waitForProductsToLoad()` in the `ProductCollectionPage` class to wait for the products to load in the block.

These changes ensure that the sidebar settings and order by control are functioning correctly in the Product Collection block.

* Minor improvements

* Add tests for "on sale" filter

* Add tests for Hand picked products filter

This commit updates the E2E tests for the handpicked products filter in the Product Collection block. The changes include:

1. Adding a new test case to verify that products can be filtered based on the selection in the handpicked products option.

2. Adding a new method `addFilter()` to the `ProductCollectionPage` class to select a filter option from the dropdown.

3. Adding a new method `setHandpickedProducts()` to the `ProductCollectionPage` class to set the handpicked products in the block settings.

These changes ensure that the handpicked products filter is functioning correctly in the Product Collection block.

* Verify that on sale filter works on frontend

Adding assertions to verify the count and presence of on-sale products in the frontend after publishing.

* Add tests for Keyword filter

This commit updates the E2E tests for the keyword filter in the Product Collection block. The changes include:

1. Adding assertions to verify that the products are correctly filtered based on the keyword entered.

2. Adding assertions to verify the filtered products in the frontend after publishing.

These changes ensure that the keyword filter in the Product Collection block is functioning correctly.

* Use fixture to setup product collection page

This commit refactors the E2E tests for the Product Collection block to improve test structure and readability. The changes include:

1. Refactoring the test structure using the `test.extend` function to define shared setup and teardown logic.

2. Moving the creation of the `ProductCollectionPage` instance to the shared setup logic.

3. Using the `pageObject` fixture in each test to access the `ProductCollectionPage` instance.

4. Removing duplicate code for creating the `ProductCollectionPage` instance.

These changes enhance the maintainability and readability of the E2E tests for the Product Collection block.
2023-06-20 10:56:12 +05:30
Thomas Roberts 3ebcd7f601 Add `CartEventContext` and dispatch events when pressing proceed to checkout button (https://github.com/woocommerce/woocommerce-blocks/pull/7809)
* Add CartEventsContext with onProceedToCheckout event

* Wrap Cart in CartEventsProvider

* Dispatch onProceedToCheckout event when button is pressed

* Update type of children on CartEventsProvider

* Add test for ProceedToCheckout block

* Add tests for CartEventProvider

* Remove superfluous div

* Fix incorrect nesting after rebase

* Wrap mini cart in CartEventsProvider

* Dispatch onProceedToCheckout event when clicking button in mini cart

* Add tests for mini cart onProceedToCheckout emitter

* Make observer fail so navigation isn't attempted

* Prevent console error on navigation

* Try preventing navigation in unit tests

* Try preventing navigation in unit tests

* Try preventing navigation in unit tests

* Try preventing navigation in unit tests

* Try preventing navigation in unit tests

* Try preventing navigation in unit tests

* Try preventing navigation in unit tests
2023-06-19 08:44:37 -07:00
Luigi 51bc46594d add woocommerce/woocommerce-blocks#9878 PR 2023-06-19 17:15:55 +02:00
Luigi Teschio b585355fda Mini Cart Block: show the total price, including tax, according to the option (https://github.com/woocommerce/woocommerce-blocks/pull/9878)
* Mini Cart Block: show the total price, including tax, according to the option

* Fix tests in PR 9878 (https://github.com/woocommerce/woocommerce-blocks/pull/9880)

* add unit test

---------

Co-authored-by: Karol Manijak <karol.manijak@automattic.com>
2023-06-19 17:14:51 +02:00
Luigi Teschio bc6dc106ab Mini Cart Block: show the total price, including tax, according to the option (https://github.com/woocommerce/woocommerce-blocks/pull/9878)
* Mini Cart Block: show the total price, including tax, according to the option

* Fix tests in PR 9878 (https://github.com/woocommerce/woocommerce-blocks/pull/9880)

* add unit test

---------

Co-authored-by: Karol Manijak <karol.manijak@automattic.com>
2023-06-19 17:14:35 +02:00
Luigi e190f46064 update zip file testing 2023-06-19 15:51:46 +02:00
Luigi edd3dd38da add woocommerce/woocommerce-blocks#9869 PR 2023-06-19 15:23:12 +02:00
Alexandre Lara 677d66f137 Fix PropType warning and error when adding All Reviews block to Editor (https://github.com/woocommerce/woocommerce-blocks/pull/9869) 2023-06-19 15:17:07 +02:00
Daniel Dudzic 8835140c41 Mini Cart: Fix un-strict comparisons (https://github.com/woocommerce/woocommerce-blocks/pull/9837) 2023-06-19 12:57:04 +02:00
Alexandre Lara 48696c6727 Fix PropType warning and error when adding All Reviews block to Editor (https://github.com/woocommerce/woocommerce-blocks/pull/9869) 2023-06-19 15:39:54 +05:30
Daniel Dudzic de425c9efb Mini Cart: Add Price, Icon and Product Count color settings (https://github.com/woocommerce/woocommerce-blocks/pull/9647)
* Mini Cart: Update color settings to include Price, Icon and Product Count.

* Fix color settings in the editor.

* Mini Cart: Add color settings for the Price, Icon and Product Count.

* Mini Cart: Remove unnecessary color settings.

* Remove unnecessary code comments.

* Update color settings labels.

* Add price color to the tax label.

* Add missing docs comment

* Fix TS errors

* Fix TS error

* Adjust type declaration

* Add TS error comments

* Change @ts-to-do to @ts-expect-error

---------

Co-authored-by: tjcafferkey <tjcafferkey@gmail.com>
2023-06-19 11:42:37 +02:00
Luigi 244cdf86e2 add testing instructions 2023-06-19 11:39:43 +02:00
Luigi 028d0a90ab bump version 2023-06-19 11:38:19 +02:00
Luigi 8758f586e4 add readme 2023-06-19 10:05:54 +02:00
Alexandre Lara 8a6e1cdb76 Adjust PropTypes definition and fix block error when store has no reviews (https://github.com/woocommerce/woocommerce-blocks/pull/9868) 2023-06-19 12:37:57 +05:30
Karol Manijak 115ccca4f9 Don't treat Dependabot as community contributor (https://github.com/woocommerce/woocommerce-blocks/pull/9254)
* Test commit

* Don't treat dependabot as a community

* Remove unwanted change

* Make the check for ignored usernames clearer
2023-06-19 08:49:59 +02:00
Manish Menaria eec844f447 Add Display Settings Toolbar to the Product Collection Block (https://github.com/woocommerce/woocommerce-blocks/pull/9747)
This commit introduces the 'Display Settings' toolbar for the 'Product Collection' block in the Gutenberg editor.
- A new component 'DisplaySettingsToolbar' is added in 'display-settings-toolbar.tsx'. It includes controls for changing the number of items per page, the offset, and the maximum number of pages to show in the block. The toolbar only shows up when the 'inherit' query attribute is set to false.
- The 'DisplaySettingsToolbar' component is then integrated into the main 'edit.tsx' file through 'ToolbarControls'.
- Styles have also been added to 'editor.scss' to ensure the popover content of the display settings toolbar has an appropriate minimum width.
2023-06-19 10:37:05 +05:30
Niels Lange d70481ed8c Update available-slot-fills.md 2023-06-18 20:08:05 +02:00
Brian 8dacf20cef Update Keywords for Customer Account Block in block.json (https://github.com/woocommerce/woocommerce-blocks/pull/9815)
Co-authored-by: Karol Manijak <karol.manijak@automattic.com>
Co-authored-by: Niels Lange <info@nielslange.de>
2023-06-18 19:42:08 +02:00
Alexandre Lara c5e8cc2256 Refactor: Convert with-transform-single-select-to-multiple-select.js to with-transform-single-select-to-multiple-select.tsx and replace propTypes with TypeScript definitions (https://github.com/woocommerce/woocommerce-blocks/pull/9798)
* Transform file from Javascript to Typescript

* Add SelectOption type and default value to selected prop
2023-06-16 16:24:12 -03:00
Alexandre Lara e5dd772c94 Convert Product On Sale block file from JS to TS (https://github.com/woocommerce/woocommerce-blocks/pull/9834) 2023-06-16 13:43:54 -03:00
Alexandre Lara ba47d5dc40 Refactor: Convert All Products block file from Javascript to Typescript and replace propTypes with TypeScript definitions (https://github.com/woocommerce/woocommerce-blocks/pull/9802)
* Convert All Products block from Javascript to Typescript

* Replace BlockAttributes type with local interface
2023-06-16 12:48:47 -03:00
Karol Manijak f12c35ffc2 Temporarily skip PHP Unit Tests for PHP 8.1 and 8.2 (https://github.com/woocommerce/woocommerce-blocks/pull/9859)
* Allow failure of the PHP Unit Tests

* Limit the PHP versions to 7.4 and 8.0 to run unit tests

* Don't allow failing fast

* Add a comment explaining the skipped part

* Cancel jobs later

* Cancel all the steps in workflow based on the same condition
2023-06-16 14:16:19 +02:00
Niels Lange 0d94479bbe Update README.md 2023-06-16 13:59:30 +02:00
Mike Jolley 496fac8386 Performance: Cache script data in a transient for production builds (https://github.com/woocommerce/woocommerce-blocks/pull/9120)
* Cache script data in a transient for production builds

* Store as json

* Disable cache when script debug is on

* Disable in test environment

* Simplify caching structure

* Put back cache buster

* Fix update_script_data_cache

* Merge dependencies param always—do not cache it
2023-06-16 12:21:51 +01:00
Mike Jolley ee4e0fac18 Keep change button visible even if prefersCollection is true (https://github.com/woocommerce/woocommerce-blocks/pull/9809) 2023-06-16 12:21:19 +01:00
Mike Jolley 4d14426ecb Request 2.88.2 (https://github.com/woocommerce/woocommerce-blocks/pull/9827) 2023-06-16 11:46:03 +01:00
Alba Rincón 8a67ae2f80 Convert `edit.js` to `edit.tsx` and replace `propTypes` with TypeScript definitions (https://github.com/woocommerce/woocommerce-blocks/pull/9823)
* Remove proptypes

* Refactor after review
2023-06-16 09:30:54 +02:00
Alba Rincón 2460a04abd Remove propTypes (https://github.com/woocommerce/woocommerce-blocks/pull/9824) 2023-06-15 16:21:02 +02:00
Alba Rincón e423c4fde9 Add a default attribute to the pattern if exists (https://github.com/woocommerce/woocommerce-blocks/pull/9812)
* Add a default attribute to the pattern if exists

* Use esc_attr instead of esc_html
2023-06-15 16:07:47 +02:00
Karol Manijak 1eebcd6750 Replace Automated tests badge with E2E and Unit tests badges (https://github.com/woocommerce/woocommerce-blocks/pull/9836) 2023-06-15 14:23:23 +02:00
Daniel Dudzic cc6a9eab48 Mini Cart: Fix icon render (https://github.com/woocommerce/woocommerce-blocks/pull/9828) 2023-06-14 18:42:56 +02:00
Mike Jolley c30c6afc53 Wait for cart to be removed when emptied (https://github.com/woocommerce/woocommerce-blocks/pull/9829) 2023-06-14 16:59:21 +01:00
Roy Ho 31138031f6 Convert grid-layout-control to use Typescript (https://github.com/woocommerce/woocommerce-blocks/pull/9811) 2023-06-14 07:07:28 -07:00
dependabot[bot] 4c012300c1 Bump mockery/mockery from 1.6.1 to 1.6.2 (https://github.com/woocommerce/woocommerce-blocks/pull/9796)
Bumps [mockery/mockery](https://github.com/mockery/mockery) from 1.6.1 to 1.6.2.
- [Release notes](https://github.com/mockery/mockery/releases)
- [Changelog](https://github.com/mockery/mockery/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mockery/mockery/compare/1.6.1...1.6.2)

---
updated-dependencies:
- dependency-name: mockery/mockery
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-14 15:05:10 +01:00
Roy Ho 6270c39de8 Convert inner-block-layout-context to typescript (https://github.com/woocommerce/woocommerce-blocks/pull/9799)
* Convert inner-block-layout-context to typescript

* Add isLoading context
2023-06-14 06:36:39 -07:00
Mike Jolley 524b95acbd Bump fast-xml-parser from 4.0.7 to 4.2.4 (https://github.com/woocommerce/woocommerce-blocks/pull/9818)
* Bump fast-xml-parser from 4.0.7 to 4.2.4

Bumps [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) from 4.0.7 to 4.2.4.
- [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases)
- [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/NaturalIntelligence/fast-xml-parser/compare/v4.0.7...v4.2.4)

---
updated-dependencies:
- dependency-name: fast-xml-parser
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update package lock

* Update package

* Revert other package lock changes

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-14 14:32:19 +01:00
github-actions[bot] 09e9fb9388 Release: 10.4.2 (https://github.com/woocommerce/woocommerce-blocks/pull/9784)
* Empty commit for release pull request

* Update Hero Product 3-split pattern image

* Update Banner Pattern To Replace Unsplash Image (https://github.com/woocommerce/woocommerce-blocks/pull/9760)

* Update Banner to replace Unsplash image.

Replaces the Unsplash image with a CCO licensed image from Pxhere. Also
updates the CTA button to link to the Shop page, by default.

* Remove extra padding from top of test column.

Vertical alignment was off on the text column due to 60px of top
padding. This aligns everythign, as expected.

* Update Chessboard pattern images (https://github.com/woocommerce/woocommerce-blocks/pull/9761)

* Updathe the Hero Product Split (https://github.com/woocommerce/woocommerce-blocks/pull/9762)

* Remove unused pattern image (https://github.com/woocommerce/woocommerce-blocks/pull/9763)

* Update Images for the Product Details Patterns (https://github.com/woocommerce/woocommerce-blocks/pull/9764)

* Update image for the Product Hero pattern.

Replace the Unsplash image with a CCO licensed image from Pxhere.

* Update images for Prod List Gallery Desc pattern

Replace the Unsplash image with a CCO licensed image from Pxhere for the
Product Listing with Gallery and Description pattern.

* Remove unneeded Unsplash images.

* Update copy for Prod Listing Gallery Desc pattern.

* Optimize new image exports.

* Update image for the Product Listing pattern.

Replace the Unsplash image with a CCO licensed image from Pxhere.

* Update images for Product Details pattern.

Replace the Unsplash images with CCO licensed images from Pxhere.

* Remove unneeded Unsplash image.

* Use Relative URLs for Images in the Product Listing Pattern

This commit replaces hardcoded URLs with dynamic ones for image placeholders in the `product-listing-with-gallery-and-description.php` pattern file.

- The `plugins_url()` function is now used to generate URLs, which correctly points to the images folder within the WooCommerce Blocks plugin directory. This approach provides better flexibility and portability since it doesn't rely on a specific domain or path. The `esc_url()` function is used to ensure the URL is safe to use in the HTML context.

- The change is made for a total of four images in the pattern.

---------

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

* Update/patterns featured category product collection (https://github.com/woocommerce/woocommerce-blocks/pull/9765)

* Update image for featured category focus pattern

* Update image for featured category cover image pattern

* Update images for featured category triple pattern

* Change to wide width

* Update links to buttons

* Fix typo in hex color value.

There was an extra `f` in the hex color value, causing the text to
unexpectedly render black.

---------

Co-authored-by: Daniel W. Robert <danielwrobert@gmail.com>

* Update/collection pattern images (https://github.com/woocommerce/woocommerce-blocks/pull/9766)

* Update featured collections images

* Add shop link to shop by price pattern

* Update hero product pattern title (https://github.com/woocommerce/woocommerce-blocks/pull/9769)

* Remove unused pattern image (https://github.com/woocommerce/woocommerce-blocks/pull/9770)

* Add 10.4.2 changelog in readme.txt

* Update version number to 10.4.2

* Add testing instructions for 10.4.2

* Add 9769 PR testing steps

* WooCommerce Classic Template block: Fix error on clearing customizations on Woo Templates (https://github.com/woocommerce/woocommerce-blocks/pull/9759)

* Fix Classic Template block error on clearing customizations on template

* Add link to issue in JS Doc

* Change the way of debug check of tests-mysql container (https://github.com/woocommerce/woocommerce-blocks/pull/9794)

* Add alt text to images used in patterns describing their purpose (https://github.com/woocommerce/woocommerce-blocks/pull/9788)

* Add alt text to images used in patterns describing their purpose

* Replace 1/3 notation with 1 out of 3, so it's better handled byt screen readers

* Update testing instructions to include 9759 PR

* Update zip to include 9759 PR

* Remove 9759 PR from testing instructions

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Alba Rincón <alba.rincon@automattic.com>
Co-authored-by: Daniel W. Robert <danielwrobert@users.noreply.github.com>
Co-authored-by: Alba Rincón <albarin@users.noreply.github.com>
Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
Co-authored-by: Roy Ho <roykho77@gmail.com>
Co-authored-by: Daniel W. Robert <danielwrobert@gmail.com>
Co-authored-by: Tarun Vijwani <tarun.vijwani@automattic.com>
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
Co-authored-by: Karol Manijak <karol.manijak@automattic.com>
2023-06-13 19:18:40 +04:00
Tarun Vijwani fe1294729e Merge remote-tracking branch 'origin/trunk' into trunk 2023-06-13 16:13:47 +04:00
Tarun Vijwani eed8d5088e Add testing notes and changelog of 10.4.2 2023-06-13 16:13:03 +04:00
Hritik Chaudhary 563b439f25 Migrate Block Title component to TypeScript (https://github.com/woocommerce/woocommerce-blocks/pull/9712)
Co-authored-by: Niels Lange <info@nielslange.de>
Co-authored-by: Alba Rincón <albarin@users.noreply.github.com>
Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
2023-06-13 16:30:57 +05:30
Daniel W. Robert 9f87afde32 Apply further optimizations to pattern images. (https://github.com/woocommerce/woocommerce-blocks/pull/9803)
Ran images through imagemin with the pngquant plugin to reduce the file
sizes for our pattern images.
2023-06-12 22:22:44 -04:00
Daniel Dudzic 0a23aca517 Mini Cart: Add an alternative icon setting (https://github.com/woocommerce/woocommerce-blocks/pull/9570)
* Mini Cart: Add an icon setting with 3 alternative icon options. Closes woocommerce/woocommerce-blocks#8556.

* Mini Cart: Fix Mini-cart icons in the toggle setting.

* Minor type fixes.

* Clean up type definitions.

* Move alt icon logic to a separate function.

* Fix cart icons sizes

* Add a negative margin to the mini cart icon
2023-06-12 22:23:52 +02:00
Karol Manijak b7f1ac2b4e Add alt text to images used in patterns describing their purpose (https://github.com/woocommerce/woocommerce-blocks/pull/9788)
* Add alt text to images used in patterns describing their purpose

* Replace 1/3 notation with 1 out of 3, so it's better handled byt screen readers
2023-06-12 19:34:03 +02:00
Karol Manijak 42e95d1c54 Change the way of debug check of tests-mysql container (https://github.com/woocommerce/woocommerce-blocks/pull/9794) 2023-06-12 19:00:27 +02:00
Alexandre Lara 06a9b274c1 WooCommerce Classic Template block: Fix error on clearing customizations on Woo Templates (https://github.com/woocommerce/woocommerce-blocks/pull/9759)
* Fix Classic Template block error on clearing customizations on template

* Add link to issue in JS Doc
2023-06-12 13:55:20 -03:00
Hritik Chaudhary e17221ac79 Removed proptypes and js to ts conversion for Product Categories (https://github.com/woocommerce/woocommerce-blocks/pull/9755)
* Removed proptypes from product-categories

* deleted js file
2023-06-12 18:52:21 +02:00
Karol Manijak 1e849ff3c3 Disable the debug check of tests-mysql to let PHP unit tests pass (https://github.com/woocommerce/woocommerce-blocks/pull/9791) 2023-06-12 17:20:04 +02:00
Alba Rincón ae4757a53f Port to trunk testing notes and readme from 10.2.3 2023-06-09 16:33:08 +02:00
Albert Juhé Lluveras 0be2ef2d84 Fix capitalization in Product Collections: Newest Arrivals pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9777) 2023-06-09 16:04:53 +02:00
Albert Juhé Lluveras a89a229b37 Prevent Mini-Cart table to show horizontal scrollbar (https://github.com/woocommerce/woocommerce-blocks/pull/9676) 2023-06-09 10:48:23 +02:00
Alba Rincón 2b5c73d47e Remove unused pattern image (https://github.com/woocommerce/woocommerce-blocks/pull/9770) 2023-06-09 09:41:15 +02:00
Alba Rincón bc00fbd22b Update hero product pattern title (https://github.com/woocommerce/woocommerce-blocks/pull/9769) 2023-06-09 09:18:30 +02:00
Daniel W. Robert 13a48fb62e Update Images for the Product Details Patterns (https://github.com/woocommerce/woocommerce-blocks/pull/9764)
* Update image for the Product Hero pattern.

Replace the Unsplash image with a CCO licensed image from Pxhere.

* Update images for Prod List Gallery Desc pattern

Replace the Unsplash image with a CCO licensed image from Pxhere for the
Product Listing with Gallery and Description pattern.

* Remove unneeded Unsplash images.

* Update copy for Prod Listing Gallery Desc pattern.

* Optimize new image exports.

* Update image for the Product Listing pattern.

Replace the Unsplash image with a CCO licensed image from Pxhere.

* Update images for Product Details pattern.

Replace the Unsplash images with CCO licensed images from Pxhere.

* Remove unneeded Unsplash image.

* Use Relative URLs for Images in the Product Listing Pattern

This commit replaces hardcoded URLs with dynamic ones for image placeholders in the `product-listing-with-gallery-and-description.php` pattern file.

- The `plugins_url()` function is now used to generate URLs, which correctly points to the images folder within the WooCommerce Blocks plugin directory. This approach provides better flexibility and portability since it doesn't rely on a specific domain or path. The `esc_url()` function is used to ensure the URL is safe to use in the HTML context.

- The change is made for a total of four images in the pattern.

---------

Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
2023-06-09 12:13:19 +05:30
Roy Ho 1041bce0e4 Update/patterns featured category product collection (https://github.com/woocommerce/woocommerce-blocks/pull/9765)
* Update image for featured category focus pattern

* Update image for featured category cover image pattern

* Update images for featured category triple pattern

* Change to wide width

* Update links to buttons

* Fix typo in hex color value.

There was an extra `f` in the hex color value, causing the text to
unexpectedly render black.

---------

Co-authored-by: Daniel W. Robert <danielwrobert@gmail.com>
2023-06-09 00:37:25 -04:00
Roy Ho f4da27ca56 Update/collection pattern images (https://github.com/woocommerce/woocommerce-blocks/pull/9766)
* Update featured collections images

* Add shop link to shop by price pattern
2023-06-09 00:07:52 -04:00
Alba Rincón 49a98abef2 Remove unused pattern image (https://github.com/woocommerce/woocommerce-blocks/pull/9763) 2023-06-08 16:30:23 -04:00
Alba Rincón d78c5e57ef Update Chessboard pattern images (https://github.com/woocommerce/woocommerce-blocks/pull/9761) 2023-06-08 16:28:00 -04:00
Alba Rincón 0aa4ba69d0 Updathe the Hero Product Split (https://github.com/woocommerce/woocommerce-blocks/pull/9762) 2023-06-08 16:27:48 -04:00
Daniel W. Robert 43b6f62ad0 Update Banner Pattern To Replace Unsplash Image (https://github.com/woocommerce/woocommerce-blocks/pull/9760)
* Update Banner to replace Unsplash image.

Replaces the Unsplash image with a CCO licensed image from Pxhere. Also
updates the CTA button to link to the Shop page, by default.

* Remove extra padding from top of test column.

Vertical alignment was off on the text column due to 60px of top
padding. This aligns everythign, as expected.
2023-06-08 16:00:55 -04:00
Alba Rincón 9aa1e3448f Update Hero Product 3-split pattern image 2023-06-08 21:41:35 +02:00
Roy Ho 8e94500136 Use correct SVG for RTL display (https://github.com/woocommerce/woocommerce-blocks/pull/9756) 2023-06-08 11:29:34 -07:00
Roy Ho bb60a90f5c Convert product-orderby-control to use typescript (https://github.com/woocommerce/woocommerce-blocks/pull/9751) 2023-06-08 05:56:57 -07:00
Tarun Vijwani 27ba84cd84 Update version number to 10.5.0-dev 2023-06-08 15:31:29 +04:00
Tarun Vijwani ac99027225 Cherry pick updated 10.4.0 testing steps 2023-06-08 14:53:22 +04:00
Tarun Vijwani 0833316129 Cherry-pick 10.4.0 testing steps 2023-06-08 14:51:50 +04:00
Tarun Vijwani 8bcbeb8c0e Cherry-pick 10.4.0 changelogs 2023-06-08 14:43:54 +04:00
Albert Juhé Lluveras aa912e31a8 Fix the order of enqueued scripts in the Mini-Cart block (https://github.com/woocommerce/woocommerce-blocks/pull/9749)
* Fix the order of enqueued scripts in the Mini-Cart block

* Use again wp_script_is() to detect is a script has been enqueued or not
2023-06-08 10:37:00 +02:00
Tarun Vijwani c6d0f30989 Remove experimental blocks from the changelog 2023-06-08 11:36:21 +04:00
Manish Menaria d91385e3b9 Product Collection: Hand picked products control in sidebar settings (https://github.com/woocommerce/woocommerce-blocks/pull/9733)
* Add support for hand-picked products in Product Collection block

This commit introduces the ability to manually select specific products in the Product Collection block.

Changes include:
- Added `woocommerceHandPickedProducts` to the `ProductCollectionQuery` and `DEFAULT_FILTERS` in `constants.ts`.
- Created a new control file `hand-picked-products-control.tsx` which introduces a token field where the user can search for and select specific products.
- Included `HandPickedProductsControl` in the Product Collection block's inspector controls in `index.tsx`.
- Updated `ProductCollectionQuery` in `types.ts` to accommodate handpicked products.
- Updated the PHP `ProductCollection` class to handle the hand-picked products query parameters.

These changes allow users to hand-pick products to be displayed in the Product Collection block. This allows for greater customization of the products shown in the block.

* Enhance handling of hand-picked products

- A Set data structure is now used to store 'newHandPickedProducts' instead of an Array, which will help prevent duplicate entries.
- Additionally, the suggestions for products to be hand-picked now excludes already selected products, enhancing the user experience by avoiding redundancy in the suggestions list.
- Lastly, the function name 'displayTransform' has been changed to 'transformTokenIntoProductName' to more accurately reflect its purpose, which is to transform a token into a product name.

* Update import & export of HandPickedProductsControl
2023-06-08 06:03:01 +00:00
Manish Menaria 1814bc95e5 Product Collection: Add author filter in sidebar settings (https://github.com/woocommerce/woocommerce-blocks/pull/9736)
* Add author filter to ProductCollection block

This commit adds an author filter to the ProductCollection block in WooCommerce Blocks.

- A new file, `author-control.tsx`, has been created inside the `inspector-controls` directory of the `product-collection` block. This file contains the React component for the author filter, which fetches the list of authors from the WordPress database using `useEntityRecords`. The filter provides an interface for selecting authors whose products should be displayed in the ProductCollection block.

- The author filter is added to the main component of the `inspector-controls` in `index.tsx`.

- In `ProductCollection.php`, the 'author' parameter is now included in the product query. This allows products from a specific author to be displayed in the ProductCollection block, depending on the user's selection in the Gutenberg editor.

This addition enhances the functionality of the ProductCollection block by allowing site administrators to create more customized and targeted displays of products.

* Update error handling

* Refactor 'Author' interfaces and fix offset calculation

This commit refactors the 'Author' interfaces in the 'author-control.tsx' file. The interface 'AuthorsMapping' has been removed and its properties have been merged into 'AuthorsInfo' for simplicity and maintainability.

In the PHP file 'ProductCollection.php', the offset calculation logic has been improved to handle pagination correctly. Now, the offset is calculated as '(per_page * (page - 1)) + offset', which correctly accounts for both the page number and the offset when determining the starting point for the product query.
2023-06-08 11:10:05 +05:30
Tarun Vijwani 0f3e9340f0 Cherry pick 9684 PR as it got merged after release branch was created 2023-06-07 23:37:49 +04:00
Luigi Teschio 460b8a5034 Product rating: improve preview style when the product doesn't have rating (https://github.com/woocommerce/woocommerce-blocks/pull/9684)
* product rating: improve preview style when no rating is visible

* fix class naming

* fix cutted star

* change variable

* fix cut border
2023-06-07 23:32:31 +04:00
Tarun Vijwani 5f60dbbd6c Update testing zip file to include 9748 PR 2023-06-07 21:52:06 +04:00
Tarun Vijwani 9468a9c0d8 Cherry-pick 9748 2023-06-07 21:44:20 +04:00
Alba Rincón 8eb7b16af0 Render the single product title as an h1 (https://github.com/woocommerce/woocommerce-blocks/pull/9748) 2023-06-07 21:31:24 +04:00
Alba Rincón 06a0ab94ce Render the single product title as an h1 (https://github.com/woocommerce/woocommerce-blocks/pull/9748) 2023-06-07 15:47:56 +02:00
Tarun Vijwani 76601b3971 Remove expiremental block from testing notes 2023-06-07 16:56:56 +04:00
Roy Ho 70e3533467 Prevent showing edit product details link when in multiple products context (https://github.com/woocommerce/woocommerce-blocks/pull/9741) 2023-06-07 05:43:04 -07:00
Tarun Vijwani 910cd98b58 Move 9691 PR to WC core 2023-06-07 16:11:46 +04:00
Hritik Chaudhary af09b0c9b8 Removed proptypes from grid-content-control (https://github.com/woocommerce/woocommerce-blocks/pull/9713)
Co-authored-by: Niels Lange <info@nielslange.de>
Co-authored-by: Alba Rincón <albarin@users.noreply.github.com>
2023-06-07 13:22:50 +02:00
Thomas Roberts aa1fe5c308 Add text limit to payment method descriptions in the page editor (https://github.com/woocommerce/woocommerce-blocks/pull/9708)
* Convert summary/utils to TS

* Add @wordpress/wordcount type defs

* Move trimWords, trimCharacters, remoteTags & appendMoreText to own file

* Add tests for trimWords and related functions

* Trim payment method description if it is longer than 30 words
2023-06-07 02:29:15 -07:00
Alba Rincón cbfd2977dd [Patterns] Update button color for `Hero Product 3 Split` (https://github.com/woocommerce/woocommerce-blocks/pull/9467)
* Add color to the search button, fix php notices

* Update button color

* Update button color

* Update button color

* Update button color

* Update button color

* Remove WooCommerce from the name to follow standards

* Remove colors from buttons in patterns without hardcoded bg color
2023-06-07 10:10:07 +02:00
Tom Cafferkey 24a293bde7 Fix/escape add query arg template url (https://github.com/woocommerce/woocommerce-blocks/pull/9715)
* Escape postId for template part within MiniCart

* Escape  url

* Change esc_url to esc_url_raw
2023-06-06 16:42:19 +01:00
Roy Ho dc6fa4a8c9 Fix value without onchaning warning (https://github.com/woocommerce/woocommerce-blocks/pull/9727) 2023-06-06 06:04:40 -07:00
Hritik Chaudhary 93119e9de6 Remove propTypes definitions from All Reviews block (https://github.com/woocommerce/woocommerce-blocks/pull/9631)
* converted all-reviews block to tsx and removed proptypes

* Update assets/js/blocks/reviews/all-reviews/index.tsx

Co-authored-by: Niels Lange <niels.lange@a8c.com>

* Update assets/js/blocks/reviews/all-reviews/edit.tsx

Co-authored-by: Niels Lange <niels.lange@a8c.com>

* Update assets/js/blocks/reviews/all-reviews/block.tsx

Co-authored-by: Niels Lange <niels.lange@a8c.com>

---------

Co-authored-by: Niels Lange <info@nielslange.de>
Co-authored-by: Niels Lange <niels.lange@a8c.com>
2023-06-06 14:46:49 +02:00
Tarun Vijwani bfa3cff71a Add more details in testing instructions for 9684 PR 2023-06-06 16:01:54 +04:00
Tarun Vijwani ce95cfea7c Update testing instructions for 9684 PR 2023-06-06 15:53:15 +04:00
Alba Rincón ceba20832f Update zip for testing 2023-06-06 11:35:15 +02:00
Tarun Vijwani 5ceb6e5b8c Cherry pick 9723 PR 2023-06-06 12:34:05 +04:00
dependabot[bot] 525bd58c74 Bump mockery/mockery from 1.5.1 to 1.6.1 (https://github.com/woocommerce/woocommerce-blocks/pull/9728)
Bumps [mockery/mockery](https://github.com/mockery/mockery) from 1.5.1 to 1.6.1.
- [Release notes](https://github.com/mockery/mockery/releases)
- [Changelog](https://github.com/mockery/mockery/blob/1.6.1/CHANGELOG.md)
- [Commits](https://github.com/mockery/mockery/compare/1.5.1...1.6.1)

---
updated-dependencies:
- dependency-name: mockery/mockery
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-06 10:27:55 +02:00
Luigi Teschio eddaf34918 Single Product Template: fix Compatibility Layer when the template implements the Single Product Template (https://github.com/woocommerce/woocommerce-blocks/pull/9723) 2023-06-06 12:27:17 +04:00
Tarun Vijwani b8fdeb4b68 Fix version number in testing notes 2023-06-06 12:23:14 +04:00
Tarun Vijwani 4cf62bd787 Add testing instructions for the release 2023-06-06 12:21:45 +04:00
Alba Rincón 643bdbe4df [Patterns] Add new `Footer with Simple Menu and Cart` pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9176)
* Add new `Footer with Simple Menu and Cart` pattern

* Remove ref, overlay off

* Improve search, navigation and separator

* Improve the mobile view

* Make string translatable
2023-06-06 08:56:20 +02:00
Luigi Teschio a69f0874e5 Single Product Template: fix Compatibility Layer when the template implements the Single Product Template (https://github.com/woocommerce/woocommerce-blocks/pull/9723) 2023-06-05 17:48:36 +02:00
Luigi Teschio a27787fb17 Product rating: improve preview style when the product doesn't have rating (https://github.com/woocommerce/woocommerce-blocks/pull/9684)
* product rating: improve preview style when no rating is visible

* fix class naming

* fix cutted star

* change variable

* fix cut border
2023-06-05 17:27:55 +02:00
Alexandre Lara 27275b913e Refactor: Add useIsDescendentOfSingleProductTemplate hook (https://github.com/woocommerce/woocommerce-blocks/pull/9657)
* Add useIsDescendentOfSingleProductTemplate hook

* Replace logic with useIsDescendentOfSingleProductTemplate hook
2023-06-05 12:13:28 -03:00
Tarun Vijwani 7ccf34dcc4 Update readme and version details 2023-06-05 18:52:43 +04:00
Tom Cafferkey 0f59e3f698 Checkout block: Full width Place Order button when Return To Cart link is disabled. (https://github.com/woocommerce/woocommerce-blocks/pull/9721)
* When the Return To Cart link is disabled, make Place Order button full width

* Optional prop fullWidth has undefined type added to it
2023-06-05 15:31:32 +01:00
dependabot[bot] 3d853d77d5 Bump automattic/jetpack-autoloader from 2.11.19 to 2.11.21 (https://github.com/woocommerce/woocommerce-blocks/pull/9639)
Bumps [automattic/jetpack-autoloader](https://github.com/Automattic/jetpack-autoloader) from 2.11.19 to 2.11.21.
- [Release notes](https://github.com/Automattic/jetpack-autoloader/releases)
- [Changelog](https://github.com/Automattic/jetpack-autoloader/blob/trunk/CHANGELOG.md)
- [Commits](https://github.com/Automattic/jetpack-autoloader/compare/v2.11.19...v2.11.21)

---
updated-dependencies:
- dependency-name: automattic/jetpack-autoloader
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-05 16:24:44 +02:00
dependabot[bot] 01ad02ffbe Bump tj-actions/branch-names from 6 to 7 (https://github.com/woocommerce/woocommerce-blocks/pull/9688)
Bumps [tj-actions/branch-names](https://github.com/tj-actions/branch-names) from 6 to 7.
- [Release notes](https://github.com/tj-actions/branch-names/releases)
- [Changelog](https://github.com/tj-actions/branch-names/blob/main/HISTORY.md)
- [Commits](https://github.com/tj-actions/branch-names/compare/v6...v7)

---
updated-dependencies:
- dependency-name: tj-actions/branch-names
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-05 16:22:55 +02:00
dependabot[bot] d14bd2f605 Bump dependabot/fetch-metadata from 1.4.0 to 1.5.1 (https://github.com/woocommerce/woocommerce-blocks/pull/9689)
Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.4.0 to 1.5.1.
- [Release notes](https://github.com/dependabot/fetch-metadata/releases)
- [Commits](https://github.com/dependabot/fetch-metadata/compare/v1.4.0...v1.5.1)

---
updated-dependencies:
- dependency-name: dependabot/fetch-metadata
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-05 16:21:17 +02:00
Roy Ho 5a5d5d315a Make mini cart icon RTL on RTL sites in editor (https://github.com/woocommerce/woocommerce-blocks/pull/9707)
* Make mini cart icon RTL on RTL sites in editor

* Use BEM convention
2023-06-05 06:36:57 -07:00
Alba Rincón 4cd22fb705 Create `Customer account` block e2e playwright tests (https://github.com/woocommerce/woocommerce-blocks/pull/9505)
* Create customer account block playwright tests

* Refactor after review

* Refacto after review
2023-06-05 14:39:11 +02:00
Luigi Teschio 4c3cb1ab17 Enable Single Product block (https://github.com/woocommerce/woocommerce-blocks/pull/9714)
* Enable Single Product block

* Single Product Block: remove experimental build flag
2023-06-05 12:11:21 +00:00
Luigi Teschio 5b862f3fb1 Product Rating: fix the filter woocommerce_product_get_rating_html is removed (https://github.com/woocommerce/woocommerce-blocks/pull/9719) 2023-06-05 13:41:35 +02:00
Luigi Teschio 57c5d4a89a Product Price: remove underline on sale price (https://github.com/woocommerce/woocommerce-blocks/pull/9702) 2023-06-05 07:56:25 +00:00
Alexandre Lara 2438ce41a6 Add to Cart with Options block: Prevent page redirection when clicking on Add to Cart button (https://github.com/woocommerce/woocommerce-blocks/pull/9691)
* Add isDescendentOfSingleProductBlock attribute to Add to Cart Form block

* Prevent notice from appearing when Add to Cart button is clicked

When the Add to Cart Form is added inside the Single Product Block, we
have to prevent the notice from appearing when the Add to Cart button is
clicked.

* Fix PHP CS errors

* Fix PHP CS errors

* Fix PHP CS errors

* Fix PHP CS errors

* Fix PHP CS errors

* Fix PHP CS errors

* Add phpcs:ignore WordPress.Security.NonceVerification.Recommended

* Fix Processing form data without nonce verification.

* PHP Ignore

* Improve doc comments

* Improve name for add_to_cart_message_html_filter hook

* Prevent page redirection when click on Add to Cart button

* Fix PHP CS errors
2023-06-05 09:50:48 +02:00
Karol Manijak 37d4823680 Product Collection - Add Inherit query from template control (https://github.com/woocommerce/woocommerce-blocks/pull/9485)
* Add columns control to product collection block editor settings

- `InspectorControls` from './inspector-controls' is now imported in `edit.tsx` and used in the returned JSX of `Edit` function.
- A new file `columns-control.tsx` is added under 'product-collection' block's 'inspector-controls' directory which exports a `ColumnsControl` component. This component uses `RangeControl` from '@wordpress/components' to control the number of columns in the product collection display layout when the layout type is 'flex'.
- The types file (`types.ts`) for 'product-collection' block is updated. The `Attributes` interface is renamed to `ProductCollectionAttributes` and the `ProductCollectionContext` interface is removed. The `ProductCollectionAttributes` now includes 'queryContext', 'templateSlug', and 'displayLayout' properties.

* Refactor: Simplify Fallback Return in ColumnsControl Component

This commit simplifies the fallback return value of the ColumnsControl component. Instead of returning an empty fragment (<> </>), it now returns null when the condition isn't met. This change improves readability and aligns with best practices for conditional rendering in React.

* Feature: Add 'Order By' Control to Product Collection Inspector

This commit adds a new 'Order By' control to the product collection inspector. The control allows users to specify the order of products in a collection by various attributes such as title and date. To support this, a new component 'OrderByControl' has been created and included in the product collection inspector. Additionally, the types for 'order' and 'orderBy' attributes have been updated and exported for reuse.

* Add more options to OrderBy type

* Add Inherit global query control to the Product Collection

* Add orderby handling on frontend & editor

The main changes include:
1. Added a new property 'isProductCollectionBlock' in the block.json to denote if a block is a product collection block.
2. In the ProductCollection PHP class, a new initialization function has been defined to hook into the WordPress lifecycle, register the block, and update the query based on this block.
3. Added methods to manage query parameters for both frontend rendering and the Editor.
4. Expanded allowed 'collection_params' for the REST API to include custom 'orderby' values.
5. Defined a function to build the query based on block attributes, filters, and global WP_Query.
6. Created utility functions to handle complex query operations such as merging queries, handling custom sort values, and merging arrays recursively.

These improvements allow for more flexible and robust handling of product collections in both the front-end display and the WordPress editor. It also extends support for custom 'orderby' values in the REST API, which allows for more advanced sorting options in product collections.

* Fix the condition to show query controls (they shoul appear if query is NOT inherited)

* Make Product Collection inheirt global query in product archive templates by default

* Add 'on sale' filter and enhance settings management in product collection block

This commit introduces several changes to the product collection block.
- First, it adds a new 'on sale' filter that can be used to display only the products that are currently on sale.
- It also refactors the settings management in the product collection block to use the experimental ToolsPanel component from WordPress, which provides a more flexible and intuitive way to manage block settings.
- It moves the 'Columns' control into the ToolsPanel, along with the 'Order by' control.
- A new utility function `setQueryAttribute` is introduced to simplify setting nested query parameters.
- The structure of the `ProductCollectionAttributes` and `ProductCollectionQuery` types have been adjusted to accommodate the changes.
- Finally, it makes corresponding changes in the PHP part to handle the new 'on sale' query parameter.

This should enhance the flexibility and user-friendliness of the product collection block.

* Revert "Make Product Collection inheirt global query in product archive templates by default"

This reverts commit d257e8bdb014742c40ef069110f6a2a35148fb7a.

* Updated 'inherit' behavior in the Product Collection block

This commit updates the 'inherit' behavior in the Product Collection block and its associated controls.

Changes include:
- Removed the 'inherit' attribute from the block's JSON definition
- Defined an array of 'archive product templates' which includes the WooCommerce product archive, taxonomy, attribute, and search results templates.
- Set the initial 'inherit' value based on the current template ID when the Product Collection block is first added to the page.
- Restored the query object value when toggling 'inherit' off.
- Conditionally rendered the InheritQueryControl based on the current editor being the site editor.

* Add stock status filter to WooCommerce product collection block

This commit introduces a stock status filter to the WooCommerce product collection block.

The changes include:
1. Added the ability to filter products based on their stock status within the 'product-collection' block. A new stock status control is created within the inspector-controls of the block.
2. A new 'get_stock_status_query' function is introduced in 'ProductCollection.php' which returns a query for products depending on their stock status.

Please note that the stock status filter will only appear in the experimental build for now.

* Refactor Stock Status control of Product Collection block

This commit refactors the Stock Status control. The changes aim to improve the code organization and make the behavior of the component more explicit.

The key modifications are:
1. Moved stock status related constants and functions from `inspector-controls/utils.tsx` to `inspector-controls/constants.ts`. This is done to ensure that all constants and similar utility functions are organized in one place.
2. Updated `product-collection/index.tsx` to import `getDefaultStockStatuses` from `inspector-controls/constants` instead of `inspector-controls/utils`.
3. Updated `stock-status-control.tsx` to determine whether the stock status has value or not by comparing with the default stock statuses using `fastDeepEqual`. If the stock status control is deselected, it resets the stock status to the default statuses.

These changes do not introduce any new functionalities, but improve the readability and maintainability of the code.

* Add keyword search control to Product Collection block

This commit introduces a keyword search functionality to the Product Collection block. The update is aimed to provide users with more flexibility and precision in product collection queries.

Key changes:
1. Introduced a new file `keyword-control.tsx` that creates a Keyword Control component. This component includes a TextControl field that allows inputting a search keyword. The keyword search is debounced to prevent unnecessary queries during input and updates the block's attributes accordingly.
2. Modified `inspector-controls/index.tsx` to include the KeywordControl in the ToolsPanel for the block's filters.
3. Adjusted `ProductCollection.php` to include the keyword search in the product query array.

With these changes, users can now search for products by keyword in the Product Collection block.

* Add product attributes filter control to ProductCollection block

- This commit introduces the ability to filter products by attributes in ProductCollection block.
- A new `woocommerceAttributes` key was added to the `block.json` file and the `ProductCollectionQuery` type. Also, a new file `attributes-control.tsx` was created, providing the UI component for the attribute filter control in the editor.
- In addition, updates were made to the `ProductCollection.php` file in the backend to support filtering products by attributes, and the tax query was updated to include attribute queries.
- Lastly, the `ProductCollectionInspectorControls` was updated to include the `AttributesControl` component, thus enabling users to filter products by attributes in the block editor."`

* remove unused import of getDefaultStockStatuses

* Delete a duplicate file

* Remove console log

* Add taxonomies control to Product collection block

The primary changes include:
1. `taxQuery` field in the `ProductCollectionAttributes` was changed from a string to an object in `assets/js/blocks/product-collection/types.ts` and `assets/js/blocks/product-collection/constants.ts`, accommodating the ability to query products by taxonomy terms.

2. `assets/js/blocks/product-collection/inspector-controls/utils.tsx` was moved to `assets/js/blocks/product-collection/utils.tsx` to make it available for broader use.

3. New component `TaxonomyControls` was created in `assets/js/blocks/product-collection/inspector-controls/taxonomy-controls.tsx`, which is included in `assets/js/blocks/product-collection/inspector-controls/index.tsx`. This new control allows users to filter products in the block by their taxonomy terms.

4. Updated the block's inspector controls in `assets/js/blocks/product-collection/inspector-controls/index.tsx` to use the new `TaxonomyControls` component.

Please note that the TaxonomyControls component uses experimental features of WordPress's FormTokenField. As a result, a comment has been added to disable eslint warnings regarding the use of experimental APIs.

* Address PR feedback & other improvements

1. Added `woocommerceAttributes` to `DEFAULT_FILTERS` in the `product-collection/constants.ts` file to fix `reset all` button issue.

2. Refactored `attributes-control.tsx` to make it more maintainable:
   - The constant `EDIT_ATTRIBUTES_URL` now uses `ADMIN_URL` from `@woocommerce/settings` for a more dynamic URL generation.
   - The interface `Props` has been renamed to `AttributesControlProps` for more explicit naming.
   - Removed the usage of `useState` and `useEffect` for selected attributes. Instead, `selectedAttributes` is now directly derived from `woocommerceAttributes`.
   - The CSS class `woocommerce-product-query-panel__external-link` was renamed to `wc-product-collection-panel__external-link`

3. Deleted the `product-collection/inspector-controls/constants.ts` file which was no longer necessary due to changes in product collection implementation.

These changes contribute to codebase quality, improving readability and maintainability.

* Address PR review comments

This commit involves a significant refactoring of the default product query inside the 'product-collection/constants.ts' file. A new constant `DEFAULT_QUERY` has been defined and used to replace the previously hard-coded default query settings. This refactoring aids in code readability and future modifications.

Changes also include adjustments in 'product-collection/inspector-controls' to enhance UI/UX. A new SCSS file 'editor.scss' has been created for custom styles related to the editor.

Additions include:
- Adding a class name `product-collection-inspector-toolspanel__filters` to ToolsPanel for additional styling.
- The experimental property `__experimentalShowHowTo` is set to false for `FormTokenField` and `StockStatusControl`, to hide some additional information.

In 'product-collection/inspector-controls/taxonomy-controls.tsx', the classname `product-collection-inspector__taxonomy-control` is added for improved CSS targeting.

* Add wc-block-editor prefix to className

* Make improvements to 'inherit' functionality in Product collection block.

Key changes are:

1. 'inherit' in 'ProductCollectionAttributes' within 'constants.ts' has been changed from 'false' to 'null'. This accommodates for situations when Product collection block is first added to the page.

2. Various improvements in 'index.tsx' file which include more robust null checking for the 'query' object, simplifying the way 'woocommerceAttributes' is obtained, and passing 'setQueryAttributeBind' and 'inherit' to the 'InheritQueryControl' component.

3. In 'inherit-query-control.tsx', 'InheritQueryControl' component has been refactored to use '__experimentalToolsPanelItem' from '@wordpress/components' instead of 'ToggleControl'. This adds more flexibility to the control.

4. Changes in 'ProductCollectionAttributes' and 'ProductCollectionQuery' types in 'types.ts'. The

* Improve product collection query inheritance and fix URL typo

This commit addresses two primary areas:
1. Fixed a typo in the URL used as a reference in the use-previous.ts file. The URL was incorrectly case-sensitive, which has been corrected.

2. The product-collection block in the JavaScript files has been refactored for better handling of query inheritance:

   - Changed the 'inherit' value from false to null in the DEFAULT_QUERY constant to handle initial state more accurately.

   - In product-collection/inspector-controls, implemented conditional rendering for Filters and Query Controls based on 'displayQueryControls'. Also, improved the 'InheritQueryControl' by using the 'usePrevious' hook to maintain the state before enabling the inheritance.

   - In inherit-query-control, enhanced the control to toggle the query inheritance. It now considers the 'inherit' state from the query object and keeps track of the query object state before enabling inheritance. If the inheritance is toggled off, it reverts the query to the previous state before inheritance was enabled.

* Minor improvemnets

* Add wc-block-editor- prefix with classNames

* Handle duplicate taxonomy names in Taxonomy controls

the taxonomy controls have been enhanced in the following ways:
1. Modified the BASE_QUERY object to include 'slug' in the '_fields' property. This will ensure that the 'slug' of the taxonomy term is fetched along with its 'id' and 'name'.

2. Added a 'slug' property to the Term type to store the 'slug' of each term.

3. Updated the useEffect hook inside the TaxonomyItem function to generate suggestions based on search results. The suggestions now include the 'slug' of a term if the term's name is not unique. This change will help users distinguish between terms with the same name but different slugs.

* Remove isset() in if condition as it's unnecessary

* Refactor TaxonomyItem component for better readability

Following changes were made:

1. The useSelect hooks which were being used to fetch existing terms and search results have been moved into their own custom hooks named 'useExistingTerms' and 'useSearchResults' respectively. This simplifies the TaxonomyItem function's body and makes the hooks' purposes clearer.

2. The comments and props destructuring for the TaxonomyItem function have been moved up to make it easier to understand the function's purpose and the props it receives.

3. This refactor does not introduce any changes in functionality. It only changes how the code is organized and presented, which will make future development easier.

* Handling for duplicate term names & other improvements

This commit enhances the `TaxonomyControls` component within `product-collection` block by adding memoization and improving term uniqueness handling.

Changes:

1. Imported `useMemo` from `@wordpress/element` for memoizing certain results.

2. `getTermIdByTermValue` function has been modified to use a `termIdToNameMap` (term ids as keys and term names as values). This provides a more efficient and direct mapping for term search.

3. Introduced `useTermIdToNameMap` function, which returns a `Map` where term ids are keys and term names are values. It handles duplicate term names by appending the term slug to the name, ensuring unique term names.

4. Updated the `useExistingTerms` and `useSearchResults` to include `taxonomy` in their dependency arrays for `useSelect` hook. This will force re-computation when `taxonomy` changes.

5. Changed `TaxonomyItem` from a function declaration to a const arrow function, consistent with the rest of the codebase.

6. Updated `onTermsChange` function in `TaxonomyItem` to accommodate the changes in `getTermIdByTermValue` and the introduction of `termIdToNameMap`.

7. Replaced `Set` with a standard array for storing new term IDs in `onTermsChange`. The `Set` was unnecessary as term IDs are unique by default.

8. Updated `TaxonomyItem`'s effects and rendering to work with `termIdToNameMap`, ensuring the displayed term names are unique.

This update will result in more efficient term search and handling, and it will solve issues related to duplicate term names.

* Restructure taxonomy controls in product collection block

This commit restructures the taxonomy controls in the product collection block for improved clarity and maintainability.
- The file `taxonomy-controls.tsx` has been deleted, and its functionality has been divided into two new files: `index.tsx` and `taxonomy-item.tsx`.

- The `index.tsx` file contains the main TaxonomyControls component, which is responsible for displaying taxonomy-related options in the block's inspector controls. It includes a custom hook `useTaxonomies` that fetches and returns taxonomies associated with product post type.

- The `taxonomy-item.tsx` file, on the other hand, contains a TaxonomyItem component that handles the rendering of individual taxonomy items. It also contains some utility functions for mapping term names and ids and fetching terms based on the search query.

This refactor aims to improve code readability and separation of concerns, thus making future changes and maintenance easier.

* Fix case insensitive search support for FormTokenField

This change enhances the search functionality of the FormTokenField by introducing support for case insensitive search. This has been achieved by adding a lower-case version of the term name to the 'termNameToIdMap'.

This is an important enhancement as it will make the search process more user-friendly and resilient to different casing inputs. Users will now be able to find the desired taxonomy term regardless of their input's case.

* Refactor getTermIdByTermValue function and update newSuggestions mapping

This commit does a couple of important things:
1. Reorders the definition of constants in `TaxonomyItemProps` for clarity.
2. Refactors the `getTermIdByTermValue` function. Instead of checking for an exact term name match in a convoluted manner, it now directly tries to fetch the `id` from the `searchTerm` if it is an object. If the `searchTerm` is not an object, the function tries to match it against the `termNameToIdMap` in both normal and lowercase forms. This simplification makes the function more readable and concise.
3. Updates the `newSuggestions` mapping in the `TaxonomyItem` component. It now has a fallback to `searchResult.name` if a term's name is not found in `termIdToNameMap`. This change ensures that even if the term's name is not in the map for some reason, we can still display a suggestion using the original name of the term.

* Optimize term fetching and initial search state in TaxonomyItem

This commit introduces a couple of improvements to the TaxonomyItem component.

1. The initial state of the 'search' state variable has been updated to 'undefined'. This change helps prevent unnecessary initial fetching of terms when the search input is empty.

2. Term fetching logic has been optimized to only enable term fetching when necessary:
   a) Fetching based on the search query is only enabled when 'search' is not 'undefined'.
   b) Fetching existing terms is only enabled when there are term IDs.

3. The block of code responsible for fetching existing terms and setting the current value has been moved upwards. This reordering of code does not change the functionality, but it groups together similar pieces of code, enhancing readability and maintainability.

These optimizations make the component more efficient by reducing unnecessary requests and computations, and they improve the code organization.

* Address PR comments and other improvements

This commit makes several changes:
1. The useEffect that sets the default attributes was moved and modified. This now includes a `query` attribute that utilizes the imported function `getDefaultValueOfInheritQueryFromTemplate`.
2. An early return was added in `edit.tsx` to prevent rendering until default attributes are set.
3. In `columns-control.tsx`, the early return was removed and a label was added to the `RangeControl` component.
4. In `inherit-query-control.tsx`, logic related to `inherit` value initial setting was refactored using a `useMemo` hook with `getDefaultValueOfInheritQueryFromTemplate` function. This logic was moved to a separate utility function in `utils`.
5. The `query` attribute is no longer optional in `types.ts`.
6. A new utility function `getDefaultValueOfInheritQueryFromTemplate` was created in `utils.tsx` to encapsulate the logic of deciding the default value of `inherit` query attribute based on the current template.

These changes aim to improve code clarity and maintainability.

* Add  with types import statement

---------

Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
2023-06-05 06:09:11 +00:00
Tom Cafferkey ebffcf3031 Fix esc_html error in footer pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9704) 2023-06-02 14:57:58 -04:00