Make templates fallback methods template-agnostic #46372
Draft
+62
−51
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.
In #44778 we are working on a refactor that will simplify how templates that fall back to another template work (aka Products by Category/Tag/Attribute falling back to the Product Catalog template when they haven't been customized).
Unfortunately, that PR has some upstream blockers, so it's unlikely that we will be able to merge it anytime soon. So I'm creating this PR to port some improvements from that PR into
trunk
.Specifically, this PR:
template_is_eligible_for_product_archive_fallback()
method, as knowing if a template is elligible for fallback is as easy as checking if$template->template_fallback
exists.templates_is_eligible_for_product_archive_fallback...
methods to be template-agnostic, that means removingproduct_archive
from the method name and checking for thetemplate_fallback
property, instead of only checking for the Product Catalog slug.Submission Review Guidelines:
Changes proposed in this Pull Request:
Part of #42251.
How to test the changes in this Pull Request:
This PR doesn't change the behavior of how WooCommerce templates currently work in the Site Editor. Hopefully any issues would be evident (ie: a PHP fatal) or would be caught by e2e tests, but in any case, in order to do some smoke testing:
/shop
) and verify the edits you did in the Product Catalog template are visible./product-category/clothing
) and verify the edits you did in the Products by Category template are visible./product-tag/recommended
, note: you might need to create the tag first from Products > Tags) and verify the edits you did in the Product Catalog template are visible.Changelog entry
Significance
Type
Message
Comment