Closed Aljullu closed 2 years ago
After testing removing the filter added in woocommerce/woocommerce#30138 against the latest trunk
of woocommerce-gutenberg-products-block
, I found:
single-product
template should be removed from the template dropdown.
Following the steps above, after removing the filter, the template dropdown contains two options: Default template
and Product page
. They have the same effect because the single-product.html
template in the theme overrides the one from the plugin and becomes the default template.archive-product,
taxonomy-prouduct_cat
, and taxonomy-product_tag
) need to be registered in theme.json
without setting postTypes
to avoid being included in the template dropdown.So for now, IMO, what we can do is replace the filter added in woocommerce/woocommerce#30138 with another filter that removes only the single-product
template.
The one that's holding me from removing the filter is the custom templates created in the Template Editor. Users should have the ability to limit the template to post types or specific pages. Currently, all custom templates are available for all post types that support page templates.
After discussing this issue on Slack, we agree to address this issue in Store Editing Templates project v2.
Some notes from the discussion:
Related to display conditions:
Albert Juhé Lluveras: we might want to check with Gutenberg developers to know what they think about this. I found some discussion on this here, but I'm not sure to understand the resolution.
Tung Du: From another perspective, all custom templates created in the Template Editors are user-created content, so it should be users’ responsibility to “not surprised” if there are some un-related templates in the dropdown. But it’s a bad UX IMO, users should be able to choose the display condition at least, then it’s up to them to do that or not. Extending the above point, I even think that custom templates created in the Template Editor must have display conditions to be included in the dropdown. It means that we can filter out all templates that aren't assigned to the current post type. But it also means that we will remove all user-created templates.
Related to default template:
Albert Juhé Lluveras: Just a note on that, which is something we need to keep in mind for the testing phase. The same rules from PHP templating from WP apply to block templates. That means that it's possible to have a single-product-hoodie template that would be applied to the Hoodie product. I'm not sure if that actually works right now, but wanted to bring it here because in some cases, "Default template" and single-product might be different. So in those cases we might want to display both in the selector.
Tung Du: We can extend the template registration in theme.json to support category/tag, etc. Then we can share the same display conditions logic between Template Editor and theme.json.
This issue has been marked as stale
because it has not seen any activity within the past 60 days. Our team uses this tool to help surface issues for review. If you are the author of the issue there's no need to comment as it will be looked at.
This issue has been marked as stale
because it has not seen any activity within the past 60 days. Our team uses this tool to help surface issues for review. If you are the author of the issue there's no need to comment as it will be looked at.
In preparation for WP 5.8, we disabled the option to change the block template of each individual product (see https://github.com/woocommerce/woocommerce/pull/30138).
That decision was based on a couple of reasons:
Given that the first issue has been solved and the second issue will be solved, we should evaluate whether we can revert that change.
To reproduce
single-product.html
template in/my-theme/block-templates/single-product.html
:theme.json
: