woocommerce/plugins/woocommerce-blocks/assets/js/blocks/product-collection/collections
Manish Menaria a55812eba2
Product Collection: Update heading for Hand-Picked collection (#51643)
* Update heading for Hand-Picked collection

- Added 'recommend' to the keywords array.
- Changed heading content from 'Hand-Picked' to 'Recommended products'.

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

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-09-24 16:14:07 +05:30
..
README.md New flow of adding Product Collection and basic set of Collections (#42696) 2023-12-27 11:07:27 +01:00
best-sellers.tsx Product Collection: add control to toggle whether block is filterable in non archive context (#49627) 2024-07-24 11:51:53 +02:00
featured.tsx Product Collection: add control to toggle whether block is filterable in non archive context (#49627) 2024-07-24 11:51:53 +02:00
hand-picked.tsx Product Collection: Update heading for Hand-Picked collection (#51643) 2024-09-24 16:14:07 +05:30
index.tsx Product Collection: Implement the Hand-Picked collection (#51141) 2024-09-21 20:10:10 +05:30
new-arrivals.tsx Product Collection: add control to toggle whether block is filterable in non archive context (#49627) 2024-07-24 11:51:53 +02:00
on-sale.tsx Product Collection: add control to toggle whether block is filterable in non archive context (#49627) 2024-07-24 11:51:53 +02:00
product-collection.tsx Product Collection: Redesigned Collection Insertion Selection (#48911) 2024-07-09 13:53:48 +02:00
related.tsx Product Collection: Introduce "Related Products" Collection (#51076) 2024-09-21 16:12:58 +05:30
top-rated.tsx Product Collection: add control to toggle whether block is filterable in non archive context (#49627) 2024-07-24 11:51:53 +02:00
upsells.tsx Add Upsells collection (#51374) 2024-09-21 19:28:47 +05:30

README.md

Product Collection - Collections

Note: Collections documented here are internal implementation. It's not a way to register custom Collections, however we're going to expose public API for that.

Collections are a variations of Product Collection block with the predefined attributes which includes:

  • UI aspect - you can define layout, number of columns etc.
  • Query - specify the filters and sorting of the products
  • Inner blocks structure - define the Product Template structure

Interface

Collections are in fact Variations and they are registered via Variation API. Hence they should follow the BlockVariation type, providing at least:

type Collection ={
	name: string;
	title: string;
	icon: Icon;
	description: string;
	attributes: ProductCollectionAttributes;
	innerBlocks: InnerBlockTemplate[];
	isActive?:
		(blockAttrs: BlockAttributes, variationAttributes: BlockAttributes) => boolean;
}

Please be aware you can specify isActive function, but if not, the default one will compare the variation's name with attributes.collection value.

As an example please follow ./new-arrivals.tsx.

Collection can hide Inspector Controls filters from users

Let's take New Arrivals as an example. What defines New Arrivals is the product order: from newest to oldest. Users can apply additional filters on top of it, for example, "On Sale" but shouldn't be able to change ordering because that would no longer be New Arrivals Collection.

To achieve this add additional property to collection definition:

type Collection = {
	...;
	hideControls: FilterName[];
}

Registering Collection

To register collection import it in ./index.ts file and add to the collections array.