Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make templates fallback methods template-agnostic #46372

Draft
wants to merge 7 commits into
base: trunk
Choose a base branch
from

Conversation

Aljullu
Copy link
Contributor

@Aljullu Aljullu commented Apr 9, 2024

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:

  • Gets rid of the 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.
  • Refactors all templates_is_eligible_for_product_archive_fallback... methods to be template-agnostic, that means removing product_archive from the method name and checking for the template_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:

  1. Go to Appearance > Editor and make some edits to the Product Catalog and Products by Category template.
  2. Go to the Shop page in the frontend (/shop) and verify the edits you did in the Product Catalog template are visible.
  3. Go to a category page in the frontend (ie: /product-category/clothing) and verify the edits you did in the Products by Category template are visible.
  4. Go to a tag page in the frontend (ie: /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.
  5. Revert the editions.
  6. Visit the frontend pages again and verify there are no edits.

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Comment

@Aljullu Aljullu added the focus: template Issue related to WooCommerce templates. label Apr 9, 2024
@Aljullu Aljullu self-assigned this Apr 9, 2024
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Apr 9, 2024
@Aljullu Aljullu force-pushed the fix/agnostic-fallback-methods branch 3 times, most recently from 6beeec1 to fa06367 Compare April 12, 2024 10:30
@Aljullu Aljullu force-pushed the fix/agnostic-fallback-methods branch from fa06367 to 41e6ba3 Compare April 24, 2024 13:58
@Aljullu Aljullu force-pushed the fix/agnostic-fallback-methods branch from 41e6ba3 to 44aa8e2 Compare April 25, 2024 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: template Issue related to WooCommerce templates. plugin: woocommerce Issues related to the WooCommerce Core plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant