Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Make Active Filters work with PHP templates #6138

Closed
Aljullu opened this issue Mar 28, 2022 · 4 comments · Fixed by #6295
Closed

Make Active Filters work with PHP templates #6138

Aljullu opened this issue Mar 28, 2022 · 4 comments · Fixed by #6295
Assignees
Labels
block: active filters Issues related to the Active Filters block. focus: FSE Work related to prepare WooCommerce for FSE. type: enhancement The issue is a request for an enhancement.

Comments

@Aljullu
Copy link
Contributor

Aljullu commented Mar 28, 2022

Blocked by #6135, #6136 or #6137.

Currently, it's not possible to use the Active Filters block with PHP templates. That's because that block is designed to only work with the All Products block.

This issue is about updating it, so it can work with the Shop catalog template.

Take into account currently there isn’t a widget equivalent, so it might require some changes in WC core in order to get this block working with PHP templates. (That's why the estimate of this issue is higher than the one from similar issues)

To reproduce

  1. With a block theme, go to Appearance > Editor > Template > Product Catalog.
  2. Add the Active Filters block above the product grid.
  3. Remove some of the selected values in the filter block
  4. Notice the products in the product grid don't update.

Expected behavior

The products in the product grid should update based on the removed filters.

@Aljullu Aljullu added type: enhancement The issue is a request for an enhancement. block: active filters Issues related to the Active Filters block. focus: FSE Work related to prepare WooCommerce for FSE. labels Mar 28, 2022
@gigitux gigitux assigned gigitux and unassigned gigitux Apr 11, 2022
@dinhtungdu dinhtungdu self-assigned this Apr 13, 2022
@dinhtungdu dinhtungdu assigned dinhtungdu and unassigned dinhtungdu Apr 14, 2022
@dinhtungdu
Copy link
Member

dinhtungdu commented Apr 14, 2022

Look like we're missing a use-case when we need the filter arguments injected to the URL for blocks.

For example, a page contains the All Products block with some filter blocks. If I set some filters and want to share the filtered results with my friends, it's impossible to do that now.

We're making the filter blocks work with PHP templates, we use URL as the bridge between those two. The URL can solve the issue I mentioned above: for products blocks, we can just update the URL without reloading the page. For PHP templates, we update the URL and reload the page as we do now.

For now, we're handling two cases separately based on the is_rendering_php_template value, which IMO, increases the complexity of the codebase. I think we can handle both block and PHP templates the same way and only reload the page if we're working with PHP templates.

@gigitux
Copy link
Contributor

gigitux commented Apr 14, 2022

@dinhtungdu Mmmm, good point. It can be a good time for refactoring the codebase around the filters that it seems a little bit tricky, at least for me.

@Aljullu what do you think?

@dinhtungdu
Copy link
Member

The #6252 is my take for this PR with our current direction used in other PRs. But I still think we should handle the URL change for both cases.

@gigitux
Copy link
Contributor

gigitux commented Apr 14, 2022

I'm working on #6137 with the current direction. The problem is that the current direction is easier to implement, but we will lose everything when we will blockify the template.

Maybe we could work on a refactor when we will blockify the template

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: active filters Issues related to the Active Filters block. focus: FSE Work related to prepare WooCommerce for FSE. type: enhancement The issue is a request for an enhancement.
Projects
None yet
3 participants