* Refactor Columns Control inspector controls in Product Collection
* Refactor Order By inspector controls in Product Collection
* Reorder imports in Product Collection Inspector Controls
* Refactor On Sale inspector controls in Product Collection
* Refactor Stock Status inspector controls in Product Collection
* Refactor Keyword inspector controls in Product Collection
* Unify interface of query controlling Inspector Controls
* Unify interfaces of Inspector Controls that modify Query in Product Collection
* Unify other Query modifying Controls
* Simplify types
* Add E2E tests for category-based product filtering
This commit refactors the product filtering in the product collection E2E tests and adds the ability to filter products based on their category.
Changes:
1. The method `setHandpickedProducts` was renamed to `setFilterComboboxValue` to reflect the fact that it's now used for more than just handpicked products. This method is now used to set the values of different filters.
2. The `addFilter` method was extended to support the 'Show Taxonomies' filter. It also includes a delay to ensure the correct rendering of the UI before further interactions.
3. A new test was added for filtering products based on their category using the 'Show Taxonomies' filter.
4. The tests for filtering products by handpicked selection and keyword were updated to use the new `setFilterComboboxValue` method.
These changes improve the robustness of the E2E tests and increase their coverage by including category-based filtering.
* Add product attribute filters to end-to-end tests
- A new test case has been added in the `product-collection.block_theme.spec.ts` to test the functionality of filtering products based on their attributes like color and size. This is done using the `addFilter` and `setProductAttribute` methods.
- Additionally, the `addFilter` method in `product-collection.page.ts` has been updated to include the 'Show Product Attributes' filter.
- A new method `setProductAttribute` has been introduced to set the attribute value which will trigger the filter action.
These updates enhance the test coverage by verifying the functionality of product attribute filters in the product collection.
* Add responsiveness test for product collection block
This commit introduces a new end-to-end test to ensure that the product collection block responds correctly to changes in screen size.
The new test in `product-collection.block_theme.spec.ts` verifies that the number of product columns adjusts as expected for different viewport sizes. In the initial viewport size, the width of a product should be less than the parent width as multiple columns are expected. When the viewport size is reduced, the product width should be approximately equal to the parent width, indicating a single column layout.
These changes provide more robust testing of the product collection block's responsiveness, helping to ensure a consistent user experience across different device sizes.
* Refactor product assertions and add setViewportSize method in ProductCollection tests
This commit refactors the Product Collection tests to enhance test readability and consistency. It switches the product count checks from `productImages` to `products` which is more semantically correct.
Additionally, a new method `setViewportSize` has been added in the `ProductCollectionPage` class for adjusting the viewport size in the tests.
- Changed product count assertions to use `products` instead of `productImages`
- Added `setViewportSize` method to `ProductCollectionPage`
- Updated existing tests to use the newly added `setViewportSize` method
* Add test case for product filtering based on stock status in Product Collection tests
This commit adds a new test case in the Product Collection suite to test product filtering based on their stock status. The test case checks if the filter for 'Out of stock' status works correctly.
Note: This test case is currently commented out because there are no products with 'Out of stock' status in the test data. The assertions will need to be uncommented once the test data includes 'Out of stock' products.
* Add new test case for toolbar settings
This commit does two main things:
1) Adds a new test case under 'Toolbar settings' to test 'Items per page', 'offset' & 'max page to show' settings in the product collection block.
2) It extends the ProductCollectionPage class to add methods for setting display settings and for handling pagination. It also defines a new 'pagination' locator to find the pagination navigation on the page.
This update will allow us to more effectively test the behavior of the product collection block when dealing with large collections and pagination. Note: the 'Product can be filtered based on stock status' test has been marked as skipped until there are products with 'Out of stock' status in the test data.
* Refactor e2e test files for Product Collection
Changes in `product-collection.block_theme.spec.ts`:
- Marked the test 'Products can be filtered based on category' as a 'fixme'. This test is currently failing due to a bug in the product collection block.
Changes in `product-collection.page.ts`:
- Reorganized constant block data into a more extensive set of selectors.
- Introduced a new method `locateSidebarSettings` to locate the sidebar settings region, improving readability and reusability.
- Used the new method `locateSidebarSettings` in various places where settings values are being set.
- Refactored other methods to better locate elements based on the reorganized selectors.
- Adjusted the product-related locators to rely on these newly defined selectors.
* Fix: Frontend Category Filtering in Product Collection Block (https://github.com/woocommerce/woocommerce-blocks/pull/10132)
* Fix: Product collection - Product category filter isn't working on frontend
* Remove fixme from test
* Refactor variables names
* Add Display Layout controls to Product Collection
* Adjust the layout type name
* Add explicit display layout types
* Change the function name to setDisplayLayout so it's more explicit
* Pass only the necessary props to nested inspector controls
---------
Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
* Add support for filter blocks
This commit updates the `ProductCollection` block implementation to add support for filter blocks, including the Price filter, Attributes filter, Rating filter, and In stock filter.
The changes include:
1. Adding a new property `$attributes_filter_query_args` to store the query arguments related to the filter by attributes block.
2. Adding a new method `add_support_for_filter_blocks()` to enable support for filter blocks. This method sets the necessary asset data to enable filtering and refreshes the page when a filter is applied.
3. Adding new methods to handle specific filter queries, including `get_filter_by_price_query()`, `get_filter_by_attributes_query()`, `get_filter_by_stock_status_query()`, and `get_filter_by_rating_query()`. These methods generate the respective queries based on the applied filters.
4. Refactoring the `get_final_query_args()` method to include the newly added filter queries using the `get_queries_by_applied_filters()` method.
These changes enhance the functionality of the `ProductCollection` block by allowing users to filter products based on price, attributes, rating, and stock status.
* Go to first page when filters are updated
* Enhance ProductCollection block to support filter blocks
This commit enhances the ProductCollection block to support various filter blocks such as Price filter block, Attributes filter block, Rating filter block, and In stock filter block.
The `build_query` method has been refactored into two separate methods: `build_frontend_query` and `get_final_frontend_query` to make the code more modular and readable. The `add_support_for_filter_blocks` method has been modified to support the generation of product IDs for filter blocks.
The method `update_rest_query` has been renamed to `update_rest_query_in_editor` for better clarity and understanding of its function. Similarly, `get_final_query_args` has been refactored to include the `$is_exclude_applied_filters` parameter which helps in generating product IDs for the filter blocks.
Moreover, the filter hook `pre_render_block` has been added to support the filtering of blocks before they are rendered.
This update will enhance the user experience by providing more filtering options in the ProductCollection block.
* Remove changes related to redirect to 1st page
* Go to first page when filters are updated
This commit refactors the changeUrl function in the `filters.ts` file. The purpose of this refactor is to remove the page number from the URL whenever filters are changed. This ensures that the user is always taken to the first page of results.
The commit includes the following changes:
- Added comments explaining the different page number formats in the URL.
- Updated the `newUrl` parameter by removing the page number using regular expressions.
- The page is then reloaded with the updated URL using `window.location.href`.
These changes improve the URL handling in the `changeUrl` function and enhance the user experience when interacting with filters.
* Optimize URL updates to prevent unnecessary page reloads
This commit optimizes the `changeUrl` utility function to prevent unnecessary page reloads.
Changes:
1. It checks if there are no query parameters in the URL and the URL ends with a '?'.
2. If these conditions are met, it removes the trailing '?' from the URL.
The reason for this change is that a '?' in the URL typically indicates that query parameters will follow. If there are no query parameters, the '?' is unnecessary and can cause the page to reload, which can negatively affect performance. Therefore, by removing the '?', we prevent this unnecessary page reload.
* Simplify trailing '?' removal in URL handling
This commit simplifies the removal of trailing '?' characters from URLs.
The previous implementation checked if there were any query parameters
before removing a trailing '?'.
However, upon review, it was determined that this check was unnecessary,
as a trailing '?' could be removed safely even if query parameters were
present, without any negative impact.
This change simplifies the code and prevents unnecessary computation
checking for the existence of query parameters.
* Product Gallery: Add an new block base code
* Product Gallery: Add experimental flag
* Product Gallery: Add Large Image block code
* Product Gallery Large Image: Remove unsed types
* Product Gallery: Move the block from registerBlockType to registerBlockSingleProductTemplate
* Product Gallery: Update icon
* Product Gallery: Add missing icon import
* Product Gallery Large Image: Add experimental mode check
* Product Gallery Large Image: Deregister unnecessary block settings
* Product Gallery Large Image: Add experimental flag to the Product Gallery Large Image and remove the icon override
* Product Gallery Large Image: Add zoom and correct styling
* Product Gallery Large Image: Remove commented out unnecessary code
* Product Gallery Large Image: Re-add the removed action after capturing the large image html
* Product Gallery Large Image: Update Large Image icon and description. Move metadata to the block.json file.
* Revert "fix save method"
This reverts commit f6623c55320bf55ee7fa3c23eb294f06d79ee4a5.
* Revert "Revert "fix save method""
This reverts commit 739db2e3b0b62e10fbe1ebabd1ec6bbae8425b3c.
* Update Filter by Attribute and Filter by Stock e2e test fixtures
* Update Filter by Attribute 'can hide product count' test
* Remove data attributes from fixture for active filters
* Remove data attributes from fixture for filter by price
* Remove data attributes from fixture for filter by attribute
* Remove data attributes from fixture for filter by stock
* Render Checkout on Pay for Order for FSE themes with checkout flow templates.
Few typos corrected
* Render Checkout on Pay for Order for FSE themes with checkout flow templates.
Few typos corrected
* Backup and restore notices so they display on the pay page still
* Cache and restore notices during hydration to avoid breaking real notices on pages/shortcodes
---------
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* Product Gallery: Add an new block base code
* Product Gallery: Add experimental flag
* Product Gallery: Move the block from registerBlockType to registerBlockSingleProductTemplate
* Product Gallery: Update icon
* Add height & width setting to the image sidebar settings
* Extract settings and add scale options
* Add width settings
* Apply settings on the frontend
* Style placeholder image
* Replace post featured image with product image
* Allow the width to be wider than container
* Fix image on top of other elements
* Hide "collection from" text when a location has an incomplete address.
* Fix display on confirmation page
* has_valid_pickup_location helper
* Missing isset
* Update test
* Fix pickup text assertion
---------
Co-authored-by: Niels Lange <info@nielslange.de>
* Product Rating block > Ensure the customer reviews text is linked to the relevant reviews (https://github.com/woocommerce/woocommerce-blocks/pull/9998)
* Fix reviews count not showing on Single Product page
* Fix css style
* Product Rating block: Ensure the Customer reviews text is linked to the relevant reviews when used within the Single Product Template. When used within the Single Product Block, the link directs the user to the product template. Additionally, clear out\ PHPCS warnings.
* remove unnecessary call to wc_get_star_rating_html
---------
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
* Product Rating block: Fix reviews count not showing on Single Product page (https://github.com/woocommerce/woocommerce-blocks/pull/9995)
* Fix reviews count not showing on Single Product page
* Fix css style
* Single Product: Fix Product SKU not loading for different variations (https://github.com/woocommerce/woocommerce-blocks/pull/9990)
* Single Product: Fix incorrect add to cart form markup (https://github.com/woocommerce/woocommerce-blocks/pull/9986)
* Product Image Gallery block: Fix overflow when multiple images are used (https://github.com/woocommerce/woocommerce-blocks/pull/10013)
* Fix Product Image Gallery block overflow when multiple images are used
* Increase css specificity for the Product Image Gallery images
* Fix whitespace
* Fix style issue when using smaller images in the product image gallery
* Empty commit for release pull request
* update version
* add testing instructions
* update zip link
* Product Rating: append #reviews on the Single Product Block (https://github.com/woocommerce/woocommerce-blocks/pull/10040)
* Product Rating: append #reviews on the Single Product Block
* refactor after feedback
* fix version
* update zip link
* Single Product Block: avoid to register incompatibility blocks with the Single Product Block on the post/page editor (https://github.com/woocommerce/woocommerce-blocks/pull/10044)
* update testing instructions
* update zip link
---------
Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com>
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Luigi <gigitux@gmail.com>
* Fix Product Image Gallery block overflow when multiple images are used
* Increase css specificity for the Product Image Gallery images
* Fix whitespace
* Fix style issue when using smaller images in the product image gallery
* WIP: dirty attempt to dry run Cart & Checkout templates
* Added Cart and Checkout to the template hierarchies
* Merge branch 'trunk' into poc/cart_and_checkout_fse_templates
* Updated cart & Checkout templates
* Order Received FSE template (https://github.com/woocommerce/woocommerce-blocks/pull/8937)
* Order Received template bootstrap
* typo
* WIP: new block
* add logic here
* Order received classic template
* reverted constants.ts
* Added the post title (buggy)
* Corrected page title
* Updated constants.ts
* Fixed template typo
* removed placeholder for order received block
* add order-received template description
* updated placeholder description
* Formatting fixes
* Template description.
* replaced hardcoded string with OrderReceivedTemplate::SLUG
---------
Co-authored-by: Luigi <gigitux@gmail.com>
* Code formatting (https://github.com/woocommerce/woocommerce-blocks/pull/8350)
* Code formatting
* page_template_hierarchy priority to 1 (https://github.com/woocommerce/woocommerce-blocks/pull/9323)
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
* Migrate Cart and Checkout Pages to the Template Editor when using a FSE theme (https://github.com/woocommerce/woocommerce-blocks/pull/9339)
* Introduce woocommerce_blocks_template_content hook
* Migrate cart and checkout page content to the template editor
* Add redirection from edit page to edit template
---------
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
* Removed header and footer from checkout template. (https://github.com/woocommerce/woocommerce-blocks/pull/9378)
* Removed header and footer from checkout template.
* Removed header and footer from checkout template migration
* Permalink solution for the checkout endpoint/template (https://github.com/woocommerce/woocommerce-blocks/pull/9406)
* Checkout endpoint work
* Move setting field to util
* Include link to edit the template
* Remove todo
* Refactor checkout templates to share logic (https://github.com/woocommerce/woocommerce-blocks/pull/9411)
* Sync endpoints with pages (https://github.com/woocommerce/woocommerce-blocks/pull/9426)
* Switch to page syncing
* Update settings descriptions
---------
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
* Migrate pages to templates once (https://github.com/woocommerce/woocommerce-blocks/pull/9488)
* Migrate content on init, once
* Skip migration if page does not exist
* Put back HTML for header and footer parts
* Fix page redirect due to wrong ID
* fix loading template part
* Removed unnecessary var
* update cart and checkout html templates
---------
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
* Include a notice to redirect user to template editor (https://github.com/woocommerce/woocommerce-blocks/pull/9508)
* Template Placeholder Design for the Order Received Template (https://github.com/woocommerce/woocommerce-blocks/pull/9602)
* Load frontend styles in editor iframe
* Update placeholder to include skeleton and updated icons
* Update classic template configs
* 1px border for .wp-block-woocommerce-classic-template__placeholder-copy
* Show copy on focus
* Sample data
---------
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
* Add simplified header on checkout template (https://github.com/woocommerce/woocommerce-blocks/pull/9607)
* Added simplified header on checkout template
* Moved simplified header to template part
* updated constants.ts
* added template part to checkout.html
* Add missing translation
* frontpage_template_hierarchy no longer needed
* Allow plugin based template parts (https://github.com/woocommerce/woocommerce-blocks/pull/9667)
* Merge branch 'trunk' into add/9288_cart-checkout-order-received_fse_templates
* Synced templates on blockified folder
* Add blockified order-received.html
* removed WooCommerce prefix
* Refactor/rebrand order received template to order confirmation (https://github.com/woocommerce/woocommerce-blocks/pull/9734)
* rebrand order received to order confirmation
* updated descriptions for templates
* updated descriptions for order confirmation placeholder
* Resolve merge conflict
* Resolve merge conflicts
* Resolve more merge conflicts after rebase
* Fix formatting
* Use patterns for localisation (https://github.com/woocommerce/woocommerce-blocks/pull/9883)
* e2e tests for cart and checkout templates (https://github.com/woocommerce/woocommerce-blocks/pull/9939)
* Merge branch 'trunk' into poc/cart_and_checkout_fse_templates
* Merge branch 'trunk' into add/9288_cart-checkout-order-received_fse_templates
* Resolve merge conflicts
* Add e2e for permalink settings
* Test that templates exist
* Add test to check that templates can be edited
* Add tests to confirm templates can be edited
* Ensure cart has contents before running tests on frontend views
* Commend out problem test
* Make sure search has multiple results
* Remove useThrottle - bad rebase
* Revert changes to docs after rebase
* Revert function call for noReviewsPlaceholder
* Bad rebase
* Reverts
* Remove revertTemplate
* Spacing
* Wait for networkidle after navigation
* Always wait for network
* Use button roles in site editor
* More specific button locator
* Update option comparison
* Fix template content
* Disable failing tests
* Disable failing classic template tests
* Use enterEditMode
* More enterEditMode usage
* enterEditMode
* Use test.skip
* More robust selectors
* Alt iframe selector
---------
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
* Skip flakey test
---------
Co-authored-by: Luigi <gigitux@gmail.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>