-
Notifications
You must be signed in to change notification settings - Fork 218
Product Collection: Add stock status filter #9580
Product Collection: Add stock status filter #9580
Commits on May 15, 2023
-
Add columns control to product collection block editor settings
- `InspectorControls` from './inspector-controls' is now imported in `edit.tsx` and used in the returned JSX of `Edit` function. - A new file `columns-control.tsx` is added under 'product-collection' block's 'inspector-controls' directory which exports a `ColumnsControl` component. This component uses `RangeControl` from '@wordpress/components' to control the number of columns in the product collection display layout when the layout type is 'flex'. - The types file (`types.ts`) for 'product-collection' block is updated. The `Attributes` interface is renamed to `ProductCollectionAttributes` and the `ProductCollectionContext` interface is removed. The `ProductCollectionAttributes` now includes 'queryContext', 'templateSlug', and 'displayLayout' properties.
Configuration menu - View commit details
-
Copy full SHA for e4abb25 - Browse repository at this point
Copy the full SHA e4abb25View commit details -
Configuration menu - View commit details
-
Copy full SHA for 43b2d1c - Browse repository at this point
Copy the full SHA 43b2d1cView commit details
Commits on May 16, 2023
-
Refactor: Simplify Fallback Return in ColumnsControl Component
This commit simplifies the fallback return value of the ColumnsControl component. Instead of returning an empty fragment (<> </>), it now returns null when the condition isn't met. This change improves readability and aligns with best practices for conditional rendering in React.
Configuration menu - View commit details
-
Copy full SHA for 65582af - Browse repository at this point
Copy the full SHA 65582afView commit details -
Feature: Add 'Order By' Control to Product Collection Inspector
This commit adds a new 'Order By' control to the product collection inspector. The control allows users to specify the order of products in a collection by various attributes such as title and date. To support this, a new component 'OrderByControl' has been created and included in the product collection inspector. Additionally, the types for 'order' and 'orderBy' attributes have been updated and exported for reuse.
Configuration menu - View commit details
-
Copy full SHA for e03ecf6 - Browse repository at this point
Copy the full SHA e03ecf6View commit details -
Merge branch 'trunk' of https://github.com/woocommerce/woocommerce-bl…
…ocks into 9359-product-collection-editor-settings-order-by
Configuration menu - View commit details
-
Copy full SHA for 91b5cb4 - Browse repository at this point
Copy the full SHA 91b5cb4View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5e5c6b1 - Browse repository at this point
Copy the full SHA 5e5c6b1View commit details
Commits on May 17, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 9cfa07e - Browse repository at this point
Copy the full SHA 9cfa07eView commit details -
Add orderby handling on frontend & editor
The main changes include: 1. Added a new property 'isProductCollectionBlock' in the block.json to denote if a block is a product collection block. 2. In the ProductCollection PHP class, a new initialization function has been defined to hook into the WordPress lifecycle, register the block, and update the query based on this block. 3. Added methods to manage query parameters for both frontend rendering and the Editor. 4. Expanded allowed 'collection_params' for the REST API to include custom 'orderby' values. 5. Defined a function to build the query based on block attributes, filters, and global WP_Query. 6. Created utility functions to handle complex query operations such as merging queries, handling custom sort values, and merging arrays recursively. These improvements allow for more flexible and robust handling of product collections in both the front-end display and the WordPress editor. It also extends support for custom 'orderby' values in the REST API, which allows for more advanced sorting options in product collections.
Configuration menu - View commit details
-
Copy full SHA for 7954c13 - Browse repository at this point
Copy the full SHA 7954c13View commit details -
Configuration menu - View commit details
-
Copy full SHA for b756198 - Browse repository at this point
Copy the full SHA b756198View commit details
Commits on May 18, 2023
-
Configuration menu - View commit details
-
Copy full SHA for bed6be4 - Browse repository at this point
Copy the full SHA bed6be4View commit details
Commits on May 19, 2023
-
Merge branch 'trunk' of https://github.com/woocommerce/woocommerce-bl…
…ocks into 9361-product-collection-filters-on-sale
Configuration menu - View commit details
-
Copy full SHA for 724f894 - Browse repository at this point
Copy the full SHA 724f894View commit details -
Add 'on sale' filter and enhance settings management in product colle…
…ction block This commit introduces several changes to the product collection block. - First, it adds a new 'on sale' filter that can be used to display only the products that are currently on sale. - It also refactors the settings management in the product collection block to use the experimental ToolsPanel component from WordPress, which provides a more flexible and intuitive way to manage block settings. - It moves the 'Columns' control into the ToolsPanel, along with the 'Order by' control. - A new utility function `setQueryAttribute` is introduced to simplify setting nested query parameters. - The structure of the `ProductCollectionAttributes` and `ProductCollectionQuery` types have been adjusted to accommodate the changes. - Finally, it makes corresponding changes in the PHP part to handle the new 'on sale' query parameter. This should enhance the flexibility and user-friendliness of the product collection block.
Configuration menu - View commit details
-
Copy full SHA for e5a43cf - Browse repository at this point
Copy the full SHA e5a43cfView commit details
Commits on May 22, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 2e77956 - Browse repository at this point
Copy the full SHA 2e77956View commit details
Commits on May 24, 2023
-
Add stock status filter to WooCommerce product collection block
This commit introduces a stock status filter to the WooCommerce product collection block. The changes include: 1. Added the ability to filter products based on their stock status within the 'product-collection' block. A new stock status control is created within the inspector-controls of the block. 2. A new 'get_stock_status_query' function is introduced in 'ProductCollection.php' which returns a query for products depending on their stock status. Please note that the stock status filter will only appear in the experimental build for now.
Configuration menu - View commit details
-
Copy full SHA for a832d97 - Browse repository at this point
Copy the full SHA a832d97View commit details -
Refactor Stock Status control of Product Collection block
This commit refactors the Stock Status control. The changes aim to improve the code organization and make the behavior of the component more explicit. The key modifications are: 1. Moved stock status related constants and functions from `inspector-controls/utils.tsx` to `inspector-controls/constants.ts`. This is done to ensure that all constants and similar utility functions are organized in one place. 2. Updated `product-collection/index.tsx` to import `getDefaultStockStatuses` from `inspector-controls/constants` instead of `inspector-controls/utils`. 3. Updated `stock-status-control.tsx` to determine whether the stock status has value or not by comparing with the default stock statuses using `fastDeepEqual`. If the stock status control is deselected, it resets the stock status to the default statuses. These changes do not introduce any new functionalities, but improve the readability and maintainability of the code.
Configuration menu - View commit details
-
Copy full SHA for c4188da - Browse repository at this point
Copy the full SHA c4188daView commit details -
Configuration menu - View commit details
-
Copy full SHA for 2d5e3f9 - Browse repository at this point
Copy the full SHA 2d5e3f9View commit details
Commits on May 25, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 255b164 - Browse repository at this point
Copy the full SHA 255b164View commit details
Commits on May 26, 2023
-
Fix: Default values of attributes not saving as serialized block comment
This was happening because of this issue: WordPress/gutenberg#7342 Therefore, I had to use `useEffect` to set the default values of the attributes. Here is the list of changes I made: 1. Removed default values from `block.json` for `query`, `tagName`, and `displayLayout`. 2. Moved the default values to `constants.ts` and created a new object `DEFAULT_ATTRIBUTES` to store them. 3. Relocated `constants.ts` from `inspector-controls` to the parent directory. 4. Refactored `edit.tsx` to use `DEFAULT_ATTRIBUTES` from `constants.ts` to set default attributes using `useEffect`. 5. Removed the attributes assignment from `registerBlockType` in `index.tsx`. 6. Updated `columns-control.tsx`, `index.tsx`, `order-by-control.tsx`, and `stock-status-control.tsx` to import from the relocated `constants.ts`. 7. Updated `ProductCollectionAttributes` and `ProductCollectionQuery` in `types.ts` to include `tagName` and `isProductCollectionBlock` respectively. 8. Modified `ProductCollection.php` to match the updated `orderBy` key in the query parameter. This refactor enhances the readability of the code and reduces duplication by keeping all constants and default values in one place.
Configuration menu - View commit details
-
Copy full SHA for d1e29ef - Browse repository at this point
Copy the full SHA d1e29efView commit details -
Replace usage of 'statii' with 'statuses' in stock status handling
This commit replaces all instances of 'statii' with the correct term 'statuses' in the context of handling stock status. This change affects three files: 1. `assets/js/blocks/product-collection/inspector-controls/stock-status-control.tsx` - The term is corrected in a comment block. 2. `assets/js/blocks/product-collection/types.ts` - Updated the name of a variable in the `ProductCollectionQuery` interface. 3. `src/BlockTypes/ProductCollection.php` - Here, the term is replaced in several locations including variable names, comments and the method `get_stock_status_query`. This commit helps improve code readability and consistency across the repository.
Configuration menu - View commit details
-
Copy full SHA for 0c30f5b - Browse repository at this point
Copy the full SHA 0c30f5bView commit details -
Configuration menu - View commit details
-
Copy full SHA for c99646e - Browse repository at this point
Copy the full SHA c99646eView commit details