woocommerce/plugins/woocommerce-blocks/assets/js
Manish Menaria a73c6e5546
Product Collection: Enable Context-Aware Previews by Adding `usesReference` to `registerProductCollection` (#49796)
* 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>
2024-08-01 15:33:27 +05:30
..
atomic [React 18] Use `createRoot().render()` instead of `render()` (#48843) 2024-07-26 09:18:48 +02:00
base Allow rendering the quantity in cart when the quantity is not editable (#49450) 2024-07-29 16:12:15 +01:00
blocks Product Collection: Enable Context-Aware Previews by Adding `usesReference` to `registerProductCollection` (#49796) 2024-08-01 15:33:27 +05:30
blocks-registry Product Collection: Enable Context-Aware Previews by Adding `usesReference` to `registerProductCollection` (#49796) 2024-08-01 15:33:27 +05:30
data Checkout: Add password field to create account form (#48985) 2024-07-15 11:43:02 +01:00
editor-components Revert "[Enhancement]: Add option to show price on the place order button" (#49899) 2024-07-24 18:08:05 +02:00
extensions Use `createRoot().render()` instead of `render()` (#48858) 2024-07-04 11:36:38 +02:00
filters Fixed Blocks Linting Errors (#42727) 2023-12-12 15:05:20 -08:00
hocs With Product Variations HOC > Convert to TypeScript (#44785) 2024-02-26 10:26:21 -03:00
icons [Experimental]: Update: new title and icon for the Overlay Navigation block (#50011) 2024-07-31 12:56:53 +07:00
interactivity [Experimental] Interactivity Dropdown multi-select mode, ratings filter and introduce each directive (#42981) 2023-12-22 13:34:28 +13:00
middleware Fixed Blocks Linting Errors (#42727) 2023-12-12 15:05:20 -08:00
previews Extensibility: Format currency config so it can be consumed more easily (#48727) 2024-07-12 14:24:22 +01:00
settings Add validation to select fields and add placeholder option to additional fields API (#49929) 2024-07-26 16:38:44 +00:00
shared Convert inner-block-layout-context to typescript (https://github.com/woocommerce/woocommerce-blocks/pull/9799) 2023-06-14 06:36:39 -07:00
templates/revert-button Update revert button text and description (#48717) 2024-07-03 19:31:50 +05:30
types Filter by Attribute: fix potential reading property of undefined error (#47699) 2024-05-22 11:57:53 +02:00
utils Use the term attribute sort order for the "Filter by attribute" block (#47616) 2024-05-21 15:44:08 +02:00
global.d.ts WIP - Checkout i2 Feature Branch Tracking (https://github.com/woocommerce/woocommerce-blocks/pull/4268) 2021-07-22 12:03:00 +01:00
index.js Move registration of block categories on the server side (#47836) 2024-06-03 20:34:41 +02:00