-
Notifications
You must be signed in to change notification settings - Fork 219
Fix corrupt Classic Template placeholders for specific products. #7033
Conversation
…st matching template details
The release ZIP for this PR is accessible via:
|
Size Change: +93 B (0%) Total Size: 871 kB
ℹ️ View Unchanged
|
… for specific template names
@sunyatasattva do you know why these E2E tests would fail with Gutenberg enabled? The Snapshots should not have changed in theory so I'm not convinced they're related to this change but wanted to get your opinion on this to make sure. |
FWIW, I'm seeing the exact same task failing in all of my currently open PRs. |
Yea looks like snapshots have changed, possibly Gutenberg related, and we can just update. At a first glance, I don't see anything too worrisome. It looks like there is an extra container div within the group? |
// Finds the most appropriate template details object for specific template keys such as single-product-hoodie. | ||
export function getTemplateDetailsBySlug( | ||
parsedTemplate: string, | ||
templates: TemplateDetails |
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.
Do these functions really need to accept a second argument for templates
? Is there a circumstance in which we won't use TEMPLATES
from constants
as this second argument?
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.
@sunyatasattva I intentionally made this a pure function. I find they're easier to read, reuse and predict. Also much easier to unit test (and debug should those tests fail)
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.
Alright then! Everything else looks good to me.
…commerce#7033) * If user has created a template for a specific product, find the closest matching template details * Move Classic Template functions into Utils file and refactor function for specific template names * Classic Template utils refactor and unit tests
When using the Gutenberg plugin, you can create specific templates for products, categories and tags via the Appearance > Editor > Add New button. At the moment in the code for the Classic Template Block placeholder we don't accommodate for these specific slugs e.g.
single-product-hoodie
so we get an unsupported block notice in the editor as seen below.This PR introduces a change finds the closest matching template. For example
single-product-hoodie
will match the template details forsingle-product
(and the same for product categories/tags too).Accessibility
prefers-reduced-motion
Other Checks
Screenshots
Testing
Automated Tests
User Facing Testing
Reproduce the original issue:
Test the fix:
WooCommerce Visibility
Performance Impact
Changelog