Add include/exclude category filters to the Product Categories block - #320
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Editors can now pick which product categories the block shows (include) and which to always hide (exclude), with nested parent/child categories shown as "Parent > Child" in the picker. When a category is listed in both, exclude wins. Default behaviour (no filters set) is unchanged. Closes #308 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
9697aa6 to
d7857b6
Compare
|
@Castellon-ACM revisas esto? P2 — El selector carga solo per_page=100; en tiendas con más de 100 categorías, las restantes no se pueden incluir ni excluir desde el editor. Debe paginar la REST API (o implementar una búsqueda remota). Ver línea 139. |
P1 — resolve_category_filters() returned both include and exclude empty when every included category was also excluded, which get_terms() reads as "no restriction" and shows every category instead of none. Fall back to include => [0] (never a valid term ID) in that case, so the query matches zero terms. Mirrored the same fix in the editor's preview query (frontblocks-product-categories-option.jsx) using the same include=0 sentinel, and updated the test that had asserted the old, buggy expectation. P2 — the include/exclude picker loaded a flat per_page=100 list of every store category up front, so categories beyond the first 100 could never be selected. Replaced that with: resolve only the categories already selected by ID (plus one extra round-trip for any unresolved parent, for "Parent > Child" labels), and a 250ms-debounced live search (REST `search` param, 20 results per keystroke) for the picker's suggestions. Works regardless of how many categories a store has. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Editors can now pick which product categories the block shows (include) and which to always hide (exclude), with nested parent/child categories shown as "Parent > Child" in the picker. When a category is listed in both, exclude wins. Default behaviour (no filters set) is unchanged.
Closes #308