-
Notifications
You must be signed in to change notification settings - Fork 219
Check if the current theme has a product-archive block template in the absence of a product taxonomy block template. #5380
Check if the current theme has a product-archive block template in the absence of a product taxonomy block template. #5380
Conversation
Size Change: -189 B (0%) Total Size: 819 kB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this is testing well, thanks for investigating this issue @tjcafferkey!
One thing I noticed is that if I delete the Product Category and Product Tag templates from the theme, they still appear in the Template list as being owned by the theme:
If I try to edit them, the editor opens the Product Archive template. Can you reproduce it too? Maybe we need to limit the logic from this PR to only happen in the frontend?
I did this intentionally. If we limit this PR to on the frontend then:
I hope this makes sense. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope this makes sense.
Ah, right, I tested it again and it makes a lot of sense. Following my previous example, if I edit the Product Tag template, in the editor I see the Product Archive template, but any edit I do will only impact the Product Tag template. I missed that in my first review!
Btw, I left a couple of extra comments that I noticed during this second round of testing. 👇
src/Utils/BlockTemplateUtils.php
Outdated
$template->id = 'woocommerce//' . $template_file->slug; | ||
$template->theme = 'woocommerce/woocommerce'; | ||
$template->id = $template_is_from_theme ? strtolower( $theme_name ) . '//' . $template_file->slug : 'woocommerce//' . $template_file->slug; | ||
$template->theme = $template_is_from_theme ? $theme_name : 'woocommerce/woocommerce'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch Ive used TextDomain
instead of Name
instead and this fixes this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚢
…e absence of a product taxonomy block template. (#5380) * Add archive-product template into block template hieachy * Add archive-product condition to product tag block template render method * Move taxonomy hierarchy filter to WC core * Undo template amends * Duplicate the themes archive-product template if it has one for taxonomy block templates * Review feedback * Use TextDomain instead of Name * use correct if/else syntax * Remove unncessary boolean syntax
* Empty commit for release pull request * Fix saving WooCommerce templates in WP 5.9 beta 3 (#5408) * fix not found template for the template editor (#5425) * Check for woocommerce as the theme before rendering with a more user friendly plugin name (#5420) * Make it so WooCommerce template names are not editable (#5385) * Make it so WooCommerce template names is not editable * Remove source='plugin' from templates * Load required scripts in LegacyTemplate.php render method (#5346) * Fix reverting WC templates (#5342) * Update block theme conditionals in BlockTemplateController (#5335) * Check if the current theme has a product-archive block template in the absence of a product taxonomy block template. (#5380) * Add archive-product template into block template hieachy * Add archive-product condition to product tag block template render method * Move taxonomy hierarchy filter to WC core * Undo template amends * Duplicate the themes archive-product template if it has one for taxonomy block templates * Review feedback * Use TextDomain instead of Name * use correct if/else syntax * Remove unncessary boolean syntax * Update readme.txt for 6.5.1 changelog * Testing notes for 6.5.1 * Bumping version strings to new version. Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> Co-authored-by: Luigi Teschio <gigitux@gmail.com> Co-authored-by: Tom Cafferkey <tjcafferkey@gmail.com>
This change means that if a theme has a
product-archive.html
block template, but not more taxonomy specific ones we will use thearchive-product.html
template for taxonomy frontend instead of the Woo Blockstaxonomy-product_cat
/taxonomy-product_tag
files.Fixes #5230
Testing
Manual Testing
How to test the changes in this Pull Request:
To make this easier to test, add the following block markup to the following templates so you know which one is getting rendered:
woo-blocks/archive-product.html
woo-blocks/taxonomy-product_tag.html
woo-blocks/taxonomy-product_cat.html
woo-blocks/taxonomy-product_cat.html
is the template being used.woo-blocks/archive-product.html
intoblockbase/block-templates/
and change the markup you added above to say "Blockbase" instead of "Woo Blocks" so we can differentiate.archive-product.html
from Blockbase is being loaded.User Facing Testing
These are steps for user testing (where "user" is someone interacting with this change that is not editing any code).
Changelog