* fix line height
* Support controlling address card from data store
* expand billing address on unsync
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* disable linter rule
* remove empty section
* remove used vars
---------
Co-authored-by: github-actions <github-actions@github.com>
* Initial implementation of the missing product state
- Changed `getProductCollectionUIStateInEditor` to a hook `useProductCollectionUIState`.
- As we added logic to check if selected product reference is deleted which require making an API call. Therefore, I decided to use a hook.
- While making an API call to check if product reference is deleted, I decided to show spinner in the block.
- Introduced new UI state `DELETED_PRODUCT_REFERENCE` to handle the missing product state.
- Updated existing `ProductPicker` component to handle the new UI state.
- It's better to use existing component for the missing product state, as it already has all the required UI.
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Use getEntityRecord to check if product exists and other improvements
* Remove console log
* Add E2E tests for deleted product reference in Product Collection block
This commit introduces new E2E tests to verify the behavior of the Product
Collection block when dealing with deleted product references. The changes
include:
1. New test suite in register-product-collection-tester.block_theme.spec.ts
2. Modification to product-collection.page.ts to support custom product selection
3. Minor update to utils.tsx to handle trashed products
These tests ensure that the Product Collection block correctly handles
scenarios where referenced products are deleted, trashed, or restored,
improving the overall reliability of the feature.
* Simplify product creation in Product Collection block test
* Refactor E2E test for delete product reference picker
1. Removing the unnecessary `test.describe` block for "Deleted product reference"
2. Eliminating the `beforeEach` hook that was creating a test product
3. Integrating the test product creation directly into the main test
This change simplifies the test structure and improves readability while
maintaining the same test coverage for the Product Collection block's
behavior when dealing with deleted or unavailable products.
* Simplify logic for product collection UI state
This commit simplifies the handling of the `usesReference` prop in the
Product Collection block:
1. In `edit/index.tsx`, directly pass `usesReference` to
`useProductCollectionUIState` hook without conditional spreading.
2. In `utils.tsx`, update the type definition of `usesReference` in the
`useProductCollectionUIState` hook to explicitly include `undefined`.
* Refactor Product Collection block to improve prop passing
- Introduce ProductCollectionContentProps type for better prop management
- Refactor Edit component to use a renderComponent function
- Update component prop types to use more specific props
- Remove unnecessary props from ProductCollectionEditComponentProps
- Simplify component rendering logic in Edit component
- Adjust ProductPicker to receive only required props
- Update imports and prop types in various files to use new types
This refactoring improves code organization and reduces prop drilling by
only passing necessary props to each component. It enhances maintainability
and readability of the Product Collection block and related components.
* Refactor Product Collection block editor UI state handling
This commit simplifies the rendering logic in the Product Collection block's
Edit component. It removes a redundant case for the VALID state, as both
VALID and VALID_WITH_PREVIEW states now render the same ProductCollectionContent
component. This change improves code maintainability and reduces duplication.
* Fix: isDeletedProductReference is not set correctly
* Use "page.reload" instead of "admin.page.reload"
* Separate PRODUCT_REFERENCE_PICKER and DELETED_PRODUCT_REFERENCE cases
This improves readability and maintainability of the switch statement.
---------
Co-authored-by: github-actions <github-actions@github.com>
* reset styles for panel button
* reset styles for address card edit and address line 2
* Update shipping selector buttons
* fix line height
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* remove extra styles no longer needed
* update styles to balance chevron and change to span
---------
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
* update Mongolia postcode to be 5 digits instead of 6
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* update validation package and expand mongolia checks
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* update lock
* fix lock again
---------
Co-authored-by: github-actions <github-actions@github.com>
* Add focus styles for select
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
---------
Co-authored-by: github-actions <github-actions@github.com>
* Add block to templates
* Register block type with php
* Create block type class
* Update webpack
* Move password strength meter component
* Add button styles when disabled
* Move password strength component
* Block WIP
* CSRF token handling
* Put new block behind feature flag
* Add experimental flag docs
* Update icon + description
* Changelog
* Lint errors
* Style controls
* Adjust icon markup
* subsctring match
* More specific import
* Fix test fail caused by layout shift
* Wording changes from Figma
* Check if logged in, not just if the current email is registered
* Use opacity for disabled button text
* Sync order data with customer after account creation
* Add id/fragment to form
* Remove overlay icon settings from parent block
* Change overlay block icon to generic button icon
* Add logic to remove overlay nav when overlay mode is set to never
* Add logic to add overlay nav when overlay mode is not never
* Add default attributes for overlay nav button
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Use unique icons for each overlay navigation close and open
* Add icon picker for open overlay navigation
* Add trigger type for overlay close navigation
* Add missing settings label
* Fix e2e tests
* Skip a test for overlay-navigation block
* Add e2e tests for overlay button behavior
* Fix linting error
* Skip overlay nav tests
* Fix icon size value not saving
* Revise logic to target explicitly the innerblock of product-filters
* Ensure overlay navigation is of type open-overlay
* Prevent possible race conditions
---------
Co-authored-by: github-actions <github-actions@github.com>
* Add variation to Product Filters Overlay Navigation
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Move Product Filters Overlay Navigation to correct position
* Hide block when it is outside the Product Filters template part
* Display Navigation block in the frontend
* Show the Product Filters Overlay Navigation on the frontend
* Add logic to hide Product Filters Overlay Navigation block on the frontend
* Hide block on the Overlay template part
* Fix eslint errors
* Update the block variation title
* Remove the `isActive` property from the block variations
* Use Product Filters block context
* Replace enum with const
* Remove unnecessary `StyleAttributesUtils`
* Rename context key
* Move BlockOverlayAttribute to the constants.ts file
* fix BlockOverlayAttribute import
* Fix import error
* Improve code for the shouldHideBlock method
* Remove unnecessary attributes property
* Fix error in ProductFiltersOverlay block
* Add dialog to the Product Filters block
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Fix interactivity api error
* Prevent block from being hidden on Product Filters template part
* Fix inspector controls when block is hidden
* Add clickable action to the Product Filters Overlay Navigation block
* Fix interactivity directives that were not working for the Overlay
* Fix issue with dialog styles not being correctly applied
* Add the `closeDialog` functionality
* Parse and render blocks for the Product Filters overlay
* Fix padding
* Fix style for Product Filters Overlay navigation block
* Add e2e test
* Add e2e test to Product Filters Overlay template part
* Fix e2e test
* Fix issue causing the trigger button to show even though the overlay mode is set to 'Never"
* Fix issue causing close button to not be displayed in the dialog
* Add e2e tests
* Fix issue that was preventing users from scrolling down the dialog content
* Remove text duplication in e2e tests
* Remove unnecessary imports
* Fix php cs errors
* Fix php cs error
* Revert changes on Product Gallery modal styles
* Fix lint errors
* fix php cs lint errors
* fix php cs error
---------
Co-authored-by: github-actions <github-actions@github.com>
* Revert "[React 18] Use `createRoot().render()` instead of `render()` (#48843)"
This reverts commit 752273e6ce.
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
---------
Co-authored-by: github-actions <github-actions@github.com>
* Update README.md
* Update 722.md
* Update 741.md
* Update docs-manifest.json
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
---------
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
Co-authored-by: Roy Ho <roykho77@gmail.com>
* 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>
* Fix no products component prematurely being rendered
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Use useMemo to memoirize component element on re-renders
---------
Co-authored-by: github-actions <github-actions@github.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>
* Add aria-label to checkout form landmark
* Remove aria-hidden from checkout form sub-titles
* Add aria-label to checkout form
* Add changelog file
* Remove aria-hidden from form-step snapshots
* Bump form-checkout template version
* 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>
* Add new prefix and suffix attributes
* Add editable prefix & suffix rich text fields
* Remove the uppercase style from prefix and suffix
* Render the prefix and suffix in the front end
* Fix lint errors
* Handle old sku block without prefix and suffix
* Improve the editor styles
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Use wp_kses_post to filter and format the suffix and perfix
* Address extra space when empty and better escaping
---------
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>
* Remove filter margins in the editor
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Remove small space after + sign
---------
Co-authored-by: github-actions <github-actions@github.com>
* Change cursor style of preview button to default
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Hover and active state shouldn't change background color of the preview button.
* Remove use of wp-block-woocommerce-product-collection class
---------
Co-authored-by: github-actions <github-actions@github.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
* Update Block References doc
* Move the Block References to public Docs
* Change the place Block Reference is generated to
* Add changelog
* Update docs manifest file
* Update manifest