* Add with-product-variations.tsx
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Add types for ProductVariationItem
* Fix ESLint errors
* Remove JS file
* Replace Product with ProductResponseItem interface
Initially, a Product interface was created to add the required types; however,
it was pointed out that the @woocommerce/types alias already provided an interface
for products (the ProductResponseItem interface).
* Remove returning types definition
---------
Co-authored-by: github-actions <github-actions@github.com>
* Update collections.md
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
---------
Co-authored-by: github-actions <github-actions@github.com>
* Refactor No Reviews Placeholder component from JavaScript to TypeScript
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Fix file import
---------
Co-authored-by: github-actions <github-actions@github.com>
* Convert Reviews Editor code to TypeScript
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
---------
Co-authored-by: github-actions <github-actions@github.com>
* add imageSizing attribute to the product catalog template
* add attribute for the product search results template
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
---------
Co-authored-by: github-actions <github-actions@github.com>
* Open templates from list instead of loading the URL in block templates e2e tests
* Typo
* Clean up
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Make sure correct template is loaded
* Create a TemplateType type to avoid having to define it in several places
---------
Co-authored-by: github-actions <github-actions@github.com>
* Refactor store usage
* Prepare function resolving inherit property for additional check
* Add logic to disable sync with query if there's already one Product Collection on archive that does that
* Add changelog
* Cover the post editor case
* Add E2E test for that and small refactor in tests
* Remove duplicated import
* Fix lint problems
* Fix typo in test description
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
* Replace confusin abbreviation with other description
* Update the logic to be more robust and covering also the case where Product Collection blocks are nested
* Add issue reference to the comment
* Add eslint disable before ts-ignore
---------
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
* Add animation for client-side pagination
This includes:
- Addition of animation state management in the frontend file to control the visual transition between pagination states.
- Introduction of new SCSS rules for the start and finish animations, ensuring a seamless and visually appealing pagination experience.
- Modification of the PHP logic to inject necessary HTML for the animation to be applied.
These updates aim to provide a more engaging and responsive interface for users navigating through product collection.
* Enhance accessibility for product collection navigation
This commit introduces several improvements to enhance accessibility and user experience. Specifically, it adds new context properties to manage accessibility messages during the navigation process, including messages for loading and when a page has loaded. These changes ensure that screen reader users receive appropriate feedback during navigation.
Changes made:
- Added `accessibilityMessage`, `accessibilityLoadingMessage`, and `accessibilityLoadedMessage` properties to the `ProductCollectionStoreContext`. These properties store messages to be announced by screen readers during different stages of page navigation.
- Implemented logic in the product collection store to update the `accessibilityMessage` during the start of navigation (showing a loading message) and upon completion (showing a loaded message).
- Utilized a technique to ensure that consecutive identical messages are still announced by screen readers, by appending a no-break space to the message if it is the same as the previous one. This follows a pattern similar to the `@wordpress/a11y` package.
- In `ProductCollection.php`, enhanced the block's HTML output to include these new accessibility messages and integrated them with the existing interactive data attributes. This ensures that the front-end components are fully prepared to handle these accessibility enhancements.
- Added a new `div` with `class="screen-reader-text"` and `aria-live="polite"` attributes, which dynamically displays the accessibility message based on the navigation state. This div complements the visual pagination animation with an accessibility-focused mechanism for announcing the page load states to screen reader users.
By addressing accessibility considerations with these enhancements, we're making Product Collection navigation more inclusive and user-friendly for all users.
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
---------
Co-authored-by: github-actions <github-actions@github.com>
* Add spacing in Checkout block page
* Add spacing in Order summary block
* Update responsive styles for order summary panel
* Update styles for cart and cart line items table
* Update styles for order summary and cross-sells products
* Remove unnecessary CSS styles from cart line items table and cart block
* Remove unused CSS class from cart line items table
* Fix linting errors
* Add changelog
* Fix changelog lint
* Update quantity selector style
* Increase the line-height of the set description and remove margin top from email field
* Add margin-top to order summary image and express payment margin adjustment
* Update styles for cart and checkout components
* Fix linting error
* Fix margin units in cart-cross-sells-products
* Replace em with px
* Add margin-top to payment method container
* Update styles for Cart block for mobile screen
* Update padding in cart style.scss
* Fix removal of express payment method from state
- Correct the logic for removing an express payment method from the availableExpressPaymentMethods state object.
- Previously, the deletion targeted the incorrect object, leading to incorrect change in state. Now, the correct entry is removed using destructuring and rest parameters, ensuring the express payment method is properly deleted.
* Revert "Fix removal of express payment method from state"
This reverts commit 8e24553794.
* Fix typo error in the reducer
* Add unit to make sure correct express payment method is removed
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Remove payment method descriptions from express and fix changelog
---------
Co-authored-by: github-actions <github-actions@github.com>
* Clear billing address when useShippingAsBilling checkbox is unchecked
* Add billing address sync with server
* Add useRef hook to store previous billing address and update sync functions
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Revert "Add useRef hook to store previous billing address and update sync functions"
This reverts commit 7bc3312ab7.
* Added condition to clear address only for guest users
* Add E2E test to check billing address form is empty for Guest shopper
* Fix typo
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Updated docs-manifest.json
* Revert "Updated docs-manifest.json"
This reverts commit 20d578a9d6.
* Include company field in the E2E test
* Replace beforeAll with beforeEach
* Skip country reset to keep consistency with Shortcode Checkout
* Remove sync billing address on server
* Update E2E test to include the shipping address check
* Remove unsed imports
* Clear address fields except country and state
* Optimize the billing and shipping address check with switch statement
---------
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
* Add animation for client-side pagination
This includes:
- Addition of animation state management in the frontend file to control the visual transition between pagination states.
- Introduction of new SCSS rules for the start and finish animations, ensuring a seamless and visually appealing pagination experience.
- Modification of the PHP logic to inject necessary HTML for the animation to be applied.
These updates aim to provide a more engaging and responsive interface for users navigating through product collection.
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Allow user clicks under product collection's loading animation
This commit enhances the user experience of the loading animation for the product collection block. Changes include:
- Specifying `transform-origin: 0% 0%;` directly within the block's initial style to indicate the animation should start from the left
- Adding `pointer-events: none;` to allow user interactions with elements underneath the loading animation, thus improving usability by not blocking clicks.
Additionally, redundant `transform-origin` properties were removed from the `@keyframes` declaration to clean up the code and avoid unnecessary repetition. This simplification contributes to both the maintainability and readability of the stylesheet.
* Fix linting errors in SCSS file
---------
Co-authored-by: github-actions <github-actions@github.com>
* Add sharding to Blocks e2e tests
* Changelog
* Push a change to Blocks README to trigger tests
* Fix syntax
* Fixed again
* Try again
* Trying to get the shard number
* Shard names
* fix E2E test
* complete all the jobs
---------
Co-authored-by: Jon Lane <jon.lane@automattic.com>
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
* Fix Gutenberg links in the docs pointing to the wrong branch
* Add changefile(s) from automation for the following project(s): @woocommerce/notices, @woocommerce/eslint-plugin, @woocommerce/dependency-extraction-webpack-plugin, @woocommerce/components, woocommerce-blocks, woocommerce-beta-tester, woo-ai
* Fix markdown lint errors
* Fix wrong link in the docs
---------
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
Co-authored-by: github-actions <github-actions@github.com>
* Early implementation of getting the Product Collection location/context
* Solve the problem of async fetch in the hook
* Improve typing
* Import core data store instead of hardcoding store name
* Recognise Product Category and Product Tag
* Remove attr property from archive location data
* Unify states naming
* Add TODO entry
* Display the info about the location of Product Collection
* Improve the typing
* Recognise if Product Collection is nested in Single Product block
* Improve cases descriptions and add some defaults to potentially undefined values
* Change the taxonomies sourceData
* Recognise Mini Cart as Cart context
* Recognise attribute as archive contect but no taxonomy
* Refactor the function into single useEffect and clean it up
* Fix typo
* Remove unnecessary import
* Stop rendering the output in Editor (it was for demo purposes)
* Pass location data to Product Template query in Editor
* Replace templateSlugs literal strings with object reference
* Rename parseResponse function to more specific name getIdFromResponse
* Add dpeendency array to useEffect
* Refactor templates detection
* Use full taxonomy names instead of shortcuts
* Write down scenarios to test
* Working scenario
* Change the verification way for more robust
* Add more robust methods to include Single Product block
* Add test Product Collection in Single Product block in a Single Product Template
* Imprvoe the order of veryfing the requests
* Fix linter issues. Although that makes code less readable
* Improve the useGetLocation typing so it's more generic
* Rework the E2E tests regarding location of Product Collection and limit their number
* Bring back necessary eslint-disable
* Remove unused imports
* Uncomment line required for other tests
* Add changelog
* Rename constant from BLOCK_NAME to BLOCK_SLUG as it's a slug
* Add a BLOCK_NAME constant and replace the literal block name usages in E2E tests
* Fix post merge issues
* Fix test after merge
* Adjust the tests to kick off waiting for request before action that triggers them
* Make attributes available in rest_product_query hook
This commit introduces the 'includeInQueryContext' attribute to the 'woocommerce/product-collection' block and updates the 'woocommerce/product-template' block to consume this new attribute.
Key Changes:
1. `woocommerce/product-collection` Block:
- A new attribute 'includeInQueryContext' is added in `block.json`. This attribute is designed to hold a list of attribute names relevant for the query context.
- The 'includeInQueryContext' attribute is included in the `providesContext` field to ensure its availability to child blocks.
- In `constants.ts`, default values for 'includeInQueryContext' are defined, specifying 'collection' and 'id' as initial attributes.
- The `types.ts` file is updated with a comment explaining the purpose of 'includeInQueryContext'.
2. `woocommerce/product-template` Block:
- Modified `block.json` to utilize the 'includeInQueryContext' context provided by the parent `woocommerce/product-collection` block.
- The `edit.tsx` file is updated to handle the new context. It uses a newly added utility function `useProductCollectionBlockAttributes` from `utils.tsx` to access parent block attributes.
- The `utils.tsx` file is introduced, containing the `useProductCollectionBlockAttributes` hook. This hook is responsible for finding the parent 'woocommerce/product-collection' block and returning its attributes.
- Within `edit.tsx`, logic is added to create a query context object based on the attributes specified in 'includeInQueryContext', enhancing the block's ability to dynamically adapt to changes.
* Remove commented code
* Rename query context attribute and optimize parent block detection
This commit introduces two significant changes aimed at improving code readability and efficiency.
1. **Renaming of Query Context Attribute:**
- The attribute `includeInQueryContext` has been renamed to `queryContextIncludes` across various files, including block JSON configurations and TypeScript definitions. This change makes the attribute's purpose more intuitive, indicating it specifies which attributes to include in the query context.
2. **Optimized Parent Block Detection:**
- Replaced the use of `getBlockParents` with `getBlockParentsByBlockName` in utility functions to find the closest Product Collection block. This optimization allows for a more direct and efficient way to identify the relevant parent block by specifying the block name, reducing unnecessary iterations and improving code performance.
* Streamline query context construction in product template
Key Changes:
- **Introduction of `useProductCollectionQueryContext` Hook:** This new hook takes the `clientId` and `queryContextIncludes` as inputs and returns a query context object. It encapsulates the logic for fetching parent product collection block attributes and constructing the query context accordingly. This abstraction simplifies the edit component's logic, focusing on the essentials and improving code readability.
- **Optimization of Parent Block Detection:** The hook uses `getBlockParentsByBlockName` to accurately and efficiently find the closest parent `Product Collection` block, minimizing the overhead previously associated with traversing the block hierarchy.
* Always include `collection` and `id` in query context
* Minor refactor
* Enhance query context handling for more maintainable code
- Introduced `DEFAULT_QUERY_CONTEXT_ATTRIBUTES` in `edit.tsx` to maintain a clear list of default query context attributes.
- Modified `ProductTemplateEdit` to automatically include these default attributes in `queryContextIncludes`, ensuring they are always part of the query context without manual initialization.
- Simplified `useProductCollectionQueryContext` in `utils.tsx` by removing static initialization of 'collection' and 'id', relying instead on the dynamic addition of necessary attributes from `queryContextIncludes`.
This refactor enhances the maintainability and clarity of the code, ensuring a solid foundation for future enhancements and features.
* Add E2E tests for Product Collection query context
- Added a new test suite 'Query Context in Editor' to validate the correctness of query context parameters when the Product Collection block is used. This suite ensures that:
- For the 'Product Catalog', only the ID is sent in the query context, confirming that collection-specific parameters are excluded when not relevant.
- For collections such as 'On Sale', the collection name is correctly passed in the query context, validating that the block dynamically adjusts query parameters based on its settings.
- Introduced a new utility method `setupAndFetchQueryContextURL` in `product-collection.page.ts`. This method automates the setup of a post with the Product Collection block and fetches the URL with query context parameters, facilitating the validation of query context handling.
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Fix edge case when `queryContextIncludes` is not defined
- Initializing `queryContextIncludes` with a default empty array directly in the destructuring assignment of the component's props. This approach ensures that `queryContextIncludes` is always an array, simplifying downstream logic.
- Creating a new constant `queryContextIncludesWithDefaults` to hold the combination of `queryContextIncludes` and `DEFAULT_QUERY_CONTEXT_ATTRIBUTES`. This step avoids directly mutating the `queryContextIncludes` prop, aligning with best practices for functional purity and making the code easier to understand and debug.
- Updating the `useProductCollectionQueryContext` hook call to use `queryContextIncludesWithDefaults`. This ensures that the default query context attributes are consistently included without altering the original prop.
These adjustments not only enhance the code's maintainability but also ensure more predictable behavior by avoiding side effects related to parameter mutation.
---------
Co-authored-by: github-actions <github-actions@github.com>
* Remove global pageObject action from Product Collection tests and add it as before all for specific tests
* Replace beforeAll with beforeEach
* Adjust the beforeEach usage
* Add changelog
* Refresh locators when adding Single Product block as it's not initialised in pageObject
* Change method dedicated to templates to one dedicated to posts
* Remove 'get_block_template' backwards compatibility check
* Add back get_block_template as a deprecated function
* Deprecate BlockTemplateUtils::filter_block_templates_by_feature_flag()
* Replace 'default template' with 'fallback template'
* Only load BlockTemplatesController in block themes
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Remove unnecessary WP version comparison
* Revert "Only load BlockTemplatesController in block themes"
This reverts commit 8e1ed347d61b7ae5e8b8b96fa73b410565570f01.
* Remove deprecated functions, as they are marked as internal
---------
Co-authored-by: github-actions <github-actions@github.com>
* Add logic to trap keyboard focus inside the Product Gallery Pop-Up
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Remove unnecessary condition
* Fix issue with keyboard focus trap not working within the Pop-Up
---------
Co-authored-by: github-actions <github-actions@github.com>
* Improve password-protected Single Product block template to verify correct template is displayed after correct password is introduced
* Add changelog entry
* Import editor.scss styles of Product Templayte and increase specificity
* Add changelog
* Add ts ignore
* Revert changing eslint-disable as it conficts with another rule creating more errors
* Added Missing LInting Changes
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
---------
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Jon Lane <jon.lane@automattic.com>
* Add automated tests to verify specific product templates are rendered
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
---------
Co-authored-by: github-actions <github-actions@github.com>
* Include collection attribute in the block context
* add 'collection' to useContext for Product Template
* Changelog
---------
Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
* Return focus to trigger element when closing pop-up
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Fix php cs error
---------
Co-authored-by: github-actions <github-actions@github.com>
* Improve Product Collection test when nested in Single Product block, previous version was flakyu
* Add changelog
* Move the priovate method below the comment starting private methods
* Remove unnecessary wait