7d71e2235a
* Updated Collection Selection Buttons Rather than using normal buttons we're going to replace these with cards that we want to use instead. * Reworked Product Catalog Creation * Added Dropdown Collection Option * Changelog * Added Collection Dashicon Support * Fixed Collection Change Modal This is going to get replaced soon but it may as well look nicer than it does right now. * Type Fix * Fixed `:focus` Hover Border * Simplified Click Handler * Style Fixes * Gutenberg Style Fixes * E2E Fixes * Fixed E2E Test * Added Dropdown Inserter E2E Support * Logging * Fixed Default Insertion Options * Prevent Premature Rendering * E2E Fix Attempt * Lint Fix * E2E Fix * Fix test chaking if custom registred collections are available in the collection chooser * Improve logic of choosing collection to cover both dropdown and placeholder --------- Co-authored-by: Karol Manijak <20098064+kmanijak@users.noreply.github.com> |
||
---|---|---|
.. | ||
README.md | ||
best-sellers.tsx | ||
featured.tsx | ||
index.tsx | ||
new-arrivals.tsx | ||
on-sale.tsx | ||
product-collection.tsx | ||
top-rated.tsx |
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.