* Add cartCheckout project
* Add navigation utils
* Add global block inserter utils to EditorUtils class
* Add initial Cart block tests
* Add slug to block data type
* Get block editor selector when navigating in editor
* add test for inner block filtering
* Update navigation util to use block name instead of title
* Add view switcher test
* Update block name/title
* Run only cart/checkout tests in cartCheckout project
* Remove old comment
* Update selector to use locator instead
* Revert selector type change
* Fix TS issues
* Remove unnecessary admin state
* Update tests to use editorUtils and fix TS issue with selector
* Replace string concatenation with template
* Rename cart test to contain block_theme suffix
* Change page to editor.page and use canvas where necessary
* Rename directory to cart-checkout
* Wait for editor response before continuing
* Remove cartcheckout playwright project
* Remove typecast and switch to .toNotBeHidden
* Remove double comment
* Force click the empty cart button
* Wait for empty cart button for longer
* Isolate test to run in CI
* Dispatch click event instead of simulating click
* Remove timeouts
* Revert "Isolate test to run in CI"
This reverts commit 28af5a50700476639d0a4f12fca9800a4a5aed91.
* Empty commit for release pull request
* classicBlock: add defensive type handling (https://github.com/woocommerce/woocommerce-blocks/pull/10475)
* Update check for active cart template and migration routine (https://github.com/woocommerce/woocommerce-blocks/pull/10462)
* Update cart/checkout endpoints
* Remove updating option on every page load
* Check placeholder page vs current page
* Check placeholder page vs current page
* Switch from Rest to PHP for migrating templates
* Existing page used for migration must contain post-content to be suitable
---------
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* Version bumping & documentation for release 10.8.1
The primary changes include:
1. **Version Bumping**: Updated the version from 10.8.0 to 10.8.1 in several files including `composer.json`, `package-lock.json`, `package.json`, `readme.txt`, `src/Package.php`, and `woocommerce-gutenberg-products-block.php`.
2. **Documentation**:
- Added a new testing notes file for release 10.8.1 (`docs/internal-developers/testing/releases/1081.md`). This file provides testing procedures for two bug fixes introduced in this release.
3. **Changelog**: Updated the `readme.txt` to include the bug fixes in the 10.8.1 changelog section.
This release focuses on enhancing stability and user experience by addressing critical bugs.
* Update readme file
* Add zip file for testing
---------
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
* Propose changes for the Release Testing process.
* Update spacing
* Update wording for the experimental flag check.
* Reintroduce the 'Do not include in the Testing Notes' check.
* Update the release and patch release instructions.
* remove whitespace
* Update cart/checkout endpoints
* Remove updating option on every page load
* Check placeholder page vs current page
* Check placeholder page vs current page
* Switch from Rest to PHP for migrating templates
* Existing page used for migration must contain post-content to be suitable
---------
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* WIP Product Gallery: Add the Thumbnails block
* Product Gallery Thumbnails: Add block settings
* Add template for the Product Gallery block
* Add template for the Product Gallery block. Add the rest of the files.
* Product Gallery Thumbnails: Add context settings sharing between the Product Gallery and Thumbnails block.
* Product Gallery Thumbnails: Add UI functionality and frontend functionality. Add settings for the Thumbnails in both places - Product Gallery and the Thumbnails block.
* Product Gallery Thumbnails: Move the static template ouside of the component
* Make sure the context is set before accesing the array values
* Product Gallery Thumbnails: Move the setGroupAttributes() function outside of the component
* Product Gallery Thumbnails: Fix TS errors
* Product Gallery Thumbnails: Update the Features Flags and Experimental Interfaces doc
* Product Gallery Thumbnails: Fix TS error
* Product Gallery Thumbnails: Remove unused stylesheet
* Product Gallery Thumbnails: Fix TS errors
* Product Gallery Thumbnails: Remove unused context and fix the thumbnails bottom position styling on the frontend.
* Product Gallery Thumbnails: Allow the user to move the horizontal thumbnails above the large image and don't overwrite that automatically
* E2E: Add tests for the Product Gallery Thumbnails block
* Product Gallery Thumbnails: Add code comments and remove the incorrect conditional check when moving thumbnails up and down
* Product Gallery Thumbnails: Add failure handling
* Product Gallery Thumbnails: Fix the eslint dependency error
* Product Gallery Thumbnails: Add inner blocks to the sideEffects array
* Product Gallery Thumbnails: Refactor Product Gallery edit code and move the logic to a utils file
* Product Gallery Thumbnails: Update the utils file
* Product Gallery Thumbnails: Update the utils file. Fix comment indentation
* Product Gallery Thumbnails: Fix failing tests
* Revert unrelated package.json changes
* Product Gallery Thumbnails: Further package.json reverts
* Product Gallery Thumbnails: Rename the test screenshots
* Product Gallery Thumbnails: Fix undefined variable html when only 1 product image is set
* Product Gallery: Rename clientId to productGalleryClientId
* Product Gallery Thumbnails: Combine the useEffect code having the same dependencies
* Product Gallery Thumbnails: Combine all useEffect code together
* Product Gallery Thumbnails: Add a ThumbnailsPosition enum
* Product Gallery Thumbnails: Update the thumbnailsPosition to an enum
* Product Gallery Thumbnails: Fix TS errors
* Product Gallery Thumbnails: Fix TS errors
* Product Gallery Thumbnails: Add missing dependency
* Product Gallery Thumbnails: Uppercase the enum and fix the thumbnails position bug when initially adding the Product Gallery block
* Product Gallery Thumbnails: Fix E2E tests
* Product Gallery Thumbnails: Remove unused function from frontend utils
* Product Gallery Thumbnails: Remove unused screenshots and config amendment
* Product Gallery Thumbnails: Add check for the order of block on the frontend
* Product Gallery: Add crop, zoom and full-screen settings
* Product Gallery Thumbnails: Replace ts-ignore with ts-expect-error
* Product Gallery Thumbnails: Replace ts-ignore with ts-expect-error
* Product Gallery Thumbnails: Revert back to ts-ignore
* Revert "Product Gallery: Add crop, zoom and full-screen settings"
This reverts commit 840654197619e2611029b81990493387ae0b543d.
* Product Gallery: Add crop, zoom and full-screen settings
* Product Gallery: Remove the redundant React Fragment
* Product Gallery E2E: Simplify and combine the tests
* Enable Compatibility Layer for Product Collection
* Add another condition to recognise shop item
* Enable multiple blocks to be assigned to single hook in Compatibility Layer
* Move core/null block name assignment before the hooks assignment which is based on the block name
* Make array operations safer
* Unify hooks interface between templates
* Fix typo
* Update comment describing set_hook_data to reflect new interface
* Add function to generate a hash for script data cache busting
* Store the script data hash if cache is not disabled
* Change transient key if accessed via https
* Update hardcoded transient key to use class variable
* Add generated hash to transient script data value
* Add check to ensure JSON is valid before proceeding
* Move JSON error check to other conditional
* Change formatting on long if
* Ensure hash is checked to invalidate cache
* Update router to hydrate only interactive regions
* Rename link directive to navigation-link
* Add navigation directives to Query and Pagination blocks
* Enable the Interactivity API by default
* Remove client-side navigation meta tag
* Cache initial regions
* Move data-wc-interactive from query to query-pagination
* Add woo prefix to navigation id
* Add keys and move wc-interactive back to the query block
* Reuse root fragments for each interactive region
* Fix navigation-id retrieval
* WIP Product Gallery: Add the Thumbnails block
* Product Gallery Thumbnails: Add block settings
* Add template for the Product Gallery block
* Add template for the Product Gallery block. Add the rest of the files.
* Product Gallery Thumbnails: Add context settings sharing between the Product Gallery and Thumbnails block.
* Product Gallery Thumbnails: Add UI functionality and frontend functionality. Add settings for the Thumbnails in both places - Product Gallery and the Thumbnails block.
* Product Gallery Thumbnails: Move the static template ouside of the component
* Make sure the context is set before accesing the array values
* Product Gallery Thumbnails: Move the setGroupAttributes() function outside of the component
* Product Gallery Thumbnails: Fix TS errors
* Product Gallery Thumbnails: Update the Features Flags and Experimental Interfaces doc
* Product Gallery Thumbnails: Fix TS error
* Product Gallery Thumbnails: Remove unused stylesheet
* Product Gallery Thumbnails: Fix TS errors
* Product Gallery Thumbnails: Remove unused context and fix the thumbnails bottom position styling on the frontend.
* Product Gallery Thumbnails: Allow the user to move the horizontal thumbnails above the large image and don't overwrite that automatically
* Product Gallery Thumbnails: Add code comments and remove the incorrect conditional check when moving thumbnails up and down
* Product Gallery Thumbnails: Fix the eslint dependency error
* Product Gallery Thumbnails: Refactor Product Gallery edit code and move the logic to a utils file
* Product Gallery Thumbnails: Update the utils file
* Product Gallery Thumbnails: Update the utils file. Fix comment indentation
* Product Gallery Thumbnails: Fix undefined variable html when only 1 product image is set
* Product Gallery: Rename clientId to productGalleryClientId
* Product Gallery Thumbnails: Combine the useEffect code having the same dependencies
* Product Gallery Thumbnails: Combine all useEffect code together
* Product Gallery Thumbnails: Add a ThumbnailsPosition enum
* Product Gallery Thumbnails: Update the thumbnailsPosition to an enum
* Product Gallery Thumbnails: Fix TS errors
* Product Gallery Thumbnails: Fix TS errors
* Product Gallery Thumbnails: Add missing dependency
* Product Gallery Thumbnails: Uppercase the enum and fix the thumbnails position bug when initially adding the Product Gallery block
* Product Gallery: Add crop, zoom and full-screen settings
* Product Gallery Thumbnails: Replace ts-ignore with ts-expect-error
* Product Gallery Thumbnails: Replace ts-ignore with ts-expect-error
* Product Gallery Thumbnails: Revert back to ts-ignore
* Revert "Product Gallery: Add crop, zoom and full-screen settings"
This reverts commit 840654197619e2611029b81990493387ae0b543d.
* Product Gallery: Add crop, zoom and full-screen settings
* Product Gallery: Remove the redundant React Fragment
* WIP Product Gallery: Add the Thumbnails block
* Product Gallery Thumbnails: Add block settings
* Add template for the Product Gallery block
* Add template for the Product Gallery block. Add the rest of the files.
* Product Gallery Thumbnails: Add context settings sharing between the Product Gallery and Thumbnails block.
* Product Gallery Thumbnails: Add UI functionality and frontend functionality. Add settings for the Thumbnails in both places - Product Gallery and the Thumbnails block.
* Product Gallery Thumbnails: Move the static template ouside of the component
* Make sure the context is set before accesing the array values
* Product Gallery Thumbnails: Move the setGroupAttributes() function outside of the component
* Product Gallery Thumbnails: Fix TS errors
* Product Gallery Thumbnails: Update the Features Flags and Experimental Interfaces doc
* Product Gallery Thumbnails: Fix TS error
* Product Gallery Thumbnails: Remove unused stylesheet
* Product Gallery Thumbnails: Fix TS errors
* Product Gallery Thumbnails: Remove unused context and fix the thumbnails bottom position styling on the frontend.
* Product Gallery Thumbnails: Allow the user to move the horizontal thumbnails above the large image and don't overwrite that automatically
* Product Gallery Thumbnails: Add code comments and remove the incorrect conditional check when moving thumbnails up and down
* Product Gallery Thumbnails: Fix the eslint dependency error
* Product Gallery Thumbnails: Refactor Product Gallery edit code and move the logic to a utils file
* Product Gallery Thumbnails: Update the utils file
* Product Gallery Thumbnails: Update the utils file. Fix comment indentation
* Product Gallery Thumbnails: Fix undefined variable html when only 1 product image is set
* Product Gallery: Rename clientId to productGalleryClientId
* Product Gallery Thumbnails: Combine the useEffect code having the same dependencies
* Product Gallery Thumbnails: Combine all useEffect code together
* Product Gallery Thumbnails: Add a ThumbnailsPosition enum
* Product Gallery Thumbnails: Update the thumbnailsPosition to an enum
* Product Gallery Thumbnails: Fix TS errors
* Product Gallery Thumbnails: Fix TS errors
* Product Gallery Thumbnails: Add missing dependency
* Product Gallery Thumbnails: Uppercase the enum and fix the thumbnails position bug when initially adding the Product Gallery block
* Product Gallery: Add crop, zoom and full-screen settings
* Product Gallery Thumbnails: Replace ts-ignore with ts-expect-error
* Product Gallery Thumbnails: Replace ts-ignore with ts-expect-error
* Product Gallery Thumbnails: Revert back to ts-ignore
* Revert "Product Gallery: Add crop, zoom and full-screen settings"
This reverts commit 840654197619e2611029b81990493387ae0b543d.
* WIP Product Gallery: Add the Thumbnails block
* Product Gallery Thumbnails: Add block settings
* Add template for the Product Gallery block
* Add template for the Product Gallery block. Add the rest of the files.
* Product Gallery Thumbnails: Add context settings sharing between the Product Gallery and Thumbnails block.
* Product Gallery Thumbnails: Add UI functionality and frontend functionality. Add settings for the Thumbnails in both places - Product Gallery and the Thumbnails block.
* Product Gallery Thumbnails: Move the static template ouside of the component
* Make sure the context is set before accesing the array values
* Product Gallery Thumbnails: Move the setGroupAttributes() function outside of the component
* Product Gallery Thumbnails: Fix TS errors
* Product Gallery Thumbnails: Update the Features Flags and Experimental Interfaces doc
* Product Gallery Thumbnails: Fix TS error
* Product Gallery Thumbnails: Remove unused stylesheet
* Product Gallery Thumbnails: Fix TS errors
* Product Gallery Thumbnails: Remove unused context and fix the thumbnails bottom position styling on the frontend.
* Product Gallery Thumbnails: Allow the user to move the horizontal thumbnails above the large image and don't overwrite that automatically
* Product Gallery Thumbnails: Add code comments and remove the incorrect conditional check when moving thumbnails up and down
* Product Gallery Thumbnails: Fix the eslint dependency error
* Product Gallery Thumbnails: Refactor Product Gallery edit code and move the logic to a utils file
* Product Gallery Thumbnails: Update the utils file
* Product Gallery Thumbnails: Update the utils file. Fix comment indentation
* Product Gallery Thumbnails: Fix undefined variable html when only 1 product image is set
* Product Gallery: Rename clientId to productGalleryClientId
* Product Gallery Thumbnails: Combine the useEffect code having the same dependencies
* Product Gallery Thumbnails: Combine all useEffect code together
* Product Gallery Thumbnails: Add a ThumbnailsPosition enum
* Product Gallery Thumbnails: Update the thumbnailsPosition to an enum
* Product Gallery Thumbnails: Fix TS errors
* Product Gallery Thumbnails: Fix TS errors
* Product Gallery Thumbnails: Add missing dependency
* Product Gallery Thumbnails: Uppercase the enum and fix the thumbnails position bug when initially adding the Product Gallery block
* Product Gallery: Add crop, zoom and full-screen settings
* Product Gallery Thumbnails: Replace ts-ignore with ts-expect-error
* Product Gallery Thumbnails: Replace ts-ignore with ts-expect-error
* Product Gallery Thumbnails: Revert back to ts-ignore
* Add new GH Action for ensuring the correct labels are added to PRs.
* Update Pull Request Template instructions for labels.
* Update validation.
* Update the validation for the type.
This commit updates the minimum WordPress and WooCommerce requirements in the `woocommerce-gutenberg-products-block.php` file. It sets the minimum WordPress version to 6.2 and the minimum WooCommerce version to 7.8. Additionally, it increases the WooCommerce version tested up to 7.9.
This commit updates the version of WooCommerce Blocks from 10.8.0-dev to 10.8.0 in the `composer.json`, `package-lock.json`, `package.json`, `readme.txt`, `src/Package.php`, and `woocommerce-gutenberg-products-block.php` files. This signifies the move from the development version to the stable release.
This commit updates the `readme.txt` file to document the changes made in version 10.8.0. This version includes numerous enhancements, bug fixes, and other changes.
Enhancements include updating various patterns to become wireframed, removing opinionated styles from multiple patterns, and introducing the ColorPanel component in the Mini-Cart block for custom color controls. Bug fixes address issues in the Classic Template block, product query logic, and PHP warnings among others. The "Various" section introduces new patterns and endpoints.
Each change is linked to its corresponding pull request for detailed tracking and discussion.
* 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.
* Reintroduce test for merging attribute filter queries
This commit reintroduces the `test_merging_filter_by_attribute_queries()` test in the `ProductCollection` test class.
The test checks the correct merging of queries when filtering by color and size attributes. It sets various query variables and asserts the correct structure and content of the merged query.
This could be because the previous removal of this test was a mistake, or because changes in the code have once again made this test relevant.
* fix: passing correct block instance to build_frontend_query method
---------
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
* Make sure the revert button is registered and enqueued for usage exclusively in the site editor.
* Register and enqueue the styles for the revert button.
* Rename the files.
* Revert "Rename the file renames."
This reverts commit c0330ce70fec20bea1f957eddcf458881e16242c.
* Add plugin-proposal-optional-chaining to the WebPack plugins config.
* Rename the files.
* Remove unnecessary dependencies as those are already provided via : more specifically, get_script_data.
* Address CR.
* Featured Products 5-Item Grid pattern: Ensure a placeholder image is displayed when the product doesn't have any
* Ensure the wp-block-group is aligned wide.
* Update text styles
* Make texts translatable.
* Update the Featured Products 5-Item Grid pattern
* 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
* 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>
* Change type of payment requirements to string[]
* Add CanMakePaymentArgumentCart type and update CanMakePaymentArgument
* Add getCanMakePaymentArg function to get the arg, allows reusability
* Check saved methods gateway's to see if they can make payment
* Make canMakePaymentArg a dependency of the useMemo
* Remove await from sync function call
* Update variable names to better reflect what they store
* Add tests to ensure saved payment methods don't show if canPay is false
* Rename save-payment-method-options to tsx
* Update saved payment method options to TS
* Fix TS error in saved-payment-method-options test
* 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>
* Update Interactivity API JS files
* Disable TS checks in the Interactivity API for now
* Add new SSR files
* Replace wp_ prefixes with wc_ ones
* Replace wp- prefix with wc-
* Replace guternberg_ prefix with woocommerce_
* Remove file comments from Gutenberg
* Rename files with `wp` prefix
* Fix code to load Interactivity API php files
* Remove TODO comments
* Replace @wordpress with @woocommerce
* Update Webpack configuration
* Fix directive prefix
* Remove interactivity folder from tsconfig exclude
* Add client-side navigation meta tag code
* Remove unneeded blocks.php file
* Fix store tag id
* Register Interactivity API runtime script
* Fix Interactivity API runtime registering
* Remove all files related to directive processing in PHP
* Move json_encode to Store's render method
* fix Products block test
* test now
* fix test
* improve E2E test
* restore pw configuration
* change order
* remove timeout
---------
Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
* Empty commit for release pull request
* Add back filter blocks frontend scripts (https://github.com/woocommerce/woocommerce-blocks/pull/9954)
* Update changelog and bump version to 10.4.4
* Add testing notes for 10.4.4 release
* Update testing notes for release 10.4.4
* Replace Automated tests badge with Unit and E2E tests badge
* Wait for cart to be removed when emptied (https://github.com/woocommerce/woocommerce-blocks/pull/9829)
* Temporarily skip PHP Unit Tests for PHP 8.1 and 8.2 (https://github.com/woocommerce/woocommerce-blocks/pull/9859)
* Allow failure of the PHP Unit Tests
* Limit the PHP versions to 7.4 and 8.0 to run unit tests
* Don't allow failing fast
* Add a comment explaining the skipped part
* Cancel jobs later
* Cancel all the steps in workflow based on the same condition
---------
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
Co-authored-by: Karol Manijak <karol.manijak@automattic.com>
* Ensure the Product Summary and Product Title blocks are always rendered independent of their position in the editor.
* Update docblock with note informing where the global post variable is restored for the post title and excerpt blocks.
* Default show product counts to false for filter by attributes block
* Default show product counts to false for filter by stock block
* Default show product counts to false for filter by rating block
* Refactor deprecation
* Refactor deprecation
* Refactor deprecation
* Allow customer account block to center align
* Convert to using Flexbox
* Use mixins to DRY
---------
Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
* 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
* Empty commit for release pull request
* Update Hero Product 3-split pattern image
* Update Banner Pattern To Replace Unsplash Image (https://github.com/woocommerce/woocommerce-blocks/pull/9760)
* Update Banner to replace Unsplash image.
Replaces the Unsplash image with a CCO licensed image from Pxhere. Also
updates the CTA button to link to the Shop page, by default.
* Remove extra padding from top of test column.
Vertical alignment was off on the text column due to 60px of top
padding. This aligns everythign, as expected.
* Update Chessboard pattern images (https://github.com/woocommerce/woocommerce-blocks/pull/9761)
* Updathe the Hero Product Split (https://github.com/woocommerce/woocommerce-blocks/pull/9762)
* Remove unused pattern image (https://github.com/woocommerce/woocommerce-blocks/pull/9763)
* Update Images for the Product Details Patterns (https://github.com/woocommerce/woocommerce-blocks/pull/9764)
* Update image for the Product Hero pattern.
Replace the Unsplash image with a CCO licensed image from Pxhere.
* Update images for Prod List Gallery Desc pattern
Replace the Unsplash image with a CCO licensed image from Pxhere for the
Product Listing with Gallery and Description pattern.
* Remove unneeded Unsplash images.
* Update copy for Prod Listing Gallery Desc pattern.
* Optimize new image exports.
* Update image for the Product Listing pattern.
Replace the Unsplash image with a CCO licensed image from Pxhere.
* Update images for Product Details pattern.
Replace the Unsplash images with CCO licensed images from Pxhere.
* Remove unneeded Unsplash image.
* Use Relative URLs for Images in the Product Listing Pattern
This commit replaces hardcoded URLs with dynamic ones for image placeholders in the `product-listing-with-gallery-and-description.php` pattern file.
- The `plugins_url()` function is now used to generate URLs, which correctly points to the images folder within the WooCommerce Blocks plugin directory. This approach provides better flexibility and portability since it doesn't rely on a specific domain or path. The `esc_url()` function is used to ensure the URL is safe to use in the HTML context.
- The change is made for a total of four images in the pattern.
---------
Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
* Update/patterns featured category product collection (https://github.com/woocommerce/woocommerce-blocks/pull/9765)
* Update image for featured category focus pattern
* Update image for featured category cover image pattern
* Update images for featured category triple pattern
* Change to wide width
* Update links to buttons
* Fix typo in hex color value.
There was an extra `f` in the hex color value, causing the text to
unexpectedly render black.
---------
Co-authored-by: Daniel W. Robert <danielwrobert@gmail.com>
* Update/collection pattern images (https://github.com/woocommerce/woocommerce-blocks/pull/9766)
* Update featured collections images
* Add shop link to shop by price pattern
* Update hero product pattern title (https://github.com/woocommerce/woocommerce-blocks/pull/9769)
* Remove unused pattern image (https://github.com/woocommerce/woocommerce-blocks/pull/9770)
* Add 10.4.2 changelog in readme.txt
* Update version number to 10.4.2
* Add testing instructions for 10.4.2
* Add 9769 PR testing steps
* WooCommerce Classic Template block: Fix error on clearing customizations on Woo Templates (https://github.com/woocommerce/woocommerce-blocks/pull/9759)
* Fix Classic Template block error on clearing customizations on template
* Add link to issue in JS Doc
* Change the way of debug check of tests-mysql container (https://github.com/woocommerce/woocommerce-blocks/pull/9794)
* Add alt text to images used in patterns describing their purpose (https://github.com/woocommerce/woocommerce-blocks/pull/9788)
* Add alt text to images used in patterns describing their purpose
* Replace 1/3 notation with 1 out of 3, so it's better handled byt screen readers
* Update testing instructions to include 9759 PR
* Update zip to include 9759 PR
* Remove 9759 PR from testing instructions
* Mini Cart Block: show the total price, including tax, according to the option (https://github.com/woocommerce/woocommerce-blocks/pull/9878)
* Mini Cart Block: show the total price, including tax, according to the option
* Fix tests in PR 9878 (https://github.com/woocommerce/woocommerce-blocks/pull/9880)
* add unit test
---------
Co-authored-by: Karol Manijak <karol.manijak@automattic.com>
* Mini-Cart: don't include shipping price (https://github.com/woocommerce/woocommerce-blocks/pull/9914)
* Products Block: fix grid view with Gutenberg 16 (https://github.com/woocommerce/woocommerce-blocks/pull/9916)
* Revert "fix products block layout on gutenberg 16 (https://github.com/woocommerce/woocommerce-blocks/pull/9886)"
This reverts commit 53665a5bde.
* add post_template_has_support_for_grid_view setting
* add testing instructions
* bump version
* update zip link
* Empty commit for release pull request
* update link
---------
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Alba Rincón <alba.rincon@automattic.com>
Co-authored-by: Daniel W. Robert <danielwrobert@users.noreply.github.com>
Co-authored-by: Alba Rincón <albarin@users.noreply.github.com>
Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
Co-authored-by: Roy Ho <roykho77@gmail.com>
Co-authored-by: Daniel W. Robert <danielwrobert@gmail.com>
Co-authored-by: Tarun Vijwani <tarun.vijwani@automattic.com>
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
Co-authored-by: Karol Manijak <karol.manijak@automattic.com>
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* 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.
* 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
* Mini Cart Block: show the total price, including tax, according to the option
* Fix tests in PR 9878 (https://github.com/woocommerce/woocommerce-blocks/pull/9880)
* add unit test
---------
Co-authored-by: Karol Manijak <karol.manijak@automattic.com>
* Mini Cart Block: show the total price, including tax, according to the option
* Fix tests in PR 9878 (https://github.com/woocommerce/woocommerce-blocks/pull/9880)
* add unit test
---------
Co-authored-by: Karol Manijak <karol.manijak@automattic.com>
* Mini Cart: 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>
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.
* 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
* 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
* 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>
* Mini Cart: Add an icon setting with 3 alternative icon options. Closeswoocommerce/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
* 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 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 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.
* 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
* 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.
* 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
* 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
* 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
* 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
* 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>
* 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
* 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
* 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.
* 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>
* 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
* 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
* 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>
* 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
* 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>
* 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>