From 2af03c7dad6e79624852c97adb98a28d44425d1f Mon Sep 17 00:00:00 2001 From: Karol Manijak <20098064+kmanijak@users.noreply.github.com> Date: Fri, 13 Oct 2023 16:43:31 +0200 Subject: [PATCH] Document Product Collection Attributes --- assets/js/blocks/product-collection/README.md | 61 +++++++++++++++++++ .../edit/inspector-controls/Untitled-1.js | 0 2 files changed, 61 insertions(+) create mode 100644 assets/js/blocks/product-collection/README.md create mode 100644 assets/js/blocks/product-collection/edit/inspector-controls/Untitled-1.js diff --git a/assets/js/blocks/product-collection/README.md b/assets/js/blocks/product-collection/README.md new file mode 100644 index 00000000000..97a7a917f8a --- /dev/null +++ b/assets/js/blocks/product-collection/README.md @@ -0,0 +1,61 @@ +# Sample Product Collection attributes object with field descriptions + +## Current query attributes + +| Field | Type | Default | Description | +| ----------------------------- | ----------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------- | +| perPage | Number | 9 | Number of products per page | +| pages | Number | 0 | Total number of pages Product Collection should allow to browse | +| offset | Number | 0 | Offset of products when starting pagination | +| postType | 'product' | 'post' | product' | The type of posts to fetch. It's 'product' by default and it's very unlikely to change that | +| isProductCollectionBlock | Boolean | true | Specifies that the query is from Product Collection block. There's no case in which it should be changed | +| inherit | Boolean | true | Define it the query should inherit from template query or not. If yes, all the other filters are ignored | +| order | 'asc' | 'desc' | asc' | Determines if the order is ascending or descending | +| orderBy | 'title' | 'date' | 'popularity' | 'rating' | title' | Allows to choose the ordering from presets | +| author | String | - | To be removed. Filter products by the author of the product (post) | +| search | String | - | Filter the products by keyword | +| exclude | ProductID[] | [] | Specified products won't be displayed as results even if they match other filters. There's no UI representation of this filter at the moment | +| woocommerceHandPickedProducts | ProductID[] | [] | Array of products. The whole filtering will be applied only to this set of products | +| woocommerceOnSale | Boolean | false | If true, display only products on sale | +| woocommerceStockStatus | StockStatus[] | [] | Display products from specific stock statuses | +| woocommerceAttributes | [ { termId: TermID, taxonomy: Taxonomy } ] | [] | Display products with specific attributes | +| taxQuery | { product_cat: CategoriesId[], product_tag: TagID[] } | {} | Filter products from specific categories and/or tags | +| parents | Array | [] | ??? | +| sticky | '' | 'only' | String | '' | ??? | + +## Example attributes shape + +```javascript +const exampleAttributes = { + queryId: 0, + tagName: 'div', + displayLayout: { type: 'flex', columns: 2 }, + query: { + perPage: 9, + pages: 0, + offset: 0, + postType: 'product', + order: 'asc', + orderBy: 'title', + author: '', + search: 'hoodie', + exclude: [], + sticky: '', + inherit: false, + taxQuery: { product_cat:[5], product_tag: [39] }, + parents: [], + isProductCollectionBlock: true, + woocommerceOnSale: false, + woocommerceStockStatus: [ 'instock', 'outofstock', 'onbackorder' ], + woocommerceAttributes: [ + { termId: 47, taxonomy: 'pa_color' }, + { termId: 11, taxonomy: 'pa_color' }, + { termId: 18, taxonomy: 'pa_color' }, + { termId: 12, taxonomy: 'pa_color' }, + { termId: 13, taxonomy: 'pa_color' }, + { termId: 19, taxonomy: 'pa_color' }, + ], + woocommerceHandPickedProducts: [ '1240', '1239' ], + }, +}; +``` diff --git a/assets/js/blocks/product-collection/edit/inspector-controls/Untitled-1.js b/assets/js/blocks/product-collection/edit/inspector-controls/Untitled-1.js new file mode 100644 index 00000000000..e69de29bb2d