This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
Only allow one instance of the All Products block per page/post. #1383
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #1376
For background, see #1376. One problem we face in fixing this, is currently our implementation of All Products (and related filter blocks) doesn't really support multiple instances at the top level of the post_content. While we do have support for multiple instances, that must happen within a container block level otherwise there is no way to link various filter blocks to controlling the request for the All Products block. So currently, any blocks added to the top level context will inherit the same query context (which is "page") for all blocks added on the page. So if setting changes are made to one block, it will apply to all blocks linked to the same client data store (+ related requests for that specific data store) and context.
So, the only way we can have isolated settings per
All Products
block andFilter Block
variations is to have them within a container that defines the context (see #1261). That is something I don't think would be too hard to implement, and we will want to do it in a future iteration, but it'd be good to see if this is something even needed right away (by gauging response/feedback to the current blocks)?As a result, I think the short term fix here is to simply only allow one
All Products
block to be inserted at the top level page (and the same for filter blocks). The exception will be the attribute filter blocks because there may be more than one of them (for multiple attributes).To Test
Verify there can only be one instance of the following blocks added to a page/post:
Attribute Filter blocks can still have multiple instances added.
cc @pmcpinto, @jwold, @garymurray for your input on this solution for the WC 3.9 release. Do you have any concerns about this approach?