* Change icon, title and description of the Express Checkout Block
* Fix icon style
* Update icon and add styles
* change icon for express payments in cart
* Add tests in Playwright for Mini-Cart drawer closing
* Make use of waitForSelector instead of waitForTimeout
* Make use of waitForSelector instead of waitForTimeout (II)
* Add the new Social: Follow us in social media pattern and relevant images.
* Update the URLs
* Remove all IDs from the images.
* Make title translatable. Removed hardcoded color for the icons. Update indentation.
* Check if WordPress version is higher than 6.2.2 to make Products block compatible with Gutenberg 16+
* Extract the logic of checking the post template support for grid view toi separate function
* Change the versions comparison and improve description of custom version compare function
* Remove opinionated font styles and sizes from the Large Footer pattern.
* Ensure the year is dinamically changed in the footer.
* Make string translatable
* Update translation to include the WooCommerce brand.
* Register order route
* Check authorization for getting the order
* Add order data to the response
* Add order schema for the endpoint
* Move validation check to order controller
* Add order item schema
* Check if the order is associated with current user
* Fix after rebase
* Add checkout order endpoint
* Add order authorization trait
* Allow to use the order update customer endpoint in dev build only
* Get both customer and guest details
* Remove duplicate function
* Update the cart update customer class doc block
* Remove duplicate order route
* Update documentation for feature flags
* Add checkout trait
* Remove checkout trait
* Update billing address and order
* Only allow checkout pending orders
* Create checout trait
* Use sanitize text field
* Extend from checkout schema
* Update response message
* Allow failed orders to be paid for
* Update authorization error message
* Introduce the new Featured Products: Fresh & Tasty pattern.
* Update lettuce image.
* Update indentation.
* Make all strings translatable.
* Align all prices right
* Ensure text doesnt stack on mobile
* Update mobile display for the prices
* Update mobile display for the product names
* Remove the image id and the text styles
* Remove custom font color from the cover block.
* Update indentation for the Featured Category Triple pattern.
* Update indentation for the third column
* Make all strings translatable.
* replate all paragraph blocks with a wp-block-heading
* Ensure the central text is also white
* replace the buttons with a paragraphs.
* Remove unnecessary styles from wp:column
* Remove more unnecessary styles from wp-block-cover
* Remove the has-text-color class and other unnecessary positioning styles
* Update headings from h4 to h3 and update the paragraph styles.
* Replate theme's has-base-color with has-white-color
* Show alignment toolbar also when the block is in the single product block
* Start using `Single Product` for the `Product Details Product Listing` pattern
* Use counter and stars blocks in the pattern
* Undo button change
* Make the new rating blocks not experimental
* Add Beta to the average rating block
* Add blocks to block types controller
* Add missing page titles to the Cart and Checkout templates
* Adjust headline level
* Add i18n support for Cart and Checkout template titles
* Keep empty line between “wp:group” and “wp:template-part”
* Add empty line between “wp:template-part” and “wp:group”
* Add PHPUnit tests for the ProductCollection block type
This commit introduces PHPUnit tests for the ProductCollection block type. A new test file, `ProductCollection.php`, has been added under the `BlockTypes` directory within the tests. The test file sets up a mock instance of `ProductCollection` and verifies its behavior. Particularly, it tests the merging of on-sale queries, ensuring the results are as expected.
To assist in the testing, a new mock class, `ProductCollectionMock`, has been created under the `Mocks` directory. This class extends the `ProductCollection` block type and provides methods for setting parsed block data and attribute filter query arguments.
These tests should help ensure the correctness and reliability of the `ProductCollection` block type.
* Expand PHPUnit tests for ProductCollection block to cover stock status queries
This commit expands the existing PHPUnit tests for the ProductCollection block type to cover scenarios involving stock status queries. Specifically, a new test method, `test_merging_stock_status_queries`, has been added.
This method tests if the 'woocommerceStockStatus' attribute is correctly merged into the query parameters. It verifies that the stock status is correctly incorporated into the 'meta_query' array as part of the constructed query.
This addition enhances the coverage of our test suite, ensuring that the ProductCollection block behaves as expected in scenarios involving stock status queries.
* Add extensive testing for ProductCollection block's query merging
The following test methods were added:
1. `test_merging_default_stock_queries`: This tests the merging of default stock queries, verifying the absence of meta_query in certain conditions.
2. `test_merging_attribute_queries`: This tests the merging of attribute queries, ensuring the correct taxonomy and terms are used in the merged tax_query.
3. `test_merging_order_by_rating_queries` and `test_merging_order_by_popularity_queries`: These test the merging of order by queries, checking for the right orderby and meta_key in the merged query.
4. `test_product_visibility_query_exist_in_merged_query`: This tests if the product visibility query exists in the merged query.
This additional testing improves the reliability and coverage of our tests, ensuring the correct functionality of the ProductCollection block's query merging process.
* Add unit tests for merged queries in ProductCollection block
- Merging multiple queries
- Merging filter by max price queries
- Merging filter by min price queries
- Merging filter by min and max price queries
- Merging filter by stock status queries
- Merging filter by attribute queries
- Merging multiple filter queries
These tests use PHPUnit assertions to validate the correctness of the merged queries.
* Add tests for REST query modifications in ProductCollection block
This commit adds two new test cases and a helper method to the `ProductCollection` test class.
The helper method, `build_request()`, constructs a simplified `WP_REST_Request` object for testing purposes. This request object simulates a typical request from the ProductCollection block, including potential WooCommerce parameters such as 'woocommerceOnSale', 'woocommerceAttributes', and 'woocommerceStockStatus'.
The first new test, `test_updating_rest_query_without_attributes()`, tests the block's capability to modify a REST query that doesn't include any product attribute filters. It verifies that the correct '_stock_status' and 'product_visibility' parameters are set in the meta and tax queries respectively.
The second test, `test_updating_rest_query_with_attributes()`, does the same as the previous one but with the inclusion of a product attribute filter in the REST request. This test verifies that the block can handle REST queries with attribute filters correctly.
These tests improve coverage on the ProductCollection block's REST query handling, ensuring that it can merge different filter queries correctly.
* Add test for merging taxonomies query in ProductCollection block
This commit introduces a new test, `test_merging_taxonomies_query()`, in the `ProductCollection` test class.
The test simulates a situation where the block has to merge taxonomy queries related to product categories and tags. The parsed block attributes are configured to include 'product_cat' and 'product_tag' taxonomies with certain term IDs.
The test then asserts that the merged query correctly includes these taxonomies with the appropriate term IDs and 'include_children' set to false. This confirms that the block correctly merges taxonomy filters when building the final query.
* Fix failing test
* Try again
* Try again
* Remove test_merging_filter_by_attribute_queries test
This commit removes the `test_merging_filter_by_attribute_queries()` test from the `ProductCollection` test class.
* Add option to manually update Products block to Product Collection
* Disable manual upgrade of Products yet
* Manual update flag doesn't have to be dependant on auto update
* Removed commented out console info logs
* Disable option to upgrade Products block
* Change the way to bold text in Upgrade Notices so it's translatable
* Change the way UpgradeNotice is rendered conditionally
* Register order route
* Get order it
* Add order schema
* Check authorization for getting the order
* Add order data to the response
* Add order schema for the endpoint
* Move validation check to order controller
* Update the error codes
* Add order item schema
* Check if the order is associated with current user
* Update order schema to match cart schema
* Update order item schema to match cart item schema
* Add product item trait
* Update sold individually property
* Allow guests to pay for order
* Update wording for logged out customers
* Allow getting all orders from the endpoint
* Add inline explanation for pay_for_order capability
* Remove unused $user_id and $order variables
* Remove duplicate pay_for_order capability check from validate_order_key
* Update exception wording when missing order id or key, or user mismatch
* Ensure $order_key is not null to avoid fatal error when left blank
* Resolve linting errors in order route class
* Adjust order ID description
* Create an abstract item schema
* Remove unused properties
* Remove unused properties
* Add billing email validation
* Allow to use the order endpoint in dev build only
* Add order status property
* Fix coupon and fee handling
* Update documentation for feature flags
* Update typo in total fees tax
* Update typo in tax lines
* Add missing payment methods to cart response
---------
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* Remove styles from `Newest arrivals` pattern
* Remove id
* Replace row with columns to be able to stack blocks on mobile
* Make string translatable
* Make button string translatable
* Add new Product Average Rating block
* Add new blocks to the feature flag docs
* Translate 'No ratings'
* Fix condition
* Small improvements after review
* Avoid duplication of styles
* Update supports in php class
This commit adds a new `__experimentalExpandOnFocus` attribute to the component within the `HandPickedProductsControl`. The value is set to `true`, enabling automatic expansion of the list when the user focuses on the product selection field.
This change aims to improve the user experience by making it easier for the user to see all available options when they focus on the selection list.
* Create Mini-Cart template part area
* Update Mini-Cart template part name to exclude it
* Update src/BlockTemplatesController.php
Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com>
* Update src/BlockTemplatesController.php
Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com>
* Keep both variations of the template part name when excluding them
* Revert "Keep both variations of the template part name when excluding them"
This reverts commit c3f293511536d1ebbac0f50caaf74cded28d0025.
---------
Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com>
* Add cors check
* refactor logic
* Refactor add_cors_headers to allow null and allowed hosts
* Move remove_filter inline
* Revert unrelated code style changes
* Add explainer to docblock
* Remove access for null origin
* Move CORS handling to auth class so it applies API wide
* Move only Authentication to priority 11
* Handle preflight requests so cart-tokens work
---------
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* Mini Cart: Replace the deprecated print_inline_script() with supported get_inline_script_data(). Fixeswoocommerce/woocommerce-blocks#10004
* Mini Cart: Add version check for the new get_inline_script_data() function
* Update the variable names and fix a typo
* Mini Cart: Add regex to check for the WP version
* Abstract the WP version comparison regex to a separate Utils class
* Remove queries that fetch all products for manipulating the results returned by the Store API for certain use-cases.
* Remove the code that's supposed to read product ids for filter context and logic around that in useCollectionData
* Fix incorrect merge
---------
Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com>
* Remove queries that fetch all products for manipulating the results returned by the Store API for certain use-cases.
* Keep support for Product Collection block
* Rating start block improvements
Fix classes, register in single product, remove unused code
* Allow to use block on product & product collection
* Fix star missalignment
* Restrict the block to be insertable only in single product
Key updates:
1. Additional CSS class to Inherit Query Control: A CSS class named `wc-block-product-collection__inherit-query-control` has been added to the ToggleControl component. This provides a precise target for E2E tests and potential custom styles.
2. E2E tests for 'Inherit query from template' control: Numerous scenarios have been covered to ensure the control's correct behavior. These scenarios include verifying visibility under different circumstances and checking its functionality in a Product Catalog template.
3. E2E test code enhancements: The E2E test code now exports the `SELECTORS` object to assist in locating different elements during the tests. This includes the new 'Inherit query from template' control. The `setShowOnlyProductsOnSale()` function has been refactored to improve readability and provide more granular control over its operations.
4. Test scenario for 'Show only products on sale': The existing E2E test for this functionality has been extended to check that it retains its state when the 'Inherit query from template' control is toggled.
These changes increase the robustness of our E2E tests, providing better coverage for the 'Inherit query from template' control in the Product Collection block.
* allow for handling classic theme template part support
Note this logic is currently not right - just a quick implementation for testing POC
* Account for classic theme support of template parts
* Update supports_block_templates signature so it accepts the template type instead of a bool
* Simplify logic in supports_block_templates
* Test
* Fix supports_block_templates check to test correct template type
---------
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* Foundation of the Products block replacement with Product Collection
* Provide logic to replace Products with Product Collection
* Make sure the blocks can be replaced
* Add types and refactor replacement a bit
* Fix the query attributes transform
* Add upgrade Notice to the Product Collection block
* Force upgrade notice to be displayed at the top of the Inspector Controls
* Externalise migration code so it can be reused in both ways
* Add util to get block IDs byt its name
* Add a way to revert the Product Collection blocks to Products
* Move the subscription to another place where it's triggered only once
* Add default values
* Remove attributes from Products block if they're not used to avoid incorrect query
* WIP logic of unseen/seen/reverted notice
* Change the state reading
* Revert changes regarding notice displaying logic
* Change the logc of firing replacement and bail early if there's no core/query blocks
* Add todos
* Implement inner blocks migration
* Implement the revert transformation of inner blocks
* Refactor types
* Add layout transformation from Products to Product Collection
* Add layout migration from Product Collection to Products
* Disable migration by default
* Simplify some parts of code
* Remove additional keyword from Product Collection to move it to another PR
* Adjust the logic to introduce the first step: conversion from Products to Product Collection
* Disable automatic migration
* 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