woocommerce/plugins/woocommerce-blocks/assets/js/blocks/product-template
Bart Kalisz 35ba49a1f2
Product Collection: Implement the Hand-Picked collection (#51141)
* Fixed PHP 7.4 Compatibility

The splat operator does not support associative arrays until PHP 8.1.

* Added Related Products Collection Boilerplate

* Added `woocommerceRelatedTo` Collection Parameter

This parameter allows the block to query for products that are related
to the given product IDs.

* Added Collection Related Product Filter

Using `woocommerceRelatedTo`, queries may restrict the products returned
to those that are related to the given product ID(s).

* Removed Unnecessary Tracking

* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce

* Removing Misunderstood Option

* Linting Fix

* Fixed Test

* Initialize the Hand-Picked collection

* Removed Unnecessary Keyword

* Render the collection-specific control

* try removing for fixing gh syntax hl

* add back

* tweak icon render

* combine conditions for early return

* Remove timeFrame from the query

* Set control label per context

* Use primitives for the icon

* Hide 'order by' control for the Hand-Picked collection

* Support Unlimited `wc_get_related_products()`

This changes related product fetching so that `-1` will return all
related products. I also removed a second +10 offset that seems
to have been accidentally added eight years ago.

* Revert "Set control label per context"

This reverts commit cd537befbe.

* Update titles and description

* Enable sorting by entered order

* Removed `woocommerceRelatedTo` Param

Since we're going to use the collection name, we don't need
this functionality any longer.

* Simplified `post__in` Filtering

Since `merge_queries` was already using an intersection merge for
`post__in`, this second function is unnecessary. I've removed it
as well as refactored the merging logic.

* Pass Collection Name To Final Query

* Improve the query merging logic

* Added Custom Collection Handlers

Developers can register collections along with handlers that implement
the custom behavior.

* Removed Second Test Query Construction

As it was, `build_query_vars_from_query_block()` was triggering the
ProductCollection instance hooked into WordPress. After that, we
called `build_frontend_query()` on our test instance. This caused some
weird behavior in tests. As a result, however, the tax_query merge
test couldn't rely on the tax_query transformation done by WordPress.

* Added Related Product Collection Handlers

* Revert "Support Unlimited `wc_get_related_products()`"

This reverts commit 41c837202e.

* Fixed Preview Mode Query

It looks like we were checking the wrong place for the preview
state.

* Improve the query merging logic

* Fixed Test

* Updated Collection Heading

* Handle collection context / no results state

* Small cleanup

* Better Collection Test Teardown

Passing a callable back means that we can use variables in the
setUp and then the tearDown without any confusion.

* Removed Unnecessary Test Provider

* Fixed `$post__in` Merging

When the intersection is empty it was returning all products. This
makes it so that it returns nothing when there's no results.

* Set perPage to 0 and add Pagination block for better discoverability

* Improve empty state in Editor by providing meaningful instruction

* Make code more defensive

* Hide more filters in scope of handpicked through hideFilters API

* Fixed PHPDoc

Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>

* Hide Empty Related Product Collections

* Removed Duplicate Query Function

* Added Hand-Picked Collection Handler

* Revert changes to pnpm

* Improve comment for empty Hand-Picked collection

* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce

* Fix: Pagination not working on Frontend

Remove perPage and pages attributes from hand-picked collection

* Remove unused code

* Revert "Improve empty state in Editor by providing meaningful instruction"

This reverts commit 9ac5c20d5e.

* Do not apply layout styles for empty results

* Improve the wording on the empty results message

---------

Co-authored-by: Christopher Allford <6451942+ObliviousHarmony@users.noreply.github.com>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
Co-authored-by: Karol Manijak <20098064+kmanijak@users.noreply.github.com>
2024-09-21 20:10:10 +05:30
..
block.json Update all blocks to V3 (#48720) 2024-08-20 10:14:11 +00:00
edit.tsx Product Collection: Implement the Hand-Picked collection (#51141) 2024-09-21 20:10:10 +05:30
editor.scss Product Collection: fix assymmetrical padding in Editor (#44403) 2024-02-09 09:42:29 +01:00
icon.tsx Foundation of New Product Collection Block (https://github.com/woocommerce/woocommerce-blocks/pull/9352) 2023-05-15 08:51:49 +00:00
index.tsx Enable Product Collection as a core feature (https://github.com/woocommerce/woocommerce-blocks/pull/10524) 2023-08-25 15:58:11 +02:00
save.tsx Foundation of New Product Collection Block (https://github.com/woocommerce/woocommerce-blocks/pull/9352) 2023-05-15 08:51:49 +00:00
style.scss Product Collection: Fix alignment of the first item in Grid layout for WP 6.6 (#49096) 2024-07-05 17:24:27 +05:30
utils.tsx Product Collection - Show product picker in Editor when collection requires a product but it doesn't exist (#50164) 2024-09-02 12:39:33 +05:30