-
Notifications
You must be signed in to change notification settings - Fork 219
Product Gallery Block > Remove global variable overwrite and keep support for the Single Product Block. #9475
Product Gallery Block > Remove global variable overwrite and keep support for the Single Product Block. #9475
Conversation
…ock to continue to work within the Single Product template without any problems.
…k works as expected without the relying on the global product.
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
Size Change: 0 B Total Size: 1.08 MB ℹ️ View Unchanged
|
The Single Product Block uses the |
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.
Great work! LGTM!
Thanks for the review!
That's true, although nothing prevents the user from removing the product image block and adding the product gallery block instead. @gigitux out of curiosity: why are we using the product image block by default within the single product block? Shouldn't it be the gallery block, the same way the core's templates do for single products? |
I'm not able to add the Product Gallery block. Can you add it?
We decided to support, for now, only the Product Image block. When the Single Product block is out, we will add the support for the Product Gallery block. |
Yep: the block is available for adding on the inserter, the only limitation is that the editor preview is not displayed, but the block is rendered on the FE without any problems. |
This should be reconsidered, filter hooks like what is mentioned here (#9618) are broken because they were called in the equivalent template. Rolling out the initial blockified templates with the existing templates was done initially to preserve the most back-compat we could to help transition extension developers, etc. As an initial step here for fixing the global issue, would saving the global to a temporary variable and then restoring it generating the HTML have been sufficient? At some point we likely will move away from calling functions that just load the existing template parts but until then we need to keep the compatibility layer intact. |
This is a simplified version of #9458 aimed as a short-term solution for ensuring the
$product
global variable is not overwritten within the Product Gallery block while still keeping support for the (still experimental) Single Product block.While for the Add to Cart with Options block it was possible to simply ditch the call to the global variable (as visible on #9457), that's not the case for this block, as due to the nature of how the templates and functions are structured, not invoking global
$product
results in fatal errors even within the context of the single product template.With that said, a basic version of the following templates was added to the
ProductImageGallery
class:single-product/product-thumbnails.php
single-product/product-image.php
single-product/sale-flash.php
All hooks were deliberately removed in this first instance, more discussion and changes are expected to happen on #9458 later on.
Fixes #9453
Testing
User Facing Testing
WooCommerce Visibility
Performance Impact
Changelog