Commit Graph

5673 Commits

Author SHA1 Message Date
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
Alexandre Lara 5f307e1097 Add to Cart Form block: Prevent notice from appearing after clicking on Add to Cart button inside Single Product block (https://github.com/woocommerce/woocommerce-blocks/pull/9685)
* 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

* Replace equal operator with identity operator in the conditional statement
2023-06-02 11:29:22 -03:00
Luigi Teschio d85a6ecbd2 Blockified Single Product Template: add product-classes via `wc_get_product_class` (https://github.com/woocommerce/woocommerce-blocks/pull/9697)
* Blockified Single Product Template: add product-classes via wc_get_product_class

* Update src/BlockTemplatesController.php

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

---------

Co-authored-by: Karol Manijak <karol.manijak@automattic.com>
2023-06-02 14:16:20 +00:00
Luigi Teschio 278f0ec0db Blockified Single Product Template: avoid to add another group block on the editor side when the user creates a template for a specific product (https://github.com/woocommerce/woocommerce-blocks/pull/9699)
* Blockified Single Product Template: avoid to add another group block on the editor side when the user creates a template for a specific product

* improve comment
2023-06-02 15:59:20 +02:00
Luigi Teschio 136762ee78 Blockified Single Product Template: use h1 for the Product Title (https://github.com/woocommerce/woocommerce-blocks/pull/9698) 2023-06-02 12:36:18 +00:00
Patricia Hillebrandt 4d1a490a18 Product Image Gallery > Reintroduce filters and override-restore the global product variable. (https://github.com/woocommerce/woocommerce-blocks/pull/9630)
* Reintroduce filters to the product gallery block and override/restore the global product variable.

* Restore the product global variable earlier and update docblock for the get_block_type_uses_context method.
2023-06-02 16:47:30 +05:30
Manish Menaria 9426102565 Product Collection: Add Taxonomy filters to sidebar settings (https://github.com/woocommerce/woocommerce-blocks/pull/9634)
* 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 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.

* 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.

* 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

* 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.

---------

Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
2023-06-02 15:31:29 +05:30
Hritik Chaudhary cec26fa849 Remove propTypes definitions from Reviews By Category (https://github.com/woocommerce/woocommerce-blocks/pull/9623)
* converted reviews-by-category block

* converted index.js to tsx

* fix imports

* removed unnecessary metadata

* added type explicitly
2023-06-02 07:53:16 +02:00
Roy Ho cd84b4bed3 Add e2e tests for attributes count (https://github.com/woocommerce/woocommerce-blocks/pull/9500)
* Add e2e tests for attributes count

* Add test with pricing filter and turn on debug to prevent cache

* Prevent tests from passing if test page is not loaded

* Use WP wrapper to call WC CLI

* Refactor to use more of PW methods

* Use existing active filters block post for testing

* Move prepareAttributes function to global setup
2023-06-01 07:14:50 -07:00
Mike Jolley 30b5a1107a Update test command so PHP unit tests can be ran locally again (https://github.com/woocommerce/woocommerce-blocks/pull/9678)
* Update test command so tests can be ran locally again

* Update mappings instead

* Put back ${PWD##*/ for current dir

* Try mapping both paths
2023-06-01 13:42:23 +01:00
Roy Ho a67948d7e1 Ensure aria-label is showing correct value based on setting (https://github.com/woocommerce/woocommerce-blocks/pull/9672)
* Ensure aria-label is showing correct value based on setting

* Reuse same format code
2023-06-01 05:41:43 -07:00
Saad Tarhi bdf9a5e218 Fix local pickup e2e test (https://github.com/woocommerce/woocommerce-blocks/pull/9643)
Co-authored-by: Niels Lange <info@nielslange.de>
2023-06-01 13:01:36 +01:00
Luigi Teschio f17a09340f Enable blockified templates (https://github.com/woocommerce/woocommerce-blocks/pull/9551)
* Enable blockified templates

* add html template

* fix function

* WIP

* Migrate Classic Block E2E tests to Playwright (https://github.com/woocommerce/woocommerce-blocks/pull/9575)

* Add E2E tests

* add comment

* set worker to 1

* try now

* add beforeAll and afterAll hook

* restore woocommerce-gutenberg-products-block.php

* enable plugin with .wp-env configuration

* remove waitForNetworkIdle

* Products block: Add e2e tests (https://github.com/woocommerce/woocommerce-blocks/pull/9577)

* migrate classic block to Playwright

* fix can be inserted more than once tests

* migrate classic block to Playwright

* fix command

* remove old tests

* improve E2E tests

* skip test

* Products block: add E2E pw tests

* Add E2E tests

* fix E2E test

* test now

* try now

* rename path

* set one worker

* try now

* try now

* try now

* set 1 worker
2023-06-01 11:51:59 +00:00
Albert Juhé Lluveras c45ac22b02 Add 10.2.2 testing steps 2023-05-31 17:13:55 +02:00
Albert Juhé Lluveras 28edcf308b Add 10.2.2 changelog 2023-05-31 17:12:44 +02:00
Albert Juhé Lluveras 73ffb371d2 Fix colors not being applied to Mini-Cart Proceed to Checkout Button in the editor (https://github.com/woocommerce/woocommerce-blocks/pull/9661) 2023-05-31 13:58:20 +02:00
Tom Cafferkey 801b7846e7 Product Categories List: Add show child categories only toggle (https://github.com/woocommerce/woocommerce-blocks/pull/9550)
* Add show child categories only toggle to Product Categories block

* Check if current page is a template editor before adding the toggle

* Show current category if show_children is enabled and its the last category in the hierarchy

* Update comment

* Fix typo

* Remove forward slash

* Add is-widget-editor utility and enable feature for block usage in widget editor

* Don't render anything if the child only option is enabled and there are no children
2023-05-31 12:49:31 +01:00
Mike Jolley c6e0ca1d8b Combine country asset data to reduce the amount of data consumed by the cart and checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/9552)
* Combine countryData using shared util

* Update tests for shared util

* Update client to use countryData

* Avoid duplication of country names

* Use cart version of deep_sort_with_accents

* Update assets/js/settings/blocks/constants.ts

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

* Update LocaleSpecificAddressField type

* Support nested arrays

---------

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
2023-05-31 10:30:44 +01:00
Roy Ho 5f5a0d4b54 Stack cart and checkout buttons on smaller screens (https://github.com/woocommerce/woocommerce-blocks/pull/9603) 2023-05-30 13:07:30 -07:00
Albert Juhé Lluveras b17cdaa1da Add 10.0.6 testing steps 2023-05-30 21:53:25 +02:00
Albert Juhé Lluveras 59f2175bae Add 10.0.6 changelog 2023-05-30 21:52:18 +02:00
Albert Juhé Lluveras 4da98fde56 Fix Mini-Cart block check to see whether a script has already been enqueued (https://github.com/woocommerce/woocommerce-blocks/pull/9649) 2023-05-30 18:37:43 +02:00
Thomas Roberts fcedb41bbc Remove `setFullAddressPushed` to prevent address continually pushing (https://github.com/woocommerce/woocommerce-blocks/pull/9606)
* Remove fullShippingAddressPushed action/selectors etc from wc/store/cart

* Remove setFullAddressPushed from push-changes
2023-05-30 08:46:18 -07:00
Albert Juhé Lluveras bc34d9faaf Prevent horizontal shift when opening the Mini-Cart drawer if scrollbars are visible (https://github.com/woocommerce/woocommerce-blocks/pull/9648)
* Fix wrong TS name

* Prevent page horizontal shift when opening the Mini-Cart drawer when scrollbars are visible
2023-05-30 17:09:11 +02:00
Mike Jolley 50ad36321a Use CSSProperties in place of Records for useStyleProps (https://github.com/woocommerce/woocommerce-blocks/pull/9483)
* Use CSSProperties in place of Records

* Update types from StyleEngine

* Remove parseStyle

* Combine StyleProps type
2023-05-30 14:45:59 +01:00
Albert Juhé Lluveras c267504bd6 Use a portal to render the Drawer close button to fix the alignment with the Mini-Cart Contents block (https://github.com/woocommerce/woocommerce-blocks/pull/9507) 2023-05-30 15:39:19 +02:00
Alexandre Lara 6b105f0504 Product Rating block: Add the block to the Single Product template by default (https://github.com/woocommerce/woocommerce-blocks/pull/9510)
* Add Single Product template support to Product Rating block

* Add the Product Rating block to the Single Product Template by default

* Fix Product Rating block position on Single Product HTML template
2023-05-30 10:10:25 -03:00
Roy Ho 3f216104a2 Ensure inner content is not truncated on different widths (https://github.com/woocommerce/woocommerce-blocks/pull/9640) 2023-05-30 06:06:48 -07:00
Luigi Teschio 1ed5a06d86 Replace placeholder blockified templates with the right one (https://github.com/woocommerce/woocommerce-blocks/pull/9579)
* Add blockified templates

* removed queryId
2023-05-30 14:10:46 +02:00
Manish Menaria a6c31a7878 [Product Collection] Add `Attributes` filter control to sidebar settings (https://github.com/woocommerce/woocommerce-blocks/pull/9600)
* 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 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.

* 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.

* 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

* 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.

* Add wc-block-editor prefix to className

---------

Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
2023-05-30 11:06:26 +00:00
Albert Juhé Lluveras 27e3a9a3cc Fix invisible Mini-Cart badge in themes without <body> background (https://github.com/woocommerce/woocommerce-blocks/pull/9601) 2023-05-30 10:36:29 +02:00
Niels Lange 8a9bcd4d13 Adjust contributor docs (https://github.com/woocommerce/woocommerce-blocks/pull/9622)
* Adjust contributor docs

* Adjust contributor docs
2023-05-30 13:30:36 +07:00
Alexandre Lara 134b12bef7 Product Rating block: Add Single Product template support to the block (https://github.com/woocommerce/woocommerce-blocks/pull/9499)
* Add Single Product template support to Product Rating block

* Remove example attribute from block.json

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

* Set isDescedentOfSingleProductTemplate attribute default to false

* Remove withProductSelector HOC

Since we are using the `ancestor` key then we don't need to use this HOC anymore

* Remove unused import on Product Rating Edit component

---------

Co-authored-by: Luigi Teschio <gigitux@gmail.com>
2023-05-29 16:54:36 -03:00
Luigi Teschio ec797e689f restore upsell products (https://github.com/woocommerce/woocommerce-blocks/pull/9636) 2023-05-29 15:46:55 +02:00
Hritik Chaudhary 86e96c0d0b Remove propTypes definitions from Newest Products block (https://github.com/woocommerce/woocommerce-blocks/pull/9613)
* converted product-new block

* converted product-new block

* filename changes in readme and checkstyle.xml

---------

Co-authored-by: Niels Lange <info@nielslange.de>
2023-05-29 13:12:36 +07:00
Hritik Chaudhary 2e1193b2a9 removed proptypes from add-to-cart (https://github.com/woocommerce/woocommerce-blocks/pull/9615)
Co-authored-by: Niels Lange <info@nielslange.de>
2023-05-29 11:13:25 +07:00
Hritik Chaudhary edab9c00ab removed proptypes from product-list container (https://github.com/woocommerce/woocommerce-blocks/pull/9616)
Co-authored-by: Niels Lange <info@nielslange.de>
2023-05-28 15:11:28 +07:00
Niels Lange fdf81f6088 Update README.md 2023-05-27 20:31:15 +07:00
Daniel Dudzic 3e33914e87 Mini-Cart: Make error notifications non-dismissable. Closes woocommerce/woocommerce-blocks#8965. (https://github.com/woocommerce/woocommerce-blocks/pull/9578) 2023-05-26 19:39:33 +02:00
Niels Lange cb3a2cc056 Update README.md 2023-05-26 22:16:18 +07:00
Alexandre Lara 8a75ec8bc2 Fix magnifying glass appearing outside the product image gallery (https://github.com/woocommerce/woocommerce-blocks/pull/9594) 2023-05-26 11:23:24 -03:00
Tarun Vijwani f6a827b639 Fix Cambodian postal code validation (https://github.com/woocommerce/woocommerce-blocks/pull/9597)
-Fix the postal code validation for Cambodia to accept 6 digit postal code instead of 5 digit.
2023-05-26 17:56:55 +04:00
Luigi Teschio 40eb06a060 Fix PHP lint (https://github.com/woocommerce/woocommerce-blocks/pull/9608)
* fix CI on php linting errors

* not disable the linter rule at file level
2023-05-26 13:54:16 +00:00
Manish Menaria 3a4792150c Product Collection - Add keyword control to sidebar settings (https://github.com/woocommerce/woocommerce-blocks/pull/9583)
* 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 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.

* 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.

* 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.

* remove unused import of getDefaultStockStatuses
2023-05-26 13:21:51 +00:00
Manish Menaria c3060cff0e Product Collection: Add stock status filter (https://github.com/woocommerce/woocommerce-blocks/pull/9580)
* 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 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.

* 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.

* 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.

* Fix: Default values of attributes not saving as serialized block comment

This was happening because of this issue: https://github.com/WordPress/gutenberg/issues/7342

Therefore, I had to use `useEffect` to set the default values of the attributes.

Here is the list of changes I made:
1. Removed default values from `block.json` for `query`, `tagName`, and `displayLayout`.
2. Moved the default values to `constants.ts` and created a new object `DEFAULT_ATTRIBUTES` to store them.
3. Relocated `constants.ts` from `inspector-controls` to the parent directory.
4. Refactored `edit.tsx` to use `DEFAULT_ATTRIBUTES` from `constants.ts` to set default attributes using `useEffect`.
5. Removed the attributes assignment from `registerBlockType` in `index.tsx`.
6. Updated `columns-control.tsx`, `index.tsx`, `order-by-control.tsx`, and `stock-status-control.tsx` to import from the relocated `constants.ts`.
7. Updated `ProductCollectionAttributes` and `ProductCollectionQuery` in `types.ts` to include `tagName` and `isProductCollectionBlock` respectively.
8. Modified `ProductCollection.php` to match the updated `orderBy` key in the query parameter.

This refactor enhances the readability of the code and reduces duplication by keeping all constants and default values in one place.

* Replace usage of 'statii' with 'statuses' in stock status handling

This commit replaces all instances of 'statii' with the correct term 'statuses' in the context of handling stock status. This change affects three files:
1. `assets/js/blocks/product-collection/inspector-controls/stock-status-control.tsx` - The term is corrected in a comment block.
2. `assets/js/blocks/product-collection/types.ts` - Updated the name of a variable in the `ProductCollectionQuery` interface.
3. `src/BlockTypes/ProductCollection.php` - Here, the term is replaced in several locations including variable names, comments and the method `get_stock_status_query`.

This commit helps improve code readability and consistency across the repository.
2023-05-26 11:44:37 +00:00
Albert Juhé Lluveras e4f1dfdc22 Clarify step when bumping a release in WC core (https://github.com/woocommerce/woocommerce-blocks/pull/9605) 2023-05-26 12:05:10 +02:00
Hritik Chaudhary 5bd706edd9 Remove propTypes definitions from Top Rated Products block (https://github.com/woocommerce/woocommerce-blocks/pull/9595)
* replace propTypes and converted to tsx -  product-top-rated/block.js

* replace propTypes and converted to tsx -  product-top-rated/block.js

* converted product-top-rated to typescript

* added JSX.Element

---------

Co-authored-by: Niels Lange <info@nielslange.de>
2023-05-26 13:46:13 +07:00
Alexandre Lara 75d92b60b8 Remove Add Review link and hide rating when the Product has no rating (https://github.com/woocommerce/woocommerce-blocks/pull/9556) 2023-05-25 11:49:02 -03:00
Albert Juhé Lluveras 1817cfe179 Add 10.2.1 testing steps 2023-05-25 15:00:01 +02:00
Albert Juhé Lluveras a2cc867b62 Add 10.2.1 changelog 2023-05-25 14:58:53 +02:00
Luigi Teschio 4fb7da7962 Classic Product Template visible in the inserter (https://github.com/woocommerce/woocommerce-blocks/pull/9573) 2023-05-25 09:42:29 +02:00
Manish Menaria 0b3853090b Product Collection: Add 'on sale' filter and enhance settings management in product collection block (https://github.com/woocommerce/woocommerce-blocks/pull/9549)
* 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 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.

* 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.
2023-05-25 06:38:19 +00:00
Saad Tarhi 4bdbdbf309 Fix total shipping display info when no shipping method is available (https://github.com/woocommerce/woocommerce-blocks/pull/8819)
* Fix total shipping info when no shipping are available

* Fix a logical error for displaying shipping info

* Fix failing unit tests

* Run unit test for the Cart instead of the Checkout

The calculator is only available for the Cart Block, so it doesn't make
sense to run this test for the Checkout Block

* Fix no shipping methods and incomplete address conflict

When there are no shipping methods (except for local pickup), we would
like to inform the shopper that there are no shipping options available
even though the address is complete

The solution we found is to check the address on the Cart Block only

* Refactor code

* Check whether rate is collectible without using hardcoded id

* Correctly negate hasCollectibleRate result

* Add notice when shipping is selected but no methods are available yet (https://github.com/woocommerce/woocommerce-blocks/pull/9171)

* Create useShippingTotalWarning hook

* Show notices above checkout sidebar

* Call hook to show notice in Checkout block

* Remove unused imports

* Update hook name to useShowShippingTotalWarning

* Move hook to its own file

* Import shipping data internally (without alias)

* Remove unused imports

* Move import to correct place

* Return early to avoid if else

* Refactor useShowShippingTotalWarning

* Get shipping rates directly from the cart instead of the hook

* Show shipping cost when price information is available

* Check if the passed rates are considered selected

* Prevent errors when no rates are available

---------

Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Tarun Vijwani <tarun.vijwani@automattic.com>
2023-05-25 06:31:15 +01:00
Roy Ho b858f93628 Remove trailing comma (https://github.com/woocommerce/woocommerce-blocks/pull/9593) 2023-05-24 13:43:11 -07:00
Daniel W. Robert 80bfab6d76 Update lockfile for fresh installation. (https://github.com/woocommerce/woocommerce-blocks/pull/9574) 2023-05-24 13:00:13 -04:00
Albert Juhé Lluveras 31487e01b0 Add 10.0.5 testing notes 2023-05-24 17:49:32 +02:00
Albert Juhé Lluveras 90207c7cdc Add 10.0.5 changelog 2023-05-24 17:47:55 +02:00
Albert Juhé Lluveras 480750d20c Prevent Mini-Cart dependency scripts to lazy-load if they have already been enqueued (https://github.com/woocommerce/woocommerce-blocks/pull/9587) 2023-05-24 16:57:00 +02:00
Mike Jolley e66e683625 10.4.0-dev 2023-05-24 14:28:19 +01:00
Mike Jolley fc573a816c 10.3.0 Testing instructions and Changelog 2023-05-24 14:26:55 +01:00
Hritik Chaudhary ed2c17f16c Remove `propTypes` definitions from Product Search block (https://github.com/woocommerce/woocommerce-blocks/pull/9565)
* Remove propTypes definitions for product search

* Resolved TS errors

* Addressed review comments

---------

Co-authored-by: Niels Lange <info@nielslange.de>
2023-05-24 19:24:08 +07:00
Patricia Hillebrandt e6e908c483 Restore the global variable to its original value after being overriden. (https://github.com/woocommerce/woocommerce-blocks/pull/9581) 2023-05-24 14:08:32 +02:00
Manish Menaria 376aa1ebdb Add 'products-block-post-template' class to product templates (https://github.com/woocommerce/woocommerce-blocks/pull/9569) 2023-05-24 10:01:59 +00:00
Luigi Teschio a996ab7351 update @wordpress/env package (https://github.com/woocommerce/woocommerce-blocks/pull/9572) 2023-05-23 15:45:40 +00:00
Thomas Roberts 75785ea46a Update documentation for additionalCartCheckoutInnerBlockTypes filter (https://github.com/woocommerce/woocommerce-blocks/pull/8994) 2023-05-23 02:50:13 -07:00
Albert Juhé Lluveras a04c00a79f Make Mini-Cart block work well with caching plugins (https://github.com/woocommerce/woocommerce-blocks/pull/9493)
* Make Mini-Cart block work well with caching plugins

* Add tests

* Add back aria-label to Mini-Cart menu

* Fetch Mini-Cart data before page finishes loading

* Store and retrieve Mini-Cart values from localStorage for better performance

* Update styles as early as possible

* Reorder code

* Remove overrideTotals param from updateTotals() function

* Update tests

* Initialize local storage inside a function and add act to filter tests

* Replace void with undefined types in several funtions

* Fix 0 quantity badge appearing on page load
2023-05-23 09:28:40 +02:00
Patricia Hillebrandt 0dae17510d Fix > Product details listing pattern - Ensure the editor preview is properly rendered after page refresh (https://github.com/woocommerce/woocommerce-blocks/pull/9563)
* Fix editor render for a few paragraphs within the Product Listing Pattern.

* Update spacing and fontWeight.
2023-05-22 19:41:36 +00:00
Roy Ho 3fcbf43d60 Revert "Update the logic of disabling some blocks in the widget areas and post editor (https://github.com/woocommerce/woocommerce-blocks/pull/9462)" (https://github.com/woocommerce/woocommerce-blocks/pull/9561)
This reverts commit 2a4b78c150.
2023-05-22 08:59:51 -07:00
Luigi Teschio c919466a8c Enable blockified conversation to archive templates (https://github.com/woocommerce/woocommerce-blocks/pull/9509) 2023-05-22 12:17:56 +00:00
Thomas Roberts 56879a4861 Check if package rates is an array before filtering on it (https://github.com/woocommerce/woocommerce-blocks/pull/9351)
Co-authored-by: Niels Lange <info@nielslange.de>
2023-05-22 02:43:00 -07:00
Seghir Nadir 5457145c6a Trigger the set-billing-address when editing Shipping (https://github.com/woocommerce/woocommerce-blocks/pull/8841) 2023-05-22 09:30:49 +00:00
Tarun Vijwani 90e57bca11 Add unit test cases for Min and Max price for shipping methods (https://github.com/woocommerce/woocommerce-blocks/pull/9336)
* Add unit test cases for Min and Max price for shipping methods

* Move Test for Min and Max rates to shipping-rates

- Move Test for Min and Max rates to shipping-rates.
- Use single shippingRates object throughout the test cases.

* Update assets/js/base/utils/test/shipping-rates.ts

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

* Update assets/js/base/utils/test/shipping-rates.ts

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

* Add helper function to generate shipping rates

* Add a test for empty shipping rates

* Remove redundant attribute values from generateRate function

---------

Co-authored-by: Niels Lange <info@nielslange.de>
2023-05-22 12:48:12 +04:00
Tarun Vijwani 296a0b4360 Fix Checkout block stepped sections numbers overlapping (https://github.com/woocommerce/woocommerce-blocks/pull/9497)
- Fix the padding for checkout-step component
2023-05-22 11:03:50 +04:00
Alexandre Lara 410e041936 Remove the fill color of the Product Meta icon (https://github.com/woocommerce/woocommerce-blocks/pull/9506) 2023-05-19 16:59:18 -03:00
Alexandre Lara 0847c20f79 Remove the fill color of the Product Details icon and move it to the icons library (https://github.com/woocommerce/woocommerce-blocks/pull/9503) 2023-05-19 12:09:13 -03:00
Albert Juhé Lluveras b0af5ac12e Update Mini-Cart block logic to use isSiteEditorPage util (https://github.com/woocommerce/woocommerce-blocks/pull/9501)
* Revert "Mini-Cart: prevent 'Mini-Cart in cart and checkout pages' toggle from showing up in the post/page editor (https://github.com/woocommerce/woocommerce-blocks/pull/9442)"

This reverts commit 0bfc1b341e.

* Update Mini-Cart block logic to use isSiteEditorPage util
2023-05-18 15:53:01 +02:00
Patricia Hillebrandt 61fbf572cb Single Product Block > Only reset the post data if `setup_postdata` was invoked. (https://github.com/woocommerce/woocommerce-blocks/pull/9474)
* Only call wp_reset_postdata() if the global post variable was changed.

* Make global_post_variable_changed static.

* rely on the output of setup_postdata for verifying if the global variable was successfully changed.

* ditch the static var and defaulting to false instead.

* Rely on static as the post reset only happens when the loop of inner blocks ends and not right away.

* Update the  variable when the postdata is reset.
2023-05-18 15:35:46 +02:00
Luigi Teschio 0bf8048bd1 Fix compatibility layer when no products are displayed (https://github.com/woocommerce/woocommerce-blocks/pull/9464)
* POC

* add compatibility with the product recommendations extension

* improve readibility key

* improve readibility code

* improve readibility

* fix compatibility layer when no products are displayed

* remove duplicate code
2023-05-18 14:19:46 +02:00
Alexandre Lara bad4c30e36 Add to Cart with Options: Fix styles that are not being applied correctly (https://github.com/woocommerce/woocommerce-blocks/pull/9472)
* Add missing WooCommerce styles to Add to Cart with Options block

* Fix input style for Add to Cart with Options block

* Add comment about the input-text css class that was added to the Add To Cart Form
2023-05-18 08:02:51 -03:00
Manish Menaria 57d4ac529e Product Collection: Add 'Order By' Control to Product Collection Inspector (https://github.com/woocommerce/woocommerce-blocks/pull/9480)
* 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 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: handle undefined index for isProductCollectionBlock

This commit addresses a potential issue where the 'isProductCollectionBlock' index might not be defined in certain situations within the 'build_query' method of the ProductCollection class.

Previously, we directly accessed 'isProductCollectionBlock' from the 'query' context of the block. Now, we use the null coalescing operator (??) to ensure that we assign a default value of false if 'isProductCollectionBlock' is not set.

This change provides a safer way to handle the scenario when the 'isProductCollectionBlock' is not defined in the block context and helps prevent undefined index warnings.
2023-05-18 10:54:08 +00:00
Mike Jolley 715e63fbfd Revert changes in woocommerce/woocommerce-blocks#9332 and instead enqueue assets in correct place depending on admin vs frontend (https://github.com/woocommerce/woocommerce-blocks/pull/9495) 2023-05-18 10:46:17 +01:00
Luigi Teschio 86bb06a9a8 Product Archive Template: Fix compatibility Layer with Product Recommendations extension (https://github.com/woocommerce/woocommerce-blocks/pull/9452)
* POC

* add compatibility with the product recommendations extension

* improve readibility key

* improve readibility code

* improve readibility

* remove duplicate logic

* improve code readability
2023-05-18 11:41:44 +02:00
Albert Juhé Lluveras 5d6397b7b5 Prevent QuantitySelector stealing focus on page load (https://github.com/woocommerce/woocommerce-blocks/pull/9487) 2023-05-18 09:17:29 +02:00
Tarun Vijwani 21a356c58c Allow Shipping method prices to inherit global styles text color (https://github.com/woocommerce/woocommerce-blocks/pull/9456)
- Remove the hardcoded color for Shipping method prices
2023-05-17 21:52:20 +04:00
Alexandre Lara 2ef37db063 Add useIsDescendentOfSingleProductBlock hook to product rating block (https://github.com/woocommerce/woocommerce-blocks/pull/9489) 2023-05-17 10:58:12 -03:00
Luigi Teschio 689b5dd22a Fix undo button (https://github.com/woocommerce/woocommerce-blocks/pull/9478)
* fix undo button

* fix label
2023-05-17 13:25:02 +00:00
Mike Jolley bb1f578002 Store API: Fix payment method validation (fixes COD) (https://github.com/woocommerce/woocommerce-blocks/pull/9375)
* Widen enum for validation before cart is loaded

* Improve error message on checkout
2023-05-17 11:17:24 +01:00
Luigi Teschio 1b71b06b33 Product Search Results Template: fix compatibility layer when the Product Catalog is not blockified (https://github.com/woocommerce/woocommerce-blocks/pull/9492) 2023-05-17 10:10:58 +00:00
Alexandre Lara f22036af89 Fix Product Rating Block not showing when manually inserted to Single Product block (https://github.com/woocommerce/woocommerce-blocks/pull/9413) 2023-05-16 15:28:11 -03:00
Alexandre Lara 90573156fe Fix Product SKU not being displayed on frontend when outside Single Product template (https://github.com/woocommerce/woocommerce-blocks/pull/9446) 2023-05-16 15:25:34 -03:00
Luigi Teschio f8d46570ae Add isSiteEditorPage util (https://github.com/woocommerce/woocommerce-blocks/pull/9468)
* Add isSiteEditorPage util

* fix logic
2023-05-16 13:59:49 +02:00
Albert Juhé Lluveras 4c8baca475 Fix Filter by Price block making a 404 request in the frontend (https://github.com/woocommerce/woocommerce-blocks/pull/9481) 2023-05-16 12:05:24 +02:00
Luigi Teschio 150cde7d56 render Product Details block when it used along the Post Content block (https://github.com/woocommerce/woocommerce-blocks/pull/9479) 2023-05-16 11:31:13 +02:00
Manish Menaria 14f87be044 Product Collection: Add columns control to product collection block editor settings (https://github.com/woocommerce/woocommerce-blocks/pull/9466)
* 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.
2023-05-16 09:23:22 +00:00
Alba Rincón a24bf73c83 [Patterns] Improvements on `Product Collections: Featured Collection` (https://github.com/woocommerce/woocommerce-blocks/pull/9450)
* Hardcore text color

* Fix image margins
2023-05-16 11:06:04 +02:00
Albert Juhé Lluveras 3b28b74777 Mini Cart: stop using Modal component (https://github.com/woocommerce/woocommerce-blocks/pull/9345)
* Remove unused styles

* Replace usage of Modal component with custom Drawer

* Update MiniCart.php class structure

* Update tests

* Prevent focus styles to appear unnecessarily when opening the Mini Cart drawer

* Work-around issue with disabled buttons causing lose of focus inside the Mini-Cart drawer

* Revert "Work-around issue with disabled buttons causing lose of focus inside the Mini-Cart drawer"

This reverts commit 4360f77384ad1f1d90a3ba8a0385ad79da2449f2.

* QuantitySelector: focus text input field after decrease or increase button become disabled

* Move focus to the input field also when the body has focus, that fixes the issue in Chrome

* Add explanatory comment
2023-05-16 10:41:26 +02:00
Patricia Hillebrandt 0bad9c81c9 Product Gallery Block > Remove global variable overwrite and keep support for the Single Product Block. (https://github.com/woocommerce/woocommerce-blocks/pull/9475)
* Remove call to the  global variable and add support for the gallery block to continue to work within the Single Product template without any problems.

* Make essential/required changes to guarantee the Product Gallery block works as expected without the relying on the global product.
2023-05-16 10:36:33 +02:00
Patricia Hillebrandt d26936bad7 Add to Cart with Options Block > Remove global variable overwrite. (https://github.com/woocommerce/woocommerce-blocks/pull/9457)
* Remove global variable overwrite from Add to Cart Form block.

* Rename single_product to product.
2023-05-16 10:18:36 +02:00
Mike Jolley 6e3b1ac7fb Styling fixes for form step headings (https://github.com/woocommerce/woocommerce-blocks/pull/9437)
Co-authored-by: Niels Lange <info@nielslange.de>
2023-05-15 12:28:24 +01:00
Tarun Vijwani afa5406746 Fix radio control overlap when font-size is small (https://github.com/woocommerce/woocommerce-blocks/pull/9436)
Co-authored-by: Niels Lange <info@nielslange.de>
2023-05-15 14:46:42 +04:00
Manish Menaria 0e6141f5ed Foundation of New Product Collection Block (https://github.com/woocommerce/woocommerce-blocks/pull/9352)
* Add Products Collection block scaffolding

This commit adds the initial scaffolding for the new Products Collection block. It includes the creation of new files (block.json, edit.tsx, index.tsx and ProductsCollection.php) and additions to existing files (webpack-entries.js and BlockTypesController.php). The block is marked as experimental and currently displays a static "Product collection" text in both the editor and the frontend.

* Add Product Template block and integrate with Products Collection block

This commit introduces the new Product Template block and integrates it with the existing Products Collection block. The changes include:
- Creation of the Product Template block, including its block.json, edit.tsx, icon.tsx, index.tsx, and save.tsx files.
- Modification of the Products Collection block, adding an icon.tsx file and updating its edit.tsx and index.tsx files.
- Updates to the webpack-entries.js file to include the new Product Template block.
- Addition of the ProductTemplate class in the src/BlockTypes directory.
- Inclusion of the ProductTemplate class in the src/BlockTypesController.php file.

* Enhance product-template block with context and styling

This commit adds various enhancements to the product-template block. It includes:

- Introduce `usesContext` and `supports` properties to the block.json file
- Update the edit.tsx file to use BlockContextProvider and add query logic
- Add an editor.scss file for styling the product-template block in the editor
- Extend the products-collection block.json file with new properties
- Modify the products-collection edit.tsx file to include instanceId and useEffect

These changes improve the product-template block by providing better context handling and styling options.

* Add 'woocommerce/product-template' to supported inner blocks and improve product-template editing

This commit adds 'woocommerce/product-template' as a supported inner block for various product elements, including button, image, rating, sale-badge, SKU, and stock-indicator. It also improves the editing experience for the product-template block by memoizing the block previews and rendering them more efficiently. This should lead to a smoother editing experience and better performance in the block editor.

* Add product title and summary variations for Products Collection block

- Add default spacing between product elements in `style.scss`
- Register product title and summary element variations in `products-collection` block
- Create utility for registering element variations
- Extend core elements with WooCommerce namespace

* Set inherit to false by default and other improvements

This commit introduces several changes to the ProductsCollection block:
1. Set the "inherit" property to false in block.json, disabling inheritance by default.
2. Remove the default styles for inner blocks in the edit.tsx file.
3. Add a save function in the index.tsx file, and create a save.tsx file to handle saving the block.
4. Update the ProductTemplate.php file to properly render the block content based on the changes.
5. Remove the render function from the ProductsCollection.php file, as it is no longer necessary.

These changes improve the functionality and flexibility of the ProductsCollection block, allowing for better customization and control over the block's appearance and behavior.

* Fix pagination issue

* Minor code quality improvments

* Register product blocks only in experimental builds

- Wrap registerBlockType calls in product-template and products-collection with isExperimentalBuild check to enable block registration only in experimental builds.
- Update the default value for the perPage property in products-collection/block.json from null to 9, setting a default display of 9 items per page.

* Add experimental flag to PHP file

* Update documentation for feature flags

- Add Products Collection and Product Template blocks to the list of experimental flags in the feature-flags-and-experimental-interfaces.md file.
- Include references to PHP and webpack flags for both blocks.

* Change default order and orderBy values in block.json

- Update the default 'order' value from 'desc' to 'asc'.
- Update the default 'orderBy' value from 'date' to 'title'.

* Refactor experimental block registration and remove unused file

- Replace `isExperimentalBuild()` with `registerExperimentalBlockType()` in product-template/index.tsx.
- Remove unused file types.ts in product-template directory.
- Add `get_block_type_script()` function to ProductTemplate.php and ProductsCollection.php to return null.

* Update variation names in product summary and product title elements

Updated variation names for product summary and product title elements to match the new products-collection namespace. The previous variation names used the product-query namespace which will be deprecated. This change ensures that the correct variation names are used for these elements in the products-collection block.

* Rename 'Products Collection' to 'Product Collection'

- Renamed all instances of "products-collection" to "product-collection" across multiple files.
- Adjusted related types and method calls to match the new naming convention.
- Updated documentation and feature flags to reflect the name change.
- Made necessary changes in `BlockTypesController.php` and `bin/webpack-entries.js`.

* Hide product-template block from inserter

- Added "woocommerce/product-collection" to the list of parent blocks in `product-template/block.json`.
- Added `"inserter": false` to the "supports" section to disable the option of inserting this block through the editor inserter component.

* Fix Eslint error
2023-05-15 08:51:49 +00:00
Danilo Parra Jr 2a4b78c150 Update the logic of disabling some blocks in the widget areas and post editor (https://github.com/woocommerce/woocommerce-blocks/pull/9462)
* refactor: disable some blocks in widget areas and post editor

* refactor: add more checks on the disabling blocks logic
2023-05-15 08:36:06 +02:00
Daniel W. Robert 8621755f69 Update `Hero Product – Split` Pattern Color Settings (https://github.com/woocommerce/woocommerce-blocks/pull/9433)
* Update color settings to abide by designs.

* Update pattern heading to use inline style.

This ensures the heading color will be white by default and not take on
the heading color from the active theme.

* Translate and escape rendered text in pattern.
2023-05-12 11:00:16 -04:00
Roy Ho cd5490be6b Update/cleanup patterns (https://github.com/woocommerce/woocommerce-blocks/pull/9447)
* Update category cover image pattern

* Update featured category focus pattern

* Update featured category triple pattern

* Update product details pattern

* Update product hero pattern

* Update shop by price pattern

* Update testimonials single pattern
2023-05-12 06:05:36 -07:00
Mike Jolley 43eaed7620 Experiment: Replace style hooks coming from `@wordpress/block-editor` (https://github.com/woocommerce/woocommerce-blocks/pull/9251)
* Replace all style hooks with useStyleProps hook

* Remove border/color/spacing hooks

* Style Props Hook

* Make use of `change-case` package

* Tidy up block wrappers

* Attribute filter does not use frontend.ts nor styles within block

* Remove frontend from filter blocks and unused styleprops usage

* Tidy up variable names so its clearer attributes are not required specifically from blocks

* Update assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-title-label-block/block.tsx

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

* Update assets/js/blocks/attribute-filter/block-wrapper.tsx

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

* Update assets/js/blocks/active-filters/block-wrapper.tsx

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

* Update assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-checkout-button-block/block.tsx

Co-authored-by: Tom Cafferkey <tjcafferkey@gmail.com>

* Update assets/js/blocks/rating-filter/block-wrapper.tsx

Co-authored-by: Tom Cafferkey <tjcafferkey@gmail.com>

* Update assets/js/blocks/stock-filter/block-wrapper.tsx

Co-authored-by: Tom Cafferkey <tjcafferkey@gmail.com>

* Update assets/js/blocks/price-filter/block-wrapper.tsx

Co-authored-by: Tom Cafferkey <tjcafferkey@gmail.com>

* Update assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-cart-button-block/block.tsx

Co-authored-by: Tom Cafferkey <tjcafferkey@gmail.com>

* Simplify styleprop

* Styleprops simplify

* Fix withFeaturedItem styles

* Like the original hook, flatten props and combine with parsed styles

---------

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Tom Cafferkey <tjcafferkey@gmail.com>
2023-05-12 13:42:16 +01:00
Alba Rincón 30dc6ca5a5 Add new `Product collections: featured collections` pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9388)
* Add new `Product collections: featured collections` pattern

* Update image paths

* Add buttons

* Add colors to buttons

* Change branded image
2023-05-12 12:26:06 +02:00
Patricia Hillebrandt 2a7ac1c92b Add Product Details: product listing pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9383)
* Add the skeleton for the Product Details: product listing pattern

* Update the wp-block-woocommerce-single-product class.

* Update the product details pattern for usage with core blocks.

* Update margins for the product reviews.

* Update the styles and spacing for ratings.

* Additional changes to the editor preview for product ratings.

* update spacing between ratings and text.

* Update content padding.

* Adjust the pricing

* Make adjustments to the button

* Update styles.

* Update styles for the star ratings.

* Extra fine-tunning for reviews and font size

* Add the product details image.
2023-05-12 09:17:45 +00:00
Mike Jolley 7e06584c14 Update settings text and styling (https://github.com/woocommerce/woocommerce-blocks/pull/9440) 2023-05-12 10:11:08 +01:00
Alba Rincón 6550c830db Patterns small improvements (https://github.com/woocommerce/woocommerce-blocks/pull/9403)
* Center the menu

* Use product image block

* Change search button background to white
2023-05-12 10:41:58 +02:00
Albert Juhé Lluveras 0bfc1b341e Mini-Cart: prevent 'Mini-Cart in cart and checkout pages' toggle from showing up in the post/page editor (https://github.com/woocommerce/woocommerce-blocks/pull/9442) 2023-05-12 10:26:03 +02:00
Dennis Jonda 1add6a146e Fix alignment issue with 'Add Coupon Code' button in WooCommerce Blocks checkout page (https://github.com/woocommerce/woocommerce-blocks/pull/9392)
Co-authored-by: Niels Lange <info@nielslange.de>
2023-05-12 12:28:08 +07:00
Niels Lange 301c6891b5 Replace ‘actions-ecosystem/action-remove-labels’ with ‘mondeja/remove-labels-gh-action’ (https://github.com/woocommerce/woocommerce-blocks/pull/9173)
* Replace ‘actions-ecosystem/action-remove-labels’ with ‘mondeja/remove-labels-gh-action’

* Adjust workflow

* Add test file for woocommerce/woocommerce-blocks#9173 (https://github.com/woocommerce/woocommerce-blocks/pull/9174)

* Remove the file created for testing purpose (https://github.com/woocommerce/woocommerce-blocks/pull/9177)

---------

Co-authored-by: Karol Manijak <karol.manijak@automattic.com>
2023-05-12 11:54:04 +07:00
Albert Juhé Lluveras d236af2a8c Only show the Mini Cart count badge when there are items in the cart (https://github.com/woocommerce/woocommerce-blocks/pull/9259)
* Only show the Mini Cart count badge when there are items in the cart

* Update badge to new design

* Add tests

* Make sure colors don't break existing themes

* Update Mini Cart e2e test
2023-05-11 17:23:36 +02:00
Alba Rincón 545cc43123 Add new `Product listing with gallery` pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9347)
* Add new `Product listing with gallery` pattern

* Replace single product block pattern

* Remove ids

* Fix title and images

* Rebuild the image gallery to make it work on diff widths

* Fix image src

* Fix gallery image and align description
2023-05-11 16:45:49 +02:00
Roy Ho 47f9777f4b Add banner pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9434)
* Add banner pattern

* Hardcode the button styling
2023-05-11 07:39:36 -07:00
Albert Juhé Lluveras 2b6eef516b Update Mini-Cart block editor sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/9420)
* Update Mini-Cart block editor sidebar

* Rename Mini Cart block to Mini-Cart

* Update Mini-Cart block editor sidebar (II)

* Update two instances of mini-cart to uppercase
2023-05-11 14:52:03 +02:00
Karol Manijak a9d840ec69 Bump version in several files to 10.3.0-dev 2023-05-11 14:12:41 +02:00
Karol Manijak 202799007c Add testing steps of 10.2.0 2023-05-11 14:10:51 +02:00
Karol Manijak af725d558e Update minimal WordPress version in phpcs.xml to the 6.1 2023-05-11 14:09:08 +02:00
Karol Manijak c3e4321cb6 Update minimal WordPress version to the latest 6.2 2023-05-11 14:08:30 +02:00
Karol Manijak 379bb41e9b Add changelog for 10.2.0 2023-05-11 14:08:01 +02:00
Karol Manijak ecfd94ce2b Change the button text in the pattern to make it matching the content (https://github.com/woocommerce/woocommerce-blocks/pull/9435)
* Change the button text in the pattern to make it matching the content

* Fix the image size so it's original ratio is preserved
2023-05-11 11:02:45 +02:00
Roy Ho a84cfd93d6 Update text (https://github.com/woocommerce/woocommerce-blocks/pull/9423)
* Update text

* Make shop now button black with white text to match design

* Update pattern image and text
2023-05-11 08:17:42 +02:00
Roy Ho 06cd02b88a Update pattern with images and alignment (https://github.com/woocommerce/woocommerce-blocks/pull/9414) 2023-05-10 05:44:58 -07:00
Luigi Teschio b15cb932fb Improve transform classic product template UX (https://github.com/woocommerce/woocommerce-blocks/pull/9386)
* improve transform classic product template UX

* improve layout

* not update deps

* improve logic

* add bold

* fix height and width preview on hover

* fix label

* improve logic for revert button

* fix regression
2023-05-10 13:02:33 +02:00
Patricia Hillebrandt b12cfd2d6a Add to Cart Button > Update block registration to rely on metadata and enable usage for the Single Product Block (https://github.com/woocommerce/woocommerce-blocks/pull/9404)
* Adapt the Add to Cart Button block to be registered via block.json

* Remove the legacy supports.ts file

* Ditch all registration methods from the ProductButton class as it is now registered via metadata (a block.json file)

* Update get_block_type_uses_context and register_block_type_assets
2023-05-10 10:20:40 +00:00
Karol Manijak 8d6344a07d Skip the failing test (https://github.com/woocommerce/woocommerce-blocks/pull/9405)
* Skip the failing test

* Add an explanation to the skipped test and eslint disable
2023-05-10 11:03:22 +02:00
Daniel W. Robert b6cfe080d5 Remove br in pattern heading. (https://github.com/woocommerce/woocommerce-blocks/pull/9409)
This allows the text to flow more naturally, as opposed to having
unexpected line-breaks at certain screen widths.
2023-05-09 15:22:33 -04:00
Roy Ho b05f78b66c Update pattern alignments (https://github.com/woocommerce/woocommerce-blocks/pull/9410)
* Update pattern alignments

* Add explicit margin

* Try this

* Explicitly set margins

* Remove is-light class
2023-05-09 09:25:02 -07:00
Roy Ho e6a58ab90c Add product details pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9408)
* Add product details pattern

* Replace stars image
2023-05-09 08:15:03 -07:00
Luigi Teschio 796f16880a Related Products: Fix hardcoded limit product (https://github.com/woocommerce/woocommerce-blocks/pull/9407)
* fix hardcoded limit product

* improve readibility
2023-05-09 14:59:05 +02:00
Seghir Nadir 4c2f024418 Only validate postcode if its required or filled (https://github.com/woocommerce/woocommerce-blocks/pull/9377)
* Only validate postcode if its required

* Clear postcode validation error if postcode is not required

---------

Co-authored-by: Niels Lange <info@nielslange.de>
2023-05-09 16:54:28 +07:00
Roy Ho b92bc3e7fd Update patterns images paths (https://github.com/woocommerce/woocommerce-blocks/pull/9390) 2023-05-08 07:22:30 -07:00
Lucio Giannotta 41817ea2d6 Implement Hand-Picked Products block (https://github.com/woocommerce/woocommerce-blocks/pull/7925)
Implements the ProductSelector advanced filter within the “Products (Beta)” block.
The filter allows the merchant to narrow down the exact products to which all
subsequent filters will be applied, mirroring the functionality of the existing
“Hand-picked Products” plus all the other functionalities available
from the “Products (Beta)” block.
2023-05-08 14:50:10 +02:00
Danilo Parra Jr 4c204ab578 Add color and typography styles on the mini cart title block (https://github.com/woocommerce/woocommerce-blocks/pull/9382)
* feat: added color and typography supports on the mini cart title block

* refactor: remove background support for mini cart title block
2023-05-08 13:52:25 +02:00
Alba Rincón d8c974f104 [Pattern] Add new `Hero product chessboard` pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9180)
* Add new `Hero product chessboard` pattern

* Add images

* Margins in px to avoid diff behaviour on diff theme styles

* Add shop link
2023-05-08 11:35:51 +02:00
dependabot[bot] c54e60cac8 Bump dependabot/fetch-metadata from 1.3.6 to 1.4.0 (https://github.com/woocommerce/woocommerce-blocks/pull/9303)
Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.3.6 to 1.4.0.
- [Release notes](https://github.com/dependabot/fetch-metadata/releases)
- [Commits](https://github.com/dependabot/fetch-metadata/compare/v1.3.6...v1.4.0)

---
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>
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
2023-05-05 11:58:18 -03:00
dependabot[bot] 48f5dd6b72 Bump @wordpress/babel-preset-default from 7.8.0 to 7.16.0 (https://github.com/woocommerce/woocommerce-blocks/pull/9279)
Bumps [@wordpress/babel-preset-default](https://github.com/WordPress/gutenberg/tree/HEAD/packages/babel-preset-default) from 7.8.0 to 7.16.0.
- [Release notes](https://github.com/WordPress/gutenberg/releases)
- [Changelog](https://github.com/WordPress/gutenberg/blob/trunk/packages/babel-preset-default/CHANGELOG.md)
- [Commits](https://github.com/WordPress/gutenberg/commits/@wordpress/babel-preset-default@7.16.0/packages/babel-preset-default)

---
updated-dependencies:
- dependency-name: "@wordpress/babel-preset-default"
  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>
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
2023-05-05 11:35:44 -03:00
Roy Ho 4f90c5fe85 Add shop by price pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9373) 2023-05-05 06:33:20 -07:00
Luigi Teschio 739fa60fea Improve the E2E testing process with Playwright (https://github.com/woocommerce/woocommerce-blocks/pull/9148)
* Add Playwright infrastucture

* improve documentation

* improve type

* remove puppeteer tests

* fix wp-env.json

* add link on how run E2E tests

* chore on playwright.yml

* remove unnecessary flush command

* improve stability E2E test

* remove build:e2e-test command

* Update .github/workflows/playwright.yml

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

* Update .github/workflows/playwright.yml

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

* Update docs/contributors/contributing/e2e-guidelines.md

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

* Update docs/contributors/contributing/e2e-guidelines.md

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

* Update docs/contributors/contributing/e2e-guidelines.md

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

* remove emptyline and fix JSDoc warning

* add link about E2E guidelines

* fix theme name

* improve style

* improve markdown

---------

Co-authored-by: Niels Lange <info@nielslange.de>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2023-05-05 11:03:36 +00:00
Albert Juhé Lluveras 349ae658bb Mini Cart drawer: print width in PHP (https://github.com/woocommerce/woocommerce-blocks/pull/9329)
* Mini Cart drawer: print width in PHP

* Remove unnecessary timeout

* Make sure classic themes have a Mini Cart contents width value set up
2023-05-05 11:44:41 +02:00
Luigi c4d8e9114e Merge branch 'release/10.0.0' of https://github.com/woocommerce/woocommerce-blocks into trunk 2023-05-05 11:37:54 +02:00
github-actions[bot] 18aed7f8ae Release: 10.0.4 (https://github.com/woocommerce/woocommerce-blocks/pull/9357)
* Empty commit for release pull request

* Add 10.0.3 changelog

* Update versions to 10.0.3

* Fix image editor in Featured Product/Category blocks on WP 6.2 (https://github.com/woocommerce/woocommerce-blocks/pull/9142)

* Add 10.0.3 testing steps

* Empty commit for release pull request

* Check that the customized fallback template is archive-product before unsetting the source property (https://github.com/woocommerce/woocommerce-blocks/pull/9330)

* use 'enqueue_block_assets' is available (https://github.com/woocommerce/woocommerce-blocks/pull/9332)

* Remove esc_url() on self generated link to edit the Mini Cart template since it gets escaped in JS (https://github.com/woocommerce/woocommerce-blocks/pull/9348)

* Add changelog entries to readme.txt

* Update version number in several files

* Add testing notes for the release

* Add woocommerce/woocommerce-blocks#9332 to testing notes

* Add testing on frontend for woocommerce/woocommerce-blocks#9332

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Tom Cafferkey <tjcafferkey@gmail.com>
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
2023-05-05 11:34:51 +02:00
Daniel W. Robert 18e4ffa741 Add permalink to plugin documentation in readme. (https://github.com/woocommerce/woocommerce-blocks/pull/9343)
The plugin's readme.txt file had a URL to the official documentation but
there was no hyperlink - only text.

This improves the page by removing the text link and hyperlinking the
"official documentation" text itself.
2023-05-04 23:15:12 -04:00
Roy Ho e788db408c Convert to use WP core blocks (https://github.com/woocommerce/woocommerce-blocks/pull/9340) 2023-05-04 06:04:24 -07:00
Roy Ho 1efa47c076 Add product hero pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9181)
* Add product hero wide pattern

* Convert to using WP core blocks
2023-05-04 06:00:15 -07:00
Luigi Teschio 145bc25100 use 'enqueue_block_assets' is available (https://github.com/woocommerce/woocommerce-blocks/pull/9332) 2023-05-04 12:32:23 +00:00
Luigi Teschio fccdb92612 Single Product Template - Related Products: fix items per page option (https://github.com/woocommerce/woocommerce-blocks/pull/9286) 2023-05-04 12:21:20 +00:00
Tom Cafferkey f11bdbe0b3 Remove esc_url() on self generated link to edit the Mini Cart template since it gets escaped in JS (https://github.com/woocommerce/woocommerce-blocks/pull/9348) 2023-05-04 10:02:46 +01:00
Albert Juhé Lluveras 4bccbb61d7 Remove duplicated code in BlockTypesController.php (https://github.com/woocommerce/woocommerce-blocks/pull/9283) 2023-05-04 10:36:35 +02:00
Albert Juhé Lluveras 19332e960d Fix Product Price styles leaking into the Mini Cart, Cart and Checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/9276)
* Fix Product Price styles leaking into the Mini Cart

* Add support for All Products block
2023-05-04 09:32:45 +02:00
dependabot[bot] 2e4557bdb7 Bump automattic/jetpack-autoloader from 2.11.18 to 2.11.19 (https://github.com/woocommerce/woocommerce-blocks/pull/9305)
Bumps [automattic/jetpack-autoloader](https://github.com/Automattic/jetpack-autoloader) from 2.11.18 to 2.11.19.
- [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.18...v2.11.19)

---
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>
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
2023-05-03 17:21:04 -03:00
Daniel W. Robert 7567475a60 Implement new `Hero Product – Split` pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9191)
* Add pattern for split hero product banner.

This adds a new pattern for a hero product banner with a 50/50 split,
heading and CTA on left and product image on right.

Uses the Media + Text block.

* Update image to use Unsplash placeholder.

* Remove WooCommerce prefix in pattern title.

* Remove unneeded wrapper group block.

* Serve placeholder image from plugin directory.
2023-05-03 12:11:24 -04:00
Tom Cafferkey 150120774a Check that the customized fallback template is archive-product before unsetting the source property (https://github.com/woocommerce/woocommerce-blocks/pull/9330) 2023-05-03 15:33:03 +01:00
Roy Ho 721257d32a Add featured category cover image (https://github.com/woocommerce/woocommerce-blocks/pull/9284)
* Add featured category cover image

* Use WP core blocks

* Explicitly add meassurement type
2023-05-03 06:51:52 -07:00
Thomas Roberts fdfb445a58 Prevent email address being removed when changing shipping method/entering shipping address (https://github.com/woocommerce/woocommerce-blocks/pull/9328)
* Preserve email when rendering shipping address form for the first time

* Ensure billing email does not reset when changing form values

* Add test to ensure email does not get overwritten
2023-05-03 06:45:57 -07:00
Alba Rincón b813a98691 [Pattern] Add new `Hero product 3 split` pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9319)
* Add new `Hero product 3 split` pattern

* Improve colors and margins
2023-05-03 15:44:05 +02:00
Patricia Hillebrandt 6e76fba561 Single Product Block > Ensure the product title is correct when used in a post or page (https://github.com/woocommerce/woocommerce-blocks/pull/9335)
* Ensure the product title is correct when used outside of the scope of the single product template.

* Update docblock with the details about the temporary workaround.
2023-05-03 15:08:41 +02:00
Mike Jolley 3743b024b7 Refactor klona usage (https://github.com/woocommerce/woocommerce-blocks/pull/9320)
* cloneObject in tests

* Create custom updateNested function instead of deepCloning objects

* Update type based on feedback
2023-05-03 12:09:12 +01:00
Luigi Teschio fed679cbeb Rename Add to Cart (https://github.com/woocommerce/woocommerce-blocks/pull/9315)
* rename Add to Cart

* fix E2E test
2023-05-03 10:31:59 +00:00
Luigi Teschio 0ea4dab3c9 Product Image Gallery: fix resize width when the window resize (https://github.com/woocommerce/woocommerce-blocks/pull/9299) 2023-05-03 08:44:22 +00:00
Alba Rincón 0aa8c79790 [Pattern] Add new `Product Collections: Newest Arrivals` pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9240)
* Add new `Product Collections: Newest Arrivals` pattern

* Remove ID

* Improve paddings

* Use product image with thumbnail style
2023-05-03 10:03:45 +02:00
Albert Juhé Lluveras 4534beaa91 Fix Mini Cart block not respecting Add-to-Cart behaviour attribute when adding the first product (https://github.com/woocommerce/woocommerce-blocks/pull/9257) 2023-05-03 09:49:43 +02:00
Mike Jolley 1a0f209770 Fix shipping notices for multiple packages (https://github.com/woocommerce/woocommerce-blocks/pull/9285)
* Move notice to top and only show on cart page

* Missing setting on cart page prevents notice display

* Allow null in the select-shipping-rate endpoint to select all packages

* Only show the warning if different packages are selected

* Check if selected rates is an object before mapping it

---------

Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-05-02 16:04:29 +01:00
Roy Ho bcfc330f8a Add/featured category focus pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9322)
* Add category focus pattern

* Fix text

* Explicit add padding and make image smaller
2023-05-02 07:16:44 -07:00
Albert Juhé Lluveras bad0222385 Related Products: make Product Title a link (https://github.com/woocommerce/woocommerce-blocks/pull/9179) 2023-05-02 11:36:23 +02:00
Luigi Teschio 114ba02135 Product Image Gallery: fix inline (https://github.com/woocommerce/woocommerce-blocks/pull/9297) 2023-05-02 09:11:58 +00:00
Alexandre Lara 448f8102d9 Product Rating block: Fix review count not displaying on frontend (https://github.com/woocommerce/woocommerce-blocks/pull/9129)
* Fix review count not displaying on Product Rating

* Fix PHP CS errors

* Add Customer Reviews count to the Product Rating block on the Editor

* Remove unnecessary var_dump
2023-04-28 14:26:43 -03:00
Roy Ho 5297d93d37 Add featured category triple pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9269) 2023-04-28 05:35:54 -07:00
Alba Rincón 9524c3607d Add new `Product collections: Featured Collection` pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9246)
* Add new `Product collections: Featured Collection` pattern

* Improve padding

* Set text color to white

* Make string translatable
2023-04-28 13:58:46 +02:00
Mike Jolley 2d506f9f57 Fix/you do not need lodash (https://github.com/woocommerce/woocommerce-blocks/pull/9161)
* Remove lodash `without` usage

* isNumber

* Remove lodash `difference`

* Replace lodash isEmpty with type guard

* Replace isObject with type guard

* remove lodash noop

* Replace lodash clamp

* replace lodash uniqueId

* Remove uniqueId import

* Add eslint rule to restrict lodash import

* Replace lodash range

* Replace lodash has() function

Replace lodash has

* replace omitby

* Replace lodash isEqual with fastDeepEqual

* Replace kebabCase with change-case package

* Replace lodash camelCase

Replace lodash mapKeys with function

Move mapkeys to utility

Create camelCaseKeys which replaces usage of mapKeys

* Replace lodash debounce with custom utiity

* replace lodash keyby

* Replace lodash pick with native function

* Replace lodash cloneDeep with klona

* Replace snake case keys package with change case

* Replace sortBy with fast sort package

* replace isEmpty with type guard

* Replace pickBy usage in validation reducer

* Replace groupBy usage in search list control

* Replace flatten, uniqBy usage in getProducts()

* Remove setWith and clone from updateState

* Replace custom useThrottle with useThrottledCallback from use-debounce package

* onSelectRate can use-debounce

* Fix missing flatten

* Update assets/js/data/cart/test/push-changes.ts

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

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
2023-04-28 11:29:45 +01:00
Tom Cafferkey a22ab08410 Remove min-height and padding for WP Button elements (https://github.com/woocommerce/woocommerce-blocks/pull/9260)
* Remove min-height and padding for WP Button elements

* Remove commented out code

* Add min-height style back in for .woocommerce-block-theme-has-button-styles themes
2023-04-28 10:49:12 +01:00
Andres 98222dda09 Fix store api documentation for min_price and max_price (https://github.com/woocommerce/woocommerce-blocks/pull/9258)
* Fixed store api documentation for min_price and max_price

* Update products.md

* Update products.md

* Update src/StoreApi/docs/products.md

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

---------

Co-authored-by: Karol Manijak <karol.manijak@automattic.com>
2023-04-28 10:56:22 +02:00
Manish Menaria 1e1b82ad63 Products block: Using nested selector to add margin between Product elements (https://github.com/woocommerce/woocommerce-blocks/pull/8993)
* Using nested selector to style Product elements in Products Block

This commit simplifies the INNER_BLOCKS_TEMPLATE array in the product-query constants.ts file by removing the style properties from the individual elements. Instead, the default styles are now managed in the style.scss file, providing a more consistent and centralized approach to styling.

In the style.scss file, a new section for default styling has been added to handle product elements inside the Products Block, adhering to the Gutenberg styling hierarchy. This ensures the lowest precedence in the hierarchy, allowing for easier overrides when needed.

* Decrease specificity of styles for product elements in Products Block

The commit changes the default styles for product elements inside the 'Products Block'. It changes the way the margin-bottom and margin-top properties are set by using the :where() selector instead of using the .products-block-post-template class selector. This is done to decrease the specificity of the CSS selector, ensuring that the styles have the lowest precedence in the hierarchy. It also removes the display: inline-block property from the a selector, and moves the styles to the .editor-styles-wrapper class selector.

* Decrease specificity of CSS selectors

In these changes, the product elements inside the Products Block have been restyled. The specificity of the CSS selector has been decreased using the :where() selector, to ensure that these styles have the lowest precedence in the hierarchy.

In constants.ts, a new class name, products-block-post-template, has been added to the inner block template for the post. This class is used to add default styles for inner blocks.

In style.scss, the CSS selector for the inner blocks has been updated to include the new class name. The :where() selector has also been used to ensure that these styles have the lowest precedence in the hierarchy.

* Update default margins and remove redundant entries

This commit updates the default margin values for the Product Title in the Products block, moving them from the style.scss file to the constants.ts file. It also removes unnecessary empty arrays in the INNER_BLOCKS_TEMPLATE and background-color property from the style.scss file.
2023-04-28 07:43:47 +00:00
Albert Juhé Lluveras d7fa7a3310 10.1.0 testing steps: move Mini Cart width items under Feature plugin section (https://github.com/woocommerce/woocommerce-blocks/pull/9263) 2023-04-28 09:17:53 +02:00
Tarun Vijwani 4934d19b6a Fix coupon code translation in e2e tests (https://github.com/woocommerce/woocommerce-blocks/pull/9247)
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
2023-04-28 10:40:36 +04:00
Alexandre Lara aacd82c8fb Single Product block: Add wide and full-width alignments support (https://github.com/woocommerce/woocommerce-blocks/pull/8981)
* Add align support to single product block

* Fix block alignment that was not being set on the frontend

* Remove classname prop from the Single Product Edit component
2023-04-27 16:44:10 -03:00
Luigi Teschio 1d0ff02f8f Rename Add To Cart Form to Add To Cart Options (https://github.com/woocommerce/woocommerce-blocks/pull/9238) 2023-04-27 17:05:50 +00:00
Albert Juhé Lluveras 1dc7c953eb Rename docs which unnecessary mention the All Products block (https://github.com/woocommerce/woocommerce-blocks/pull/9265)
* Rename docs which unnecessary mention the All Products block

* Fix two more links
2023-04-27 18:26:18 +02:00
Alba Rincón 4cea6664a5 [Patterns]: Add new `Header Centered Search` pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9081)
* Add new `Header Centered Search` pattern

* Add margin support to the customer account block

* Add margin to the customer account to separate it from the search bar

* Update margin

* Add with, fix margins

* Remove unnecessary separator

* Updates after review

* Remove ref

* Remove separator

* Bring back separator and use product search

* Remove html block and fix search border
2023-04-27 10:23:24 +02:00
Alba Rincón 2b75d821fa [Patterns] Add new `Footer with 3 menus` menu (https://github.com/woocommerce/woocommerce-blocks/pull/9175)
* Add new `Footer with 3 menus` menu

* Stack menus on mobile, remove refs

* Change the site title to a `p` tag

* Align menus to the top and add paddings

* Make the `powered by` string translatable and add padding

* Improve search
2023-04-27 10:22:43 +02:00
Paulo Arromba 7fd3063239 re added codeql-analysis.yml (https://github.com/woocommerce/woocommerce-blocks/pull/9253) 2023-04-26 21:09:55 +01:00
Paulo Arromba a50e2a91a5 Update CodeQL/Analyse (https://github.com/woocommerce/woocommerce-blocks/pull/9156)
* yaml format, typescript test

* removed codeql-analysis.yml

* typo fix for CI trigger

* Revert "removed codeql-analysis.yml"

This reverts commit 0badabe02a006fd7b1cffa9aac1eb2bc138ff964.

* re-add codeql-analysis.yml

* removed codeql-analysis.yml
2023-04-26 19:50:19 +01:00
Alexandre Lara 27b3b47edd Update plugin version 2023-04-26 14:25:17 -03:00
Alexandre Lara cdb41422ca Update changelog and testing notes with PRs woocommerce/woocommerce-blocks#9195 and woocommerce/woocommerce-blocks#9196 2023-04-26 14:22:07 -03:00
Alexandre Lara 43b58d41d6 Add PR woocommerce/woocommerce-blocks#9196 to the release notes 2023-04-26 14:21:51 -03:00
Alexandre Lara b3f6bb7a61 Update woocommerce-gutenberg-products-block.zip link 2023-04-26 14:21:39 -03:00
Alexandre Lara 0dac78f781 Add some improvements to the testing notes 2023-04-26 14:21:27 -03:00
Alexandre Lara 54059baf00 Update testing notes 2023-04-26 14:21:02 -03:00
Alexandre Lara 3349140955 Add testing notes for the release 2023-04-26 14:20:49 -03:00
Alexandre Lara 7e1be7ab29 Increase WordPress and WooCommerce minimum versions 2023-04-26 14:20:32 -03:00
Alexandre Lara 59c6885476 Update version number in several files 2023-04-26 14:20:11 -03:00
Alexandre Lara 968337cc51 Add changelog entries to readme.txt 2023-04-26 14:18:54 -03:00
Mike Jolley 61bc923949 Add examples for adding variations to the cart (https://github.com/woocommerce/woocommerce-blocks/pull/9086)
Fixes woocommerce/woocommerce-blocks#8626
2023-04-26 16:24:33 +01:00
Albert Juhé Lluveras 0dae33e4b9 Use currentColor for Mini Cart footer border (https://github.com/woocommerce/woocommerce-blocks/pull/9245) 2023-04-26 16:59:35 +02:00
Luigi Teschio 8e0709eb9a Update the icon and description for the Product Details block (https://github.com/woocommerce/woocommerce-blocks/pull/9241)
* Update icon and description for the Product Details block

* fix alt
2023-04-26 16:19:01 +02:00
Luigi Teschio 2ca2287cb8 Update icon and description for the Product Meta block (https://github.com/woocommerce/woocommerce-blocks/pull/9243)
* Update icon and description for the Product Meta block

* fix alt
2023-04-26 12:16:54 +00:00
Albert Juhé Lluveras cb8040f7b0 Mini Cart Contents block: fix wide width not being applied in the editor (https://github.com/woocommerce/woocommerce-blocks/pull/9201) 2023-04-26 12:16:43 +02:00
Daniel W. Robert aa219a1aa1 Fix Semgrep Security Scan Issues (https://github.com/woocommerce/woocommerce-blocks/pull/9204)
* Add late escaping to  call in MiniCart.

* Add escaping to  call in AssetsController.

* Add escaping to  calls in StoreAPI pagination utils.

* Add ignore line to file require - OK.

* Minor update to grammar in code comment.
2023-04-25 21:41:26 -04:00
Albert Juhé Lluveras 96bd0432cd Mini Cart Contents block: set minimum width (https://github.com/woocommerce/woocommerce-blocks/pull/9196)
* Mini Cart Contents block: set minimum width

* Mini Cart Contents block: allow changing the width only in the feature plugin

* Allow resetting the Mini Cart Contents width to the default

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

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

---------

Co-authored-by: Karol Manijak <karol.manijak@automattic.com>
2023-04-25 18:54:35 +02:00
Alba Rincón 1673fcb3c2 [Patterns]: Add new `Featured products: 5-item grid` pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9006)
* Add new pattern

* Style improvements after review

* Fix price on mobile and image thumbnail

* Remove columns for title and price

* Review improvements

* Use shop url

* Make the product title bold
2023-04-25 16:22:58 +02:00
Roy Ho 212a600477 Add testimonials single pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9184)
* Add testimonials single pattern

* Fix invalid content

* Align message
2023-04-25 06:58:27 -07:00
Albert Juhé Lluveras ce97f918ea Mini Cart block: fix slide in animation (https://github.com/woocommerce/woocommerce-blocks/pull/9195) 2023-04-25 13:39:21 +02:00
Albert Juhé Lluveras d0294f1abf Patch release checklist: clarify whether the PR must have trunk or release/x.y as the base branch (https://github.com/woocommerce/woocommerce-blocks/pull/9182) 2023-04-25 10:36:30 +02:00
Karol Manijak 948db63e95 Temporarily disable Playwright tests until the conflict with PHP version is resolved (https://github.com/woocommerce/woocommerce-blocks/pull/9183)
* Temporarily disable Playwright tests until the conflict with PHP versions is resolved

* Use a correct syntax

* Remove unwanted change
2023-04-24 16:57:38 +02:00
Alba Rincón 98dc3d2eab [Patterns]: Add new `Featured Products 2 columns` pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9072)
* Add new `Featured Products 2 columns` pattern

* Remove line separator

* Change title and add shop url

* Improve copy
2023-04-24 10:33:15 +02:00
Alba Rincón f2c19e0ac2 Add new `Testimonials: 3 columns` pattern (https://github.com/woocommerce/woocommerce-blocks/pull/9159) 2023-04-24 10:15:55 +02:00
Thomas Roberts 30aecd2068 Reinstate "Hide shipping costs until an address is entered" but disable it when using local pickup (https://github.com/woocommerce/woocommerce-blocks/pull/8964)
* Add class property to track local pickup enabled

* Force shipping enabled only when local pickup is also enabled

Otherwise, skip filtering and leave it to the current value

* Disabled and add text to WC Core hide shipping option

* Skip forcing shipping to be enabled in all cases

* Remove WC Core setting changes for hidden shipping rates option

* Add warning to local pickup UI about hidden rates setting in core

* Add local_pickup_enabled util function

* Revert "Skip forcing shipping to be enabled in all cases"

This reverts commit 0bf1886e73d791f7828ac86988f681cdce808b12.

* Check if local pickup is enabled before force enabling shipping

* Show correct shipping placeholder if rates hidden until address entered

* Remove tests for removed functionality

* Remove shippingCostRequiresAddress prop

* Update tests for shipping settings

* Remove irrelevant tests and fix existing ones

* Fix typo in comment

* Disable local pickup after each test

* Get shipping data from useCustomerData hook

* Change div in help prop to span

This prevents a DOM Nesting error, div cannot appear as a descendant of p

* Prevent hide shipping notice showing if the setting was originally off
2023-04-22 02:10:11 -07:00
Daniel W. Robert 6903009af3 Add prepare script for Husky configuration. (https://github.com/woocommerce/woocommerce-blocks/pull/9167) 2023-04-21 16:51:56 -04:00
Roy Ho bb28479db5 Update php installation link (https://github.com/woocommerce/woocommerce-blocks/pull/9169)
* Update php installation link

* Set temporary debugging

* Add an exception to ignore valid link check
2023-04-21 13:18:30 -07:00
Tarun Vijwani e39a27bd74 Add theme-level global styles to Cart and Checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/8809)
* Dummy commit to open a PR

* Revert the last change

* Ensure Checkout block supports the theme-level global styles for `Colors » Buttons` (https://github.com/woocommerce/woocommerce-blocks/pull/8844)

* Add GS support for button colors in Checkout block

* Sync button hover effect with GB

* Fix link margin/padding (https://github.com/woocommerce/woocommerce-blocks/pull/8908)

* Replace <AddToCartButton /> with <ProductButton /> (https://github.com/woocommerce/woocommerce-blocks/pull/8914)

* Add GS support for button typography in Checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/8918)

* Ensure Checkout block supports the theme-level global styles for Typography » Buttons (https://github.com/woocommerce/woocommerce-blocks/pull/8892)

* Remove classname from cart image to avoid conflicts (https://github.com/woocommerce/woocommerce-blocks/pull/8898)

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

* Use consistent and semantically correct HTML elements in the Cart and Checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/9065)

* Allow button height to adjust

* Ensure to display full width heading background

* Inherit font style and font weight for headings

* Inherit font style and font weight for textarea

* Inherit font family and font weight for buttons

---------

Co-authored-by: Niels Lange <info@nielslange.de>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
2023-04-22 00:11:10 +04:00
Kirtan Gajjar 030a9ae267 Fix filter by stock status dropdown ordering (https://github.com/woocommerce/woocommerce-blocks/pull/9127)
* Fix filter by stock status dropdown ordering

* Update assets/js/blocks/stock-filter/utils.ts

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

* Update assets/js/blocks/stock-filter/utils.ts

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

---------

Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com>
2023-04-21 14:04:34 -03:00
Paulo Arromba 7c25db1c80 Add PHP 8.1/8.2 to unit testing matrix (https://github.com/woocommerce/woocommerce-blocks/pull/8757)
* Added PHP 8.1 to unit testing matrix

* Refactor unit testing to match Gutenberg repo 🤞

* Removed Gutenberg reference from debug information

* Updated image running phpunit binary

* Reverted image running phpunit binary

* Remove composer platform override

* Bump @wordpress/env and include phpunit

* Update phpunit and tests

* Change prefix

* Try admin context when install wc

* try wc install

* adjust phpunit config file

* Updated phpunit.xml.dist, composer.json and package.json

* Added PHP 8.1 to unit testing matrix

* Refactor unit testing to match Gutenberg repo 🤞

* Removed Gutenberg reference from debug information

* Updated image running phpunit binary

* Reverted image running phpunit binary

* Remove composer platform override

* Bump @wordpress/env and include phpunit

* Update phpunit and tests

* Change prefix

* Try admin context when install wc

* try wc install

* adjust phpunit config file

* Updated phpunit.xml.dist, composer.json and package.json

* Revert install changes

* updated npm packages

* updated composer lock

* updated check assets flow

* Updated check assets flow. Yaml file auto formatted.

* Updated check assets flow.

* Attempt at fixing E2E

* Reverted setup permissions step

* Add logging information to E2E

* Reverted E2E test flow

* test playwright perms fix

* test e2e perms fix

* test e2e perms fix

* test e2e perms fix

* test e2e perms fix

* languages update & debug

* languages update & debug

* revert

* force "@wordpress/env": "^4.9.0" on E2E

* update package lock

* update package lock

---------

Co-authored-by: Mike Jolley <mike.jolley@me.com>
Co-authored-by: Niels Lange <info@nielslange.de>
2023-04-21 12:07:37 +01:00
github-actions[bot] a2ca41e367 Release: 10.0.3 (https://github.com/woocommerce/woocommerce-blocks/pull/9149)
* Empty commit for release pull request

* Add 10.0.3 changelog

* Update versions to 10.0.3

* Fix image editor in Featured Product/Category blocks on WP 6.2 (https://github.com/woocommerce/woocommerce-blocks/pull/9142)

* Add 10.0.3 testing steps

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2023-04-21 12:40:53 +02:00
Albert Juhé Lluveras 8de8fc917c Add 10.0.3 testing steps 2023-04-21 10:44:43 +02:00
Albert Juhé Lluveras fa8d88a7c3 Add 10.0.3 changelog 2023-04-21 10:44:28 +02:00
Albert Juhé Lluveras 467e9734a2 Add 9.8.5 testing steps 2023-04-21 10:20:11 +02:00
Albert Juhé Lluveras 701a7269b2 Add 9.8.5 changelog 2023-04-21 10:19:06 +02:00
Albert Juhé Lluveras 813646be06 Update Husky config to v8 (https://github.com/woocommerce/woocommerce-blocks/pull/9150) 2023-04-21 10:07:55 +02:00
dependabot[bot] e745b44010 Bump @octokit/graphql from 4.8.0 to 5.0.5 (https://github.com/woocommerce/woocommerce-blocks/pull/8880)
Bumps [@octokit/graphql](https://github.com/octokit/graphql.js) from 4.8.0 to 5.0.5.
- [Release notes](https://github.com/octokit/graphql.js/releases)
- [Commits](https://github.com/octokit/graphql.js/compare/v4.8.0...v5.0.5)

---
updated-dependencies:
- dependency-name: "@octokit/graphql"
  dependency-type: direct:development
  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-04-20 19:55:37 +02:00
Roy Ho 90f59de4f6 Update minimal header patterns (https://github.com/woocommerce/woocommerce-blocks/pull/9126)
* Update minimal header patterns

* Remove ref

* Remove dark pattern and indent code
2023-04-20 07:46:15 -07:00
Karol Manijak d5ae033b54 Update @actions/core and @actions/github (https://github.com/woocommerce/woocommerce-blocks/pull/9133)
* Update @actions/core and @actions/github

* Add rimraf as a script to avoid actions failing

* Bump AbleLincoln/push-to-sftp which supports Node 16
2023-04-20 16:46:01 +02:00
Albert Juhé Lluveras 87ce986719 Fix image editor in Featured Product/Category blocks on WP 6.2 (https://github.com/woocommerce/woocommerce-blocks/pull/9142) 2023-04-20 15:56:42 +02:00
Roy Ho 642f227753 Add workflow to label community contributors (https://github.com/woocommerce/woocommerce-blocks/pull/8995)
* Add workflow to label community contributors

* Add action dependencies to package.json
2023-04-20 05:44:28 -07:00
Siddharth Thevaril cb378d2e9d fix/8129: remove rounding the caused issue with UI (https://github.com/woocommerce/woocommerce-blocks/pull/9118)
* remove rounding the caused issue with UI

* jslint autofixes

---------

Co-authored-by: Niels Lange <info@nielslange.de>
Co-authored-by: Karol Manijak <karol.manijak@automattic.com>
Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com>
2023-04-20 08:41:36 -03:00
Luigi Teschio 7b2830eafa wrap getComputedStyle function inside a useMemo (https://github.com/woocommerce/woocommerce-blocks/pull/9132) 2023-04-20 11:30:29 +02:00
Siddharth Thevaril b3acdea73c add cursor:pointer to checkbox and radio fields (https://github.com/woocommerce/woocommerce-blocks/pull/9102)
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
2023-04-20 12:40:02 +07:00
Dharmesh Patel 32f43e3d84 fix/8651: Use body background color as the Cart block sticky footer background color (https://github.com/woocommerce/woocommerce-blocks/pull/9103)
* Use body background color as the Cart block sticky footer background color

* Reduce the opacity of box-shadow.

* Fix the Proceed to Checkout button cut off.
2023-04-19 18:15:10 +01:00
Domenico Nusca 7dcb7768b2 decode entities for display in TextInput (https://github.com/woocommerce/woocommerce-blocks/pull/9117)
Co-authored-by: Domenico <dom@digitaltroop.net>
2023-04-19 17:53:26 +01:00
Siddharth Thevaril 50f08e6143 fix/8946: replace ToggleGroupControl with ToggleControl (https://github.com/woocommerce/woocommerce-blocks/pull/9098)
* replace ToggleGroupControl with ToggleControl

* eslint fix

* Fix linting in assets/js/mini-cart/edit.tsx file

---------

Co-authored-by: Niels Lange <info@nielslange.de>
Co-authored-by: Karol Manijak <karol.manijak@automattic.com>
2023-04-19 17:45:48 +02:00
Albert Juhé Lluveras 022e532688 WC Blocks 9.9.0 testing steps: move woocommerce/woocommerce-blocks#8781 testing steps to Feature Plugin section 2023-04-19 15:22:59 +02:00
Dharmesh Patel 4743d4fd93 fix/8363: Match checkout block Place order button UI with frontend (https://github.com/woocommerce/woocommerce-blocks/pull/9094)
Co-authored-by: Niels Lange <info@nielslange.de>
2023-04-19 14:09:06 +01:00
Albert Juhé Lluveras 114dc821ae Update step to mention that patch releases need to be merged into the base branch (https://github.com/woocommerce/woocommerce-blocks/pull/9097)
* Update step to mention that patch releases need to be merged into the base branch

* Minor improvements
2023-04-19 14:01:27 +02:00
Dharmesh Patel dcaf20a7c9 Fix - "Order received" page does not display the payment method information. (https://github.com/woocommerce/woocommerce-blocks/pull/9092)
* Fix - "Order received" page does not display the payment method information.

* changed fix approach by explicitly set payment method title.

---------

Co-authored-by: Niels Lange <info@nielslange.de>
2023-04-19 12:23:20 +01:00
Albert Juhé Lluveras 7816bdda51 Release: 10.0.2 (https://github.com/woocommerce/woocommerce-blocks/pull/9093)
* Empty commit for release pull request

* Add 10.0.2 changelog

* Update versions to 10.0.2

* Fix broken post/page editor screens in WordPress versions earlier than 6.2 (https://github.com/woocommerce/woocommerce-blocks/pull/9090)

* Fix infinite loop (range error) on subscribe callback.

* Replace getEditedPostContext with getEditedPostId to retrieve the templateId from the Site Editor for 6.1.1 compatibility

---------

Co-authored-by: tjcafferkey <tjcafferkey@gmail.com>

* Add 10.0.2 testing steps

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
Co-authored-by: tjcafferkey <tjcafferkey@gmail.com>
2023-04-19 11:12:03 +02:00
Albert Juhé Lluveras f92a4d8a13 Filter Products by Attribute e2e test: wait until networkidle before running tests (https://github.com/woocommerce/woocommerce-blocks/pull/9083)
* Wait until networkidle before running tests

* Copy logic to select first attribute from PHP classic template tests

* Create util function to insertProductByAttributeBlockWithFirstAttribute
2023-04-19 10:19:49 +02:00
Albert Juhé Lluveras 33f5bef3f0 Add 10.0.2 testing steps 2023-04-19 10:10:58 +02:00
Albert Juhé Lluveras 4e8bac92b2 Add 10.0.2 changelog 2023-04-19 10:10:49 +02:00
Karol Manijak 21269963e8 Get product by ID if there's more products returned from useStoreProducts (https://github.com/woocommerce/woocommerce-blocks/pull/9079)
* Get product by ID if there's more products returned from useStoreProducts
2023-04-19 09:52:16 +02:00
Luigi Teschio 4fbf32cef6 Product SKU: fix product SKU when added in the product meta block (https://github.com/woocommerce/woocommerce-blocks/pull/8966) 2023-04-19 07:47:03 +00:00
Luigi eb0d30c248 Merge branch 'release/10.0.0' of https://github.com/woocommerce/woocommerce-blocks into trunk 2023-04-19 09:19:19 +02:00
Darren Ethier 732827e60b Fix broken post/page editor screens in WordPress versions earlier than 6.2 (https://github.com/woocommerce/woocommerce-blocks/pull/9090)
* Fix infinite loop (range error) on subscribe callback.

* Replace getEditedPostContext with getEditedPostId to retrieve the templateId from the Site Editor for 6.1.1 compatibility

---------

Co-authored-by: tjcafferkey <tjcafferkey@gmail.com>
2023-04-19 09:08:40 +02:00
dependabot[bot] fbfc3a8d87 Bump wp-phpunit/wp-phpunit from 6.1.1 to 6.2.0 (https://github.com/woocommerce/woocommerce-blocks/pull/8935)
Bumps [wp-phpunit/wp-phpunit](https://github.com/wp-phpunit/wp-phpunit) from 6.1.1 to 6.2.0.
- [Release notes](https://github.com/wp-phpunit/wp-phpunit/releases)
- [Commits](https://github.com/wp-phpunit/wp-phpunit/compare/6.1.1...6.2.0)

---
updated-dependencies:
- dependency-name: wp-phpunit/wp-phpunit
  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-04-18 15:28:38 +02:00
Karol Manijak f3c28b9d78 Pass proper data to On Sale badge when used in the scope of Product Image (https://github.com/woocommerce/woocommerce-blocks/pull/9021)
* Don't use withProductDataContext in Sale Badge block

There was no information about product passed to the block, so it fetched information about all products which then wasn't even used

* Pass necessary props to the Sale Badge so it doesn't overfetch unnecessary data

* Move the import to the previous place
2023-04-18 14:53:50 +02:00
dependabot[bot] cbec25c463 Bump @wordpress/browserslist-config from 5.0.0 to 5.14.0 (https://github.com/woocommerce/woocommerce-blocks/pull/9087)
Bumps [@wordpress/browserslist-config](https://github.com/WordPress/gutenberg/tree/HEAD/packages/browserslist-config) from 5.0.0 to 5.14.0.
- [Release notes](https://github.com/WordPress/gutenberg/releases)
- [Changelog](https://github.com/WordPress/gutenberg/blob/trunk/packages/browserslist-config/CHANGELOG.md)
- [Commits](https://github.com/WordPress/gutenberg/commits/@wordpress/browserslist-config@5.14.0/packages/browserslist-config)

---
updated-dependencies:
- dependency-name: "@wordpress/browserslist-config"
  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-04-18 14:51:47 +02:00
dependabot[bot] a3db0c9e78 Bump AbleLincoln/push-to-sftp from 1.2 to 2.0 (https://github.com/woocommerce/woocommerce-blocks/pull/8597)
Bumps [AbleLincoln/push-to-sftp](https://github.com/AbleLincoln/push-to-sftp) from 1.2 to 2.0.
- [Release notes](https://github.com/AbleLincoln/push-to-sftp/releases)
- [Commits](https://github.com/AbleLincoln/push-to-sftp/compare/v1.2...v2.0)

---
updated-dependencies:
- dependency-name: AbleLincoln/push-to-sftp
  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-04-18 14:49:47 +02:00
github-actions[bot] 94a0ba2887 Release: 10.0.1 (https://github.com/woocommerce/woocommerce-blocks/pull/9084)
* Single Product Template - Compatibility Layer: don't skip custom HTML (https://github.com/woocommerce/woocommerce-blocks/pull/9075)

* Fix: tax_query should be calculated only if __woocommerceAttributes is valid (https://github.com/woocommerce/woocommerce-blocks/pull/9049)

This commit refactors the update_rest_query method in the ProductQuery.php file to improve code readability. It simplifies conditional expressions by introducing variables for clarity, and uses ternary operators to streamline the logic.

* Blockfied Single Product Template: Add support for template for specific product (https://github.com/woocommerce/woocommerce-blocks/pull/9069)

* Product Price Block: remove ProductSelector (https://github.com/woocommerce/woocommerce-blocks/pull/8980)

* Empty commit for release pull request

* Make Woo_Directive_Store PHP 7.3 compatible (https://github.com/woocommerce/woocommerce-blocks/pull/9033)

* update version

* add changelog

* add testing instructions

* update zip link file testing

* Update docs/internal-developers/testing/releases/1001.md

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

---------

Co-authored-by: Luigi Teschio <gigitux@gmail.com>
Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Viktor Szépe <viktor@szepe.net>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2023-04-18 14:24:04 +02:00
dependabot[bot] 060e0071f1 Bump yoast/phpunit-polyfills from 1.0.4 to 1.0.5 (https://github.com/woocommerce/woocommerce-blocks/pull/8936)
Bumps [yoast/phpunit-polyfills](https://github.com/Yoast/PHPUnit-Polyfills) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/Yoast/PHPUnit-Polyfills/releases)
- [Changelog](https://github.com/Yoast/PHPUnit-Polyfills/blob/2.x/CHANGELOG.md)
- [Commits](https://github.com/Yoast/PHPUnit-Polyfills/compare/1.0.4...1.0.5)

---
updated-dependencies:
- dependency-name: yoast/phpunit-polyfills
  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-04-18 14:17:51 +02:00
dependabot[bot] 57bdfa59e8 Bump husky from 2.4.1 to 8.0.3 (https://github.com/woocommerce/woocommerce-blocks/pull/8171)
Bumps [husky](https://github.com/typicode/husky) from 2.4.1 to 8.0.3.
- [Release notes](https://github.com/typicode/husky/releases)
- [Commits](https://github.com/typicode/husky/compare/v2.4.1...v8.0.3)

---
updated-dependencies:
- dependency-name: husky
  dependency-type: direct:development
  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-04-18 14:03:02 +02:00
dependabot[bot] 2d20b10b9b Bump @emotion/styled from 11.10.5 to 11.10.6 (https://github.com/woocommerce/woocommerce-blocks/pull/8882)
Bumps [@emotion/styled](https://github.com/emotion-js/emotion) from 11.10.5 to 11.10.6.
- [Release notes](https://github.com/emotion-js/emotion/releases)
- [Changelog](https://github.com/emotion-js/emotion/blob/main/CHANGELOG.md)
- [Commits](https://github.com/emotion-js/emotion/compare/@emotion/styled@11.10.5...@emotion/styled@11.10.6)

---
updated-dependencies:
- dependency-name: "@emotion/styled"
  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-04-18 13:42:50 +02:00
dependabot[bot] b5db6e3ed1 Bump automattic/jetpack-autoloader from 2.11.16 to 2.11.18 (https://github.com/woocommerce/woocommerce-blocks/pull/8934)
Bumps [automattic/jetpack-autoloader](https://github.com/Automattic/jetpack-autoloader) from 2.11.16 to 2.11.18.
- [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.16...v2.11.18)

---
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-04-18 12:31:15 +02:00
Viktor Szépe dca02da47c Make Woo_Directive_Store PHP 7.3 compatible (https://github.com/woocommerce/woocommerce-blocks/pull/9033) 2023-04-18 12:13:23 +02:00
Manish Menaria be5356d30a Product Stock indicator: Add support for background color, margin, padding & various typography controls (https://github.com/woocommerce/woocommerce-blocks/pull/8954)
* Add color, typography, and spacing support to Product SKU block

This commit introduces a new file `supports.ts` for the Product SKU block in the WooCommerce Blocks plugin, which adds color, typography, and spacing support. The following configuration has been added:

1. In `assets/js/atomic/blocks/product-elements/sku/supports.ts`, a new `supports` object is created, which extends the shared configuration and adds support for the following properties:
  - `text` and `background` color
  - `fontSize`, `lineHeight`, `__experimentalFontWeight`, `__experimentalFontFamily`, `__experimentalFontStyle`, `__experimentalTextTransform`, `__experimentalTextDecoration`, and `__experimentalLetterSpacing` for typography
  - `margin` and `padding` for spacing

* Add color, typography, and spacing support for Product SKU block in All Products block

This commit extends the support for color, typography, and spacing to the Product SKU block when used within the All Products block. The following changes have been made:

1. In `assets/js/atomic/blocks/product-elements/sku/block.tsx`, the `useColorProps`, `useSpacingProps`, and `useTypographyProps` hooks are imported and used to add the appropriate className and style properties to the rendered SKU element.
2. In `assets/js/atomic/blocks/product-elements/sku/edit.tsx`, the `style` property is separated from `useBlockProps()` and used directly on the `div` element for the SKU block.

* Add server-side rendering class for Product SKU Gutenberg block

This commit adds the ".wp-block-woocommerce-product-sku" class to the Product SKU Gutenberg block for server-side rendering purposes. The inclusion of this class ensures consistent styling between the editor and the front-end view of the block, providing a seamless experience for users.

The class name is generated based on the Gutenberg block prefix "wp-block", the namespace "woocommerce", and the block name "product-sku", creating a unique and identifiable class for the block. This class enables developers to target the block specifically in both the editor and front-end styles, maintaining the integrity of the block's appearance and functionality across different environments.

By adding this class to the server-side rendered version of the block, we ensure a unified and coherent styling experience throughout the block's usage.

* Fix minor issues

* Gate only experimental features behind isFeaturePluginBuild flag

This commit refactors the Product SKU block supports to enable color, typography, and spacing features for all builds, while keeping experimental features specific to the feature plugin build. It also adds necessary lint and TypeScript error handling for the experimental spacing API.

* Add overflow-wrap to Product SKU block and update comment

This commit adds the overflow-wrap property to the Product SKU block styles to handle long SKU values gracefully.
It also updates the comment for the experimental spacing API to better reflect the usage check.

* Refactor Product SKU block classname and style handling

This commit refactors the Product SKU block classname and style handling. It combines classnames for better readability and removes the hardcoded textTransform style in favor of default styles.
This also fix the issue where textTransform style was not working as expected.

* Add support for color, typography and spacing to stock indicator block

This commit updates the stock-indicator block support in the woocommerce-blocks repository. It includes the following changes:

- Added support for background color, line height, and various experimental typography features.
- Conditionally included support for margin and padding based on the availability of the __experimentalGetSpacingClassesAndStyles function from the @wordpress/block-editor package.

These updates provide more customization options for the stock-indicator block, allowing users to better match the appearance of this element to their site's design.

* Refactor stock text generation and apply minor style adjustments

This commit introduces a new function, `getTextBasedOnStock`, which handles the generation of stock text based on the stock information provided. It replaces the previous `lowStockText` and `stockText` functions, making the code more readable and maintainable.

In addition, minor adjustments to the class name handling have been made to simplify the code and ensure consistent styling when used inside the All Products block.

In the `edit.tsx` file, the `useBlockProps` function call has been updated to include the default `wc-block-components-product-stock-indicator` class name, ensuring it is always applied.

* Remove redundant block type supports in ProductStockIndicator

This commit removes the redundant get_block_type_supports() method from the ProductStockIndicator.php file, as it is no longer needed. The block type supports are now handled in the frontend.
2023-04-18 09:50:11 +00:00
Luigi Teschio a40f54e7f0 Single Product Template - Compatibility Layer: don't skip custom HTML (https://github.com/woocommerce/woocommerce-blocks/pull/9075) 2023-04-18 11:02:41 +02:00
Manish Menaria 4bfe9e7ff1 Fix: tax_query should be calculated only if __woocommerceAttributes is valid (https://github.com/woocommerce/woocommerce-blocks/pull/9049)
This commit refactors the update_rest_query method in the ProductQuery.php file to improve code readability. It simplifies conditional expressions by introducing variables for clarity, and uses ternary operators to streamline the logic.
2023-04-18 05:49:59 +00:00
Albert Juhé Lluveras cb9980c519 Mini Cart: Remove excessive margin under cart items (https://github.com/woocommerce/woocommerce-blocks/pull/9051) 2023-04-17 18:52:43 +02:00
leonardo lopes de albuquerque c58a09a8ef Fixed trim is not a function error when address has an attribute that is not a string (https://github.com/woocommerce/woocommerce-blocks/pull/8988) 2023-04-17 13:57:09 +00:00
Luigi Teschio 4a36f19255 Blockfied Single Product Template: Add support for template for specific product (https://github.com/woocommerce/woocommerce-blocks/pull/9069) 2023-04-17 12:23:00 +00:00
Niels Lange e7f8a8cb6e WIP: Add Playwright setup (https://github.com/woocommerce/woocommerce-blocks/pull/9034)
* Set up Playwright

* Use caching in GitHub Actions

* Update tests/e2e-pw/README.md

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

* Rename “{blockName}” to “{blockName} block”

* Disable “no-console” for setup and teardown files

* Remove obsolete log and adjusted disabled ESLint definition

* Remove conditional logic from actions/upload-artifact

---------

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
2023-04-17 19:01:41 +07:00
Albert Juhé Lluveras 79a713240b Mini Cart block: exclude already-printed scripts from scripts to lazy load (https://github.com/woocommerce/woocommerce-blocks/pull/8979) 2023-04-17 13:09:38 +02:00
Albert Juhé Lluveras 6123ba4433 Fix Mini Cart drawer not opening in RTL locales (https://github.com/woocommerce/woocommerce-blocks/pull/9066) 2023-04-17 10:02:26 +02:00
Albert Juhé Lluveras 779e13af15 Fix JS error visible in the editor caused by Mini Cart Contents buttons (https://github.com/woocommerce/woocommerce-blocks/pull/9039) 2023-04-14 16:53:39 +02:00
Alexandre Lara 0ad067d8a9 Add save method to Product Meta block (https://github.com/woocommerce/woocommerce-blocks/pull/9032) 2023-04-14 08:52:19 -03:00
Albert Juhé Lluveras ec01be5a3b Mini Cart template part: give user customized template priority over theme template (https://github.com/woocommerce/woocommerce-blocks/pull/9005)
* Mini Cart template part: give user customized template priority over theme template

* Use get_block_templates_from_db() from BlockTemplateUtils

* Add deprecation notice
2023-04-14 11:40:30 +02:00
Albert Juhé Lluveras af01052bbe Release checklist: update Release highlights page with highlights and use it to update WC core release announcement (https://github.com/woocommerce/woocommerce-blocks/pull/9028) 2023-04-14 11:08:59 +02:00
Albert Juhé Lluveras 495fc63629 JavaScript testing docs: add section about reports and update section about WP versions (https://github.com/woocommerce/woocommerce-blocks/pull/9020)
* Add section about 'Debugging e2e tests using generated reports'

* Update section in JavaScript testing about WP versions

* Update TOC

* Typo
2023-04-14 10:55:26 +02:00
Albert Juhé Lluveras c63923e2fb Display Mini Cart overlay in template part editor (https://github.com/woocommerce/woocommerce-blocks/pull/9014) 2023-04-14 10:44:09 +02:00
Karol Manijak 710221ad23 Update the docs regarding Product Collection Data endpoint in Store API (https://github.com/woocommerce/woocommerce-blocks/pull/9011)
* Update the docs regarding Product Collection Data endpoint in Store API

* Add the dots at the end of sentences

* Remove the  and  from Product Collection Data endpoint docs as it's covered in Products endpoint
2023-04-14 10:09:53 +02:00
Alba Rincón 99efb908d3 Store API: allow searching by `slug` and include `slug` in the response (https://github.com/woocommerce/woocommerce-blocks/pull/9017)
* Add ProductBySlug, search by slug and return slug field for products

* Search for product variation

* Add slug to tests

* Sanitize the slug
2023-04-14 10:06:47 +02:00
Alba Rincón b6039d1d74 Mini cart: allow changing the drawer width (https://github.com/woocommerce/woocommerce-blocks/pull/8930)
* WIP

* Add width control to the settings sidebar

* Fix linting errors

* Remove comments

* Inline function

* Fix issue with smaller viewports

* Remove unnecessary code
2023-04-14 09:48:55 +02:00
Alba Rincón 709a7a9add [Mini cart] Make the title customizable (https://github.com/woocommerce/woocommerce-blocks/pull/8905)
* Create the counter block and the header pattern

* Change the pattern to an inner block

* Allow customizing item counter block

* Rename block

* Allow removing the items counter block

* Add padding controls

* Preload new blocks

* Add title block back from the inserter

* Move h2 tag to the parent title

* Align items at the bottom

* Unify styles

* Add title class in the editor

* Prevent removing title blocks

* Disallow unlocking and inserter

* Disallowing moving blocks
2023-04-14 09:21:21 +02:00
Alba Rincón ad2003117e E2E tests fix: enable the attribute lookup direct updates settings (https://github.com/woocommerce/woocommerce-blocks/pull/9029)
* Enable the attribute lookup direct updates settings

We are importing products using the batch api and we need the lookup tables
to be updated immediately for our tests to work. Enabling this setting will
do that, instead of doing it asynchronously.

* Fix customer account test classes

* Increase timeout limit for failing tests

---------

Co-authored-by: roykho <roykho77@gmail.com>
2023-04-14 09:05:08 +02:00