Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Conversation

gigitux
Copy link
Contributor

@gigitux gigitux commented Feb 24, 2023

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
  1. With the Twenty Twenty-Three theme installed, go to Appearance » Editor.
  2. Edit the Product Catalog template, adding the Products block above the WooCommerce Product Grid Block.
  3. Save.
  4. Go to the front end and verify that the WooCommerce Product Grid Block is visible.
Single Product Template
  1. With the Twenty Twenty-Three theme installed, go to Appearance » Editor.
  2. Edit the Product Catalog template, adding the Product Image Gallery block above the WooCommerce Product Grid Block.
  3. Save.
  4. Go to the front end and verify that the WooCommerce Product Grid Block is visible.
  • Do not include in the Testing Notes

WooCommerce Visibility

  • WooCommerce Core
  • Feature plugin
  • Experimental

Performance Impact

…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
@gigitux gigitux added type: bug The issue/PR concerns a confirmed bug. skip-changelog PRs that you don't want to appear in the changelog. labels Feb 24, 2023
@gigitux gigitux self-assigned this Feb 24, 2023
@github-actions
Copy link
Contributor

Check this list before terminating the Blockfied Single P...

Check this list before terminating the Blockfied Single Product Template project.


// @TODO: Check this list before terminating the Blockfied Single Product Template project.
$single_product_template_blocks = array( 'woocommerce/product-image-gallery', 'woocommerce/product-details', 'woocommerce/add-to-cart-form' );
$wrapped_blocks = array_map(
function( $blocks ) use ( $single_product_template_blocks ) {
if ( 'core/template-part' === $blocks[0]['blockName'] ) {
return $blocks;
}
$has_single_product_template_blocks = self::has_single_product_template_blocks( $blocks, $single_product_template_blocks );
if ( $has_single_product_template_blocks ) {

🚀 This comment was generated by the automations bot based on a todo comment in 84783d9 in #8538. cc @gigitux

@woocommercebot woocommercebot requested review from a team and Aljullu and removed request for a team February 24, 2023 14:38
@github-actions
Copy link
Contributor

github-actions bot commented Feb 24, 2023

The release ZIP for this PR is accessible via:

https://wcblocks.wpcomstaging.com/wp-content/uploads/woocommerce-gutenberg-products-block-8538.zip

Script Dependencies Report

There is no changed script dependency between this branch and trunk.

This comment was automatically generated by the ./github/compare-assets action.

TypeScript Errors Report

  • Files with errors: 493
  • Total errors: 2340

🎉 🎉 This PR does not introduce new TS errors.

comments-aggregator

@github-actions
Copy link
Contributor

github-actions bot commented Feb 24, 2023

Size Change: 0 B

Total Size: 1.11 MB

ℹ️ View Unchanged
Filename Size
build/active-filters-frontend.js 7.98 kB
build/active-filters-wrapper-frontend.js 5.99 kB
build/active-filters.js 7.33 kB
build/all-products-frontend.js 11.7 kB
build/all-products.js 36.5 kB
build/all-reviews.js 7.66 kB
build/attribute-filter-frontend.js 22.4 kB
build/attribute-filter-wrapper-frontend.js 7.08 kB
build/attribute-filter.js 12.4 kB
build/blocks-checkout.js 41.2 kB
build/breadcrumbs.js 2.05 kB
build/cart-blocks/cart-accepted-payment-methods-frontend.js 1.38 kB
build/cart-blocks/cart-cross-sells-frontend.js 253 B
build/cart-blocks/cart-cross-sells-products-frontend.js 9.71 kB
build/cart-blocks/cart-express-payment--checkout-blocks/express-payment-frontend.js 5.19 kB
build/cart-blocks/cart-express-payment-frontend.js 720 B
build/cart-blocks/cart-items-frontend.js 299 B
build/cart-blocks/cart-line-items--mini-cart-contents-block/products-table-frontend.js 5.35 kB
build/cart-blocks/cart-line-items-frontend.js 1.06 kB
build/cart-blocks/cart-order-summary-frontend.js 1.24 kB
build/cart-blocks/cart-totals-frontend.js 322 B
build/cart-blocks/empty-cart-frontend.js 345 B
build/cart-blocks/filled-cart-frontend.js 655 B
build/cart-blocks/order-summary-coupon-form-frontend.js 1.62 kB
build/cart-blocks/order-summary-discount-frontend.js 2.12 kB
build/cart-blocks/order-summary-fee-frontend.js 274 B
build/cart-blocks/order-summary-heading-frontend.js 455 B
build/cart-blocks/order-summary-shipping-frontend.js 14.8 kB
build/cart-blocks/order-summary-subtotal-frontend.js 275 B
build/cart-blocks/order-summary-taxes-frontend.js 434 B
build/cart-blocks/proceed-to-checkout-frontend.js 1.24 kB
build/cart-frontend.js 28.9 kB
build/cart.js 47.4 kB
build/catalog-sorting.js 1.7 kB
build/checkout-blocks/actions-frontend.js 1.85 kB
build/checkout-blocks/billing-address--checkout-blocks/shipping-address-frontend.js 3.92 kB
build/checkout-blocks/billing-address-frontend.js 1.18 kB
build/checkout-blocks/contact-information-frontend.js 2.05 kB
build/checkout-blocks/express-payment-frontend.js 1.13 kB
build/checkout-blocks/fields-frontend.js 345 B
build/checkout-blocks/order-note-frontend.js 1.14 kB
build/checkout-blocks/order-summary-cart-items-frontend.js 3.67 kB
build/checkout-blocks/order-summary-coupon-form-frontend.js 1.79 kB
build/checkout-blocks/order-summary-discount-frontend.js 2.29 kB
build/checkout-blocks/order-summary-fee-frontend.js 276 B
build/checkout-blocks/order-summary-frontend.js 1.24 kB
build/checkout-blocks/order-summary-shipping-frontend.js 14.9 kB
build/checkout-blocks/order-summary-subtotal-frontend.js 275 B
build/checkout-blocks/order-summary-taxes-frontend.js 435 B
build/checkout-blocks/payment-frontend.js 8.43 kB
build/checkout-blocks/pickup-options-frontend.js 2.8 kB
build/checkout-blocks/shipping-address-frontend.js 1.14 kB
build/checkout-blocks/shipping-method-frontend.js 2.28 kB
build/checkout-blocks/shipping-methods-frontend.js 4.56 kB
build/checkout-blocks/terms-frontend.js 1.56 kB
build/checkout-blocks/totals-frontend.js 324 B
build/checkout-frontend.js 30.5 kB
build/checkout.js 44.2 kB
build/customer-account.js 3.08 kB
build/featured-category.js 13.5 kB
build/featured-product.js 13.7 kB
build/filter-wrapper-frontend.js 14.1 kB
build/filter-wrapper.js 2.39 kB
build/general-style-rtl.css 1.31 kB
build/general-style.css 1.31 kB
build/handpicked-products.js 7.24 kB
build/legacy-template.js 5.28 kB
build/mini-cart-component-frontend.js 28 kB
build/mini-cart-contents-block/empty-cart-frontend.js 366 B
build/mini-cart-contents-block/filled-cart-frontend.js 268 B
build/mini-cart-contents-block/footer-frontend.js 2.86 kB
build/mini-cart-contents-block/items-frontend.js 237 B
build/mini-cart-contents-block/products-table-frontend.js 589 B
build/mini-cart-contents-block/shopping-button-frontend.js 313 B
build/mini-cart-contents-block/title-frontend.js 367 B
build/mini-cart-contents.js 17.1 kB
build/mini-cart-frontend.js 2 kB
build/mini-cart.js 4.29 kB
build/price-filter-frontend.js 13.8 kB
build/price-filter-wrapper-frontend.js 6.99 kB
build/price-filter.js 8.39 kB
build/price-format.js 1.19 kB
build/product-add-to-cart--product-button--product-category-list--product-image--product-price--product-r--a0326d00.js 253 B
build/product-add-to-cart--product-button--product-image--product-rating--product-title.js 151 B
build/product-add-to-cart-frontend.js 6.71 kB
build/product-add-to-cart.js 8.61 kB
build/product-best-sellers.js 7.6 kB
build/product-button--product-category-list--product-image--product-price--product-rating--product-sale-b--e17c7c01.js 500 B
build/product-button--product-image--product-price--product-rating--product-sale-badge--product-title.js 262 B
build/product-button-frontend.js 2.22 kB
build/product-button.js 3.99 kB
build/product-categories.js 2.36 kB
build/product-category-list-frontend.js 1.19 kB
build/product-category-list.js 502 B
build/product-category.js 8.58 kB
build/product-image-frontend.js 2.23 kB
build/product-image.js 4.09 kB
build/product-new.js 7.58 kB
build/product-on-sale.js 7.91 kB
build/product-price-frontend.js 2.32 kB
build/product-price.js 1.58 kB
build/product-query.js 6.6 kB
build/product-rating-frontend.js 1.65 kB
build/product-rating.js 920 B
build/product-results-count.js 1.65 kB
build/product-sale-badge-frontend.js 1.45 kB
build/product-sale-badge.js 816 B
build/product-search.js 2.63 kB
build/product-sku-frontend.js 629 B
build/product-sku.js 378 B
build/product-stock-indicator-frontend.js 1.31 kB
build/product-stock-indicator.js 645 B
build/product-summary-frontend.js 1.58 kB
build/product-summary.js 920 B
build/product-tag-list-frontend.js 1.18 kB
build/product-tag-list.js 497 B
build/product-tag.js 8.07 kB
build/product-title-frontend.js 1.65 kB
build/product-title.js 3.46 kB
build/product-top-rated.js 7.82 kB
build/products-by-attribute.js 8.52 kB
build/rating-filter-frontend.js 20.9 kB
build/rating-filter-wrapper-frontend.js 5.61 kB
build/rating-filter.js 7.42 kB
build/reviews-by-category.js 11.2 kB
build/reviews-by-product.js 12.3 kB
build/reviews-frontend.js 7.14 kB
build/single-product-frontend.js 17.9 kB
build/single-product.js 9.94 kB
build/stock-filter-frontend.js 21.1 kB
build/stock-filter-wrapper-frontend.js 5.85 kB
build/stock-filter.js 8.14 kB
build/store-notices.js 1.69 kB
build/vendors--attribute-filter-wrapper--cart-blocks/cart-cross-sells-products--cart-blocks/order-summary--82e4ed06-frontend.js 6.86 kB
build/vendors--attribute-filter-wrapper--rating-filter-wrapper--stock-filter-wrapper-frontend.js 7.69 kB
build/vendors--cart-blocks/cart-cross-sells-products--cart-blocks/cart-line-items--cart-blocks/cart-order--3c5fe802-frontend.js 5.26 kB
build/vendors--cart-blocks/cart-cross-sells-products--cart-blocks/order-summary-shipping--checkout-blocks--18f9376a-frontend.js 19.4 kB
build/vendors--cart-blocks/cart-cross-sells-products--product-add-to-cart-frontend.js 7.25 kB
build/vendors--cart-blocks/cart-line-items--checkout-blocks/order-summary-cart-items--mini-cart-contents---233ab542-frontend.js 3.14 kB
build/vendors--cart-blocks/order-summary-shipping--checkout-blocks/billing-address--checkout-blocks/order--5b8feb0b-frontend.js 4.83 kB
build/vendors--checkout-blocks/shipping-method-frontend.js 12 kB
build/vendors--checkout-blocks/shipping-methods-frontend.js 8.84 kB
build/wc-blocks-data.js 21.5 kB
build/wc-blocks-editor-style-rtl.css 5.72 kB
build/wc-blocks-editor-style.css 5.73 kB
build/wc-blocks-google-analytics.js 1.56 kB
build/wc-blocks-middleware.js 933 B
build/wc-blocks-registry.js 3.15 kB
build/wc-blocks-shared-context.js 1.52 kB
build/wc-blocks-shared-hocs.js 1.73 kB
build/wc-blocks-style-rtl.css 26.7 kB
build/wc-blocks-style.css 26.7 kB
build/wc-blocks-vendors-style-rtl.css 1.96 kB
build/wc-blocks-vendors-style.css 1.96 kB
build/wc-blocks-vendors.js 64.4 kB
build/wc-blocks.js 2.63 kB
build/wc-payment-method-bacs.js 816 B
build/wc-payment-method-cheque.js 811 B
build/wc-payment-method-cod.js 909 B
build/wc-payment-method-paypal.js 837 B
build/wc-settings.js 2.6 kB
build/wc-shipping-method-pickup-location.js 29.7 kB
build/woo-directives-runtime.js 2.52 kB
build/woo-directives-vendors.js 7.91 kB

compressed-size-action

…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
@gigitux gigitux force-pushed the 8505-the-woocommerce-product-grid-block-block-is-not-visible-on-the-front-end-when-the-products-block-is-on-the-same-page branch from cbc4963 to 1d71030 Compare February 24, 2023 16:37
…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
Copy link
Contributor

@Aljullu Aljullu left a 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* This hooks allows to disable the compatibility layer for the blockified.
* This hook allows to disable the compatibility layer for the blockified templates.

Comment on lines 331 to 334
if ( ! is_admin() && BlockTemplateUtils::template_has_legacy_template_block( $template ) ) {
add_filter( 'woocommerce_disable_compatibility_layer', '__return_true' );
return $template;
}
Copy link
Contributor

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 );
Copy link
Contributor

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?

Suggested change
$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
@gigitux gigitux changed the base branch from trunk to add/compatibility-single-product-block February 28, 2023 11:06
@gigitux gigitux force-pushed the 8505-the-woocommerce-product-grid-block-block-is-not-visible-on-the-front-end-when-the-products-block-is-on-the-same-page branch from d37417a to 18ba63b Compare February 28, 2023 11:09
@gigitux gigitux force-pushed the add/compatibility-single-product-block branch from 1f53ac2 to 1face07 Compare February 28, 2023 11:10
…oocommerce-product-grid-block-block-is-not-visible-on-the-front-end-when-the-products-block-is-on-the-same-page
@gigitux gigitux changed the title Disable compatibility layer when the WooCommerce Product Grid Block block is used Disable compatibility layer when the WooCommerce Product Grid Block block and WooCommerce Single Product Block are used Feb 28, 2023
@gigitux
Copy link
Contributor Author

gigitux commented Feb 28, 2023

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).

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!

@gigitux gigitux requested a review from Aljullu February 28, 2023 11:16
Copy link
Contributor

@Aljullu Aljullu left a 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? 🤔

@gigitux
Copy link
Contributor Author

gigitux commented Feb 28, 2023

Thanks for the review!

After your last commits, this PR only includes changes to the docs/comments, is that correct or I'm missing anything?

Yep, it is correct. We move these hooks from BlockTemplatesCompatbility.php to AbstractTemplatesCompatbility.php.

If so, LGTM, but then maybe we should check Do not include in the Testing Notes? 🤔

👍

@gigitux gigitux merged commit ab3192b into add/compatibility-single-product-block Feb 28, 2023
@gigitux gigitux deleted the 8505-the-woocommerce-product-grid-block-block-is-not-visible-on-the-front-end-when-the-products-block-is-on-the-same-page branch February 28, 2023 15:04
gigitux added a commit that referenced this pull request Feb 28, 2023
* 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>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
skip-changelog PRs that you don't want to appear in the changelog. type: bug The issue/PR concerns a confirmed bug.
Projects
None yet
2 participants