-
Notifications
You must be signed in to change notification settings - Fork 219
Disable compatibility layer when the WooCommerce Product Grid Block block and WooCommerce Single Product Block are used #8538
Disable compatibility layer when the WooCommerce Product Grid Block block and WooCommerce Single Product Block are used #8538
Conversation
…oocommerce-product-grid-block-block-is-not-visible-on-the-front-end-when-the-products-block-is-on-the-same-page
…ocks into 8505-the-woocommerce-product-grid-block-block-is-not-visible-on-the-front-end-when-the-products-block-is-on-the-same-page
Check this list before terminating the Blockfied Single P...Check this list before terminating the Blockfied Single Product Template project.
woocommerce-blocks/src/Templates/SingleProductTemplateCompatibility.php Lines 234 to 245 in 84783d9
🚀 This comment was generated by the automations bot based on a
|
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.11 MB ℹ️ View Unchanged
|
…ub.com/woocommerce/woocommerce-blocks into 8505-the-woocommerce-product-grid-block-block-is-not-visible-on-the-front-end-when-the-products-block-is-on-the-same-page
…ub.com/woocommerce/woocommerce-blocks into 8505-the-woocommerce-product-grid-block-block-is-not-visible-on-the-front-end-when-the-products-block-is-on-the-same-page
cbc4963
to
1d71030
Compare
…ub.com/woocommerce/woocommerce-blocks into 8505-the-woocommerce-product-grid-block-block-is-not-visible-on-the-front-end-when-the-products-block-is-on-the-same-page
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 can confirm this PR removes the compatibility later from the Products block and Single Product Template blocks when the Classic block exists in the page. However, for me it didn't fix #8505. Is this a known issue? I see #8550 fixes it, but I'm not sure to understand the relation between both PRs. 😕
I would also update the PR title because currently only makes reference to the Product Grid, but the changes introduced also work in the Single Product template.
Besides that, I just left some small comments below (some of them are applicable to #8550 as well).
/** | ||
* Filters to disable the compatibility layer for the blockified templates. | ||
* | ||
* This hooks allows to disable the compatibility layer for the blockified. |
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.
* This hooks allows to disable the compatibility layer for the blockified. | |
* This hook allows to disable the compatibility layer for the blockified templates. |
src/BlockTemplatesController.php
Outdated
if ( ! is_admin() && BlockTemplateUtils::template_has_legacy_template_block( $template ) ) { | ||
add_filter( 'woocommerce_disable_compatibility_layer', '__return_true' ); | ||
return $template; | ||
} |
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.
Nit: this if
clause is the same here and in line 339-342. I wonder if it would make sense to move it before their parent if clauses, in line 328, so we avoid repeating it.
return $block_content; | ||
} | ||
|
||
$this->inject_hooks( $block_content, $block ); |
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.
Should this value be returned as well?
$this->inject_hooks( $block_content, $block ); | |
return $this->inject_hooks( $block_content, $block ); |
…ub.com/woocommerce/woocommerce-blocks into 8505-the-woocommerce-product-grid-block-block-is-not-visible-on-the-front-end-when-the-products-block-is-on-the-same-page
…ub.com/woocommerce/woocommerce-blocks into 8505-the-woocommerce-product-grid-block-block-is-not-visible-on-the-front-end-when-the-products-block-is-on-the-same-page
d37417a
to
18ba63b
Compare
1f53ac2
to
1face07
Compare
…oocommerce-product-grid-block-block-is-not-visible-on-the-front-end-when-the-products-block-is-on-the-same-page
Thanks for the review, @Aljullu! I updated the PR title. Also, I refactored this PR after the work that I did on #8505. In the end, it is the same solution. Also, I changed the destination branch to add/compatibility-single-product-block, so the diff is smaller. When you will approve this PR, I will merge #8442 in the trunk! |
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.
After your last commits, this PR only includes changes to the docs/comments, is that correct or I'm missing anything?
If so, LGTM, but then maybe we should check Do not include in the Testing Notes
? 🤔
Thanks for the review!
Yep, it is correct. We move these hooks from
👍 |
* Add minimum structure for Single Product Details block * Add Product Image Gallery #8233 Add Product Image Gallery * Add tests for Single Product Details block * Add the initial basis for the Add to Cart button * Trigger the single product add to cart action for each product type. * wip: create block structure and add initial styles * Add block details to the SingleProductDetails.php file * Rename the block from add-to-cart-button to add-to-cart-form * Update to use the cart icon. * Implement the skeleton for the editor preview. * Render tabs title with empty content * Use woocommerce_output_product_data_tabs function to retrieve tabs data * Update styles and add Notice for the display in the Editor. * Update CSS. * Add base tests for the new Add to Cart Form component. * Add Product Image Gallery block * remove support global styles * remove support global styles * Update the button CSS. * Remove customizations for the Single Product Details block * Update styles for the cart form. * update td style. * Update divs and CSS. * Use conventional input instead of the experimental InputControl * address CSS feedback * add support for the custom classname * remove save function * Remove unnecessary console.log from the Edit.tsx file * Remove block classname from block wrapper * Remove unnecessary WooCommerce tabs filter from the BlockTemplatesController * Remove attributes property from the block registration * Remove isExperimental flag for the Single Product Details block * Remove get_classes_and_styles_by_attributes method from SingleProductDetails block * Prevent Single Product Details block from apppearing in Pages or Posts * add second parameter to the subscribe function * Implement the new design and copy provided for the editor. * Make the notice compatible with dark themes. * Some additional CSS tweaks * adjust the padding for the input * wrap the Single Product Template in a div with the product class * Fix PHP Coding Standards warnings * improve logic and increase coverage of unit test * improve logic and increase coverage of unit test * fix test * format HTML * fix edge case * update @types/wordpress__data package * update placeholder, icon and description * update tsconfig * update block name * fix SCSS linter error * address feedback * create SingleProductTemplateCompatibility class * Add Hooks compatibility * remove not used file * remove not used files * Add compatibility layer for the Single Product template * fix check * address feedback * remove unused import * double empty line * remove logic in the constructor * remove hook * generate the docs * add missing hooks * fix docs * address feedback * fix linter * fix import * Disable compatibility layer when the WooCommerce Product Grid Block block and WooCommerce Single Product Block are used (#8538) * disable compatibility layer via hook * update docs * generate the docs * fix version * fix import * fix code after merge --------- Co-authored-by: Alexandre Lara <allexandrelara@gmail.com> Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com>
This PR introduces a new filter called
woocommerce_disable_compatibility_layer
that allows disabling the compatibility layer.At the same time, using the filter, the compatibility layer is disabled when Archive Product templates and Single Product template have the WooCommerce Product Grid Block.
This PR is blocked by #8442
Fixes #8505
Testing
User Facing Testing
Archive Templates
Appearance » Editor
.WooCommerce Product Grid Block
is visible.Single Product Template
Appearance » Editor
.Product Image Gallery block
above the WooCommerce Product Grid Block.WooCommerce Product Grid Block
is visible.WooCommerce Visibility
Performance Impact