* Update isAddressComplete to allow only specific fields to be checked
* Update tests for isAddressComplete
* Update wording on "enter address" prompt in Cart sidebar
* Update Shipping to Delivery in cart & checkout shipping total
* Only check the city, state, country, & postcode fields in shipping calc
* Update wording in the "Ships to" section of cart/checkout sidebar
* Update shipping calculator button to say delivery
* Update tests to use new strings
* Remove test that was falsely passing anyway
This test checked for presence of a string that wasn't in the codebase. It also doesn't seem like a valid test. Why would we want to remove the button just because default rates are available?
* Add changelog
* Left align text in shipping calculator button
It floats weirdly in the middle with the new text changes
* Update text in tests
* Update wording in unit tests
* Update shipping calculator text in test
* Update shipping text in test
* Update use of shipping in tests
* Skip test with no translation available
* Lint fixes
---------
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* Define the event
* Add action sending an event in PC store
* Add directives and context to Product Template li element
* Use on--click directive in ProductImage
* Use on--click directive in Product Title
* Use on--click directive in Product Button
* Add changelog
* Add E2E tests
* Update docs
* Update blocks reference and docs manifest
* Update m,anifest
* Fix mistake in docs
* Regenerate docs manifest
* Fix lint
* Extractb new tests to a separate file
* Product filters ensure we can add multiple instances
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Add e2e tests to ensure multiple filters can be added
---------
Co-authored-by: github-actions <github-actions@github.com>
* Show product picker control in the editor when a product context is required but not provided
Enhanced the Product Collection block by introducing the `selectedReference` attribute and implementing a product picker control. This control appears in the editor when a product context is required but not provided in the current template/page/post.
1. **block.json**: Added `selectedReference` attribute of type `object`.
2. **constants.ts**: Included `selectedReference` in the `queryContextIncludes` array.
3. **EditorProductPicker.tsx**: Created a new component for selecting products within the editor.
4. **editor.scss**: Added styles for the new Editor Product Picker component.
5. **index.tsx**: Updated logic to determine the component to render, incorporating the new Editor Product Picker.
6. **types.ts**: Defined types for `selectedReference` and updated `ProductCollectionAttributes` interface.
This enhancement allows merchants to manually select a product for collections that require a product context, ensuring the block displays correctly even when the product context is not available in the current template/page/post.
- **Product Picker Control**: Utilizes the existing `ProductControl` component for selecting products. This component is displayed in the editor when a collection requires a product context but it doesn't exist in the current template/page/post.
* Update label on ProductControl component
* Implement dynamic UI state management for product collection block
- Introduced `ProductCollectionUIStatesInEditor` enum to define various UI states for the product collection block.
- Added `getProductCollectionUIStateInEditor` utility function to determine the appropriate UI state based on context.
- Updated `Edit` component to use `getProductCollectionUIStateInEditor` for dynamic state management.
- Refactored `ProductCollectionContent` to utilize the new Editor UI state management.
* Fix: Product picker isn't showing
* Fix: Preview label state isn't showing
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Refactor WooCommerceBlockLocation type
- Introduced specific interfaces for WooCommerceBlockLocation, including ProductLocation, ArchiveLocation, CartLocation, OrderLocation, and SiteLocation, to improve type safety and code clarity.
- Updated createLocationObject function to return a BaseLocation type.
- Refactored useSetPreviewState hook in product-collection utils:
- Extracted termId from location.sourceData for cleaner and more readable code.
- Replaced direct access of location.sourceData?.termId with termId variable.
* Remove fallback to 0 in case there may be a product with id 0
* Use optional chaining to avoid undefined errors
* Rename to
* Change order of arguments in function
* Pass boolean prop instead of making further recognition of the UI state in ProductCollectionContent
* Destructure props in component
* Rename to
* Update names in enum
* Rename to and change the structure to single number.
* Rename location to
* Add a method to choose a product in the product picker in Editor
* Add E2E tests
* Fix failing e2e tests by changing location to productCollectionLocation
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Don't allow selecting product variations
* Minor code refactoring
* Fix: Product control isn't showing products
**Before**
```tsx
const getRenderItemFunc = () => {
if ( renderItem ) {
return renderItem;
} else if ( showVariations ) {
return renderItemWithVariations;
}
return () => null;
};
```
As you can see above, `return () => null;` is returning a function which is causing the issue. This will render nothing in the list. I changed this to `return undefined;`. This way, we will use default render item function.
* Translate text in ProductPicker component
* Improve E2E test
* Use createInterpolateElement to safely render strong HTML tag
* Fix E2E tests
* Fix E2E tests
* Product Collection: Inspector control to change selected product (#50590)
* Add Linked Product Control to Product Collection Block Inspector Controls
- Introduced a new `LinkedProductControl` component in the Product Collection block's Inspector Controls.
- This control allows users to link a specific product to the product collection via a dropdown with a search capability.
- Added corresponding styles to `editor.scss`.
- Integrated a `useGetProduct` hook in the `utils.tsx` to fetch and manage the state of the linked product data, including handling loading states and errors.
- Updated the Inspector Controls to include the new Linked Product Control component, enhancing the block's customization options for users.
* Add E2E tests
* Hide product picker when product context is available
* Improve logic to hide Linked Product Control
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Remove hasError state from useGetProduct hook
* Rename isShowLinkedProductControl to showLinkedProductControl
* Convert jsxProductButton to ProductButton component
* Refactor jsxPopoverContent to LinkedProductPopoverContent component
* Improve UI of Linked Product Control
* Address PR feedback
* Fix E2E tests
---------
Co-authored-by: github-actions <github-actions@github.com>
* Rename isUsesReferencePreviewMode to isUsingReferencePreviewMode
* Change order of conditions in getProductCollectionUIStateInEditor
---------
Co-authored-by: github-actions <github-actions@github.com>
* Disable PC render when content empty unless no results block is present
* Introduce empty PC classname
* Add E2E test
* Add changelog entry
* Ensure the render is preserved as expected
* Do not render empty div
* Update tests
* Try a different logic
* Add hint to the docblock
* Remove obsolete e2e test
* Update render handler name to acknowledge context
* Fix tests failing due to recent v3 update
* Restore block interactivity
---------
Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
* Not show reviews in the frontend when they are disabled at store or product level
* Add tests for single product template
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Fix typo
---------
Co-authored-by: github-actions <github-actions@github.com>
* Move register product collection tester e2e tests from product collection file to its own file
* Add changelog file
* Remove the unstable allTextContents usage
* Remove page.waitForTimeout because it doesn't validate that the button is hidden after exactly 1 second
* Remove page.waitForTimeout from 'Should display properly in Product Catalog template' e2e test
* Let's use one parent describe per file for good practice
* Keeping the structure flat
* Add context to type
* Clean up notifyerrors helpers
* Notify and clear top level cart errors
* changelog
* Make extensionCartUpdate surface the errors
* No automatic clearing of notice
* Handle generic errors only, add docs
* Rename param
* Fix linting in readme
* Update toc
* test coverage
* Unused import
* We're only dealing with arrays of errors so simplify logic
* Dispatch JS event about PC being rendered
* Revert format changes
* Write the callback
* Add functions descriptions
* Add changelog
* Remove empty line
* Add tests
* Rename test cases
* Replace waiting for page load with more reliable expect.poll
* Remove leftover step
Co-authored-by: Bart Kalisz <bartlomiej.kalisz@gmail.com>
* Fix typo in function name
* Add collection name to default Product Collection block
* Expect collection name in the event
* Expose the collection name through IAPI context
* Send the collection name with the event
* Trigger event also on page change
* Remove unused CUSTOM collection type
* Provide documentation
* Update TOC
* Update tests that verify the event payload
* Improve E2E tests further
* Don't add a Product Catalog collection type to default collection
* Avoid repeating the same piece of code by extracting some function on tag processor
* Rename function to better depict its purpose
* Move the documentation to the right place
* Remove the unused variable
* Add example to dom-events doc
* Update documentation
* Update docs manifest
* Attach default collection name
* Add the default collection context in PHP so it covers all the cases
* Prevent exposing product catalog collection name in event
* Update docs
* Update test
---------
Co-authored-by: Bart Kalisz <bartlomiej.kalisz@gmail.com>
* update: new simplified markup and style
* add: editor preview
* add: show 15 items initially
* fix: render li class for checked items
* chore: naming
* chore: changelog
* update: set some preview items checked for styling purpose
* fix: only show show more button when the list is long
* chore: lint
* fix: e2e tests
* Allow registering custom collections with various context references
Implemented the registration of product collections with different context references using the `usesReference` property. These custom collections are now registered with specific contexts such as product, cart, order, and archive.
This enhancement allows for more tailored previews and functionality based on the specific context in which the product collection is used.
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Support multiple references for usesReference
* docs: update documentation to include `usesReference`
Enhanced the `register-product-collection` documentation to include details about the new `usesReference` property. This property allows collections to specify required references, enhancing their contextual relevance and preview capabilities.
- Added `usesReference` description to the collection fields section.
- Included examples demonstrating the usage of `usesReference` with single and multiple references.
- Clarified the behavior when required references are unavailable on the editor side but available on the frontend.
This documentation update provides third-party developers with the necessary information to utilize the `usesReference` property effectively in their custom product collections.
* test: add e2e tests for `usesReference`
Added end-to-end tests to verify the functionality of the `usesReference` property in product collections. These tests ensure that the appropriate preview labels are displayed.
- Created multiple custom product collections with different `usesReference` values: `product`, `cart`, `order`, `archive`, and combinations of these.
- Verified that collections show the correct preview label when the required reference is present.
- Ensured that the preview label is not shown in irrelevant contexts, such as posts or product catalog templates.
This addition enhances test coverage and ensures the robustness of the `usesReference` feature.
* Fixed issue with preview label showing in Specific Product and Archive templates.
* Handle cases when termId or productId is 0
This also improves the readability of the code by using better variable names.
* Make PC use postId context so location can be recognised correctly (#50152)
* Fix TS errors
---------
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Karol Manijak <20098064+kmanijak@users.noreply.github.com>
* Modify Product Filters Overlay template part
* Add changefile(s) from automation for the following project(s): woocommerce
* Add E2E tests for the Product Filters Overlay template part
---------
Co-authored-by: github-actions <github-actions@github.com>
* Recognize custom category templates as archive ones
* Disable the preview label if termId is recognized
* Fetch the product category template ID
* Prepare util to properly parse product taxonomies
* Utilise the taxonomies util and update the query accordingly
* Add tests
* Update tests to be more specific
* Improve selectors in E2E test
* Add changelog
* Update selectors
* Fix the order of expected products
* Remove unneceessery entries from array that are covered by another entries
* Rename the variable to beytter depict its purpose
* Add validation and empty value to select components
* address feedback
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* remove console log
* Update plugins/woocommerce-blocks/docs/third-party-developers/extensibility/checkout-block/additional-checkout-fields.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update plugins/woocommerce-blocks/docs/third-party-developers/extensibility/checkout-block/additional-checkout-fields.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* remove test
* Fix tests
* also move select to parent
* fix tests
* add empty enum to schema
---------
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* add: new inspector controls
* update: cleanup the edit component
* chore: remove unused old inspector component
* tweak: add formatting to help text
as Jarek said:
> Here’s the copy. Please mind the formatting.
* add: default attribute id that closest to 30
* update: pass the whole attribute object
* update: use default attribute term in Product Filters template
* add: style settings
* add: sorting and show empty behavior in the editor preview
* tweak: use hideEmpty to align with existing settings
* chore: changelog
* test: add basic e2e tests
* chore: restore previous default value
* add: attribute help text and border support
* chore: lint
* fix: add missing context
* Add Product Filters template part
* Improve Product Filters template part description
* Hide Product Filters block from the inserter
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Add E2E tests
* Fix lint error
* Fix lint error
* add: register variation for unmodified template part
We should move this to abstract class later.
* Fix lint error
---------
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
* Add syncWithFilters attribute to Product Collection
* Add SycnWithFilters Inspector Control to PC
* Minor import adjustments
* Move the controls to Inherit as they share the same labels
* Rename the attirbute to filterable
* Hide control for collections
* Consume the filterable
* Consume filterable attribute so it enables the filtering
* Bring back file format
* Bring back filterable
* Move filterable from attribute to query
* Improve checks
* Fix incorrent function name
* Add changelog
* Set the default filterable value on insert
* Update test selector
* Add E2E tests to #49627 (#49715)
* Remove unnecessary call to create new post
* Fix "Use page context" control tests
* Fix post ↔ template collection sync test
* Fix non-thenable linter errors
* Extend the "Use page context" default setting test
* Add test for filtering in non-archive context
* Add test for combining editor and front-end filters
* Fix lint
* Update plugins/woocommerce-blocks/assets/js/blocks/product-collection/edit/inspector-controls/inherit-query-control.tsx
Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
* Improve query properties access
* Rename inherit-query-control to use-page-context-control to better depict its purpose
* Lint fix
---------
Co-authored-by: Bart Kalisz <bartlomiej.kalisz@gmail.com>
Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
In this PR, we are consolidating babel-loader caching and adding Jest caching, improving build/testing times locally and in CI. The improvement comes from cache covering transpile steps in the mentioned processes.
* Add overlay settings
* Tweak icon size slider
* Add overlay template part link
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Fix scss linting
* Fix php linting
* Remove preview
* Rename setting props to be more clear
* Remove unused import
* Update plugins/woocommerce-blocks/assets/js/blocks/product-filters/editor.scss
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
* Update plugins/woocommerce-blocks/assets/js/blocks/product-filters/edit.tsx
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
* Update plugins/woocommerce-blocks/assets/js/blocks/product-filters/types.ts
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
* Update plugins/woocommerce-blocks/assets/js/blocks/product-filters/edit.tsx
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
* Move experimental controls to last of list
* Improve typescript code
* Remove unneeded constructor code
* Extract icons into own component
* Moved overlay template part link to the bottom
* Add apply button
* Hide overlay settings when in always mode
* Remove overlay template part from list and put into general area
* Update api version to 3
* Update plugins/woocommerce-blocks/assets/js/icons/library/filter.tsx
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
* Update plugins/woocommerce-blocks/assets/js/icons/library/filter-three-lines.tsx
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
* Fix overlay button link style and clickable
* Remove edit overlay link from never mode
* Add e2e tests for the filters overlay settings
---------
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
* Add site title to account checkbox
* Add customer_password support to Store API
* Hide password nag if defining own password
* Add woocommerce_registration_generate_password option to block assets
* Change login prompt to just "log in"
* Add default styling to password inputs
* Reset line height for checkbox inputs
* Add customer password to store
* Add password field to contact information block
* Handle customer password in checkout processor
* Styling for new elements
* Update tests so they match new create account label
* Update log in link in tests
* Add e2e tests for password field
* Add validation message and fix rendering when account is required
* Changelog
* Add missing api to tests
* Remove console log
* rerender checkout
* Update log in link in test
* Adjust validation so we can change the label in messages with custom callback
* Use queryByText in test
* Make sure password generation is on in tests
* Create password if provided password is empty
* Skip "Place order" button translation test
* Revert "Skip "Place order" button translation test"
This reverts commit 7aed6137e88cdb3577f74f6f0c05258b531ed534.
* Update plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-contact-information-block/block.tsx
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Update plugins/woocommerce-blocks/assets/js/data/checkout/reducers.ts
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Comment empty condition
* Update CSS classnames
* Return null in CreateAccountUI if nothing to display
* Linting: Return return param
* Document $password param
---------
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>