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

Update the archive templates to use Products block #8308

Merged
merged 12 commits into from
Feb 22, 2023
Merged

Update the archive templates to use Products block #8308

merged 12 commits into from
Feb 22, 2023

Conversation

dinhtungdu
Copy link
Member

@dinhtungdu dinhtungdu commented Jan 27, 2023

Fixes #8067

In this PR:

  • We update the blockified archive-product.html and product-search-results.html templates to use the Products block instead of a placeholder.
  • To achieve a closer structure to the PHP template (for better compatibility), the Products block now wraps other blocks. Thanks to this, we can support woocommerce_archive_description hook now.
  • Two new patterns are added: No Products Found and Product Search Form. We need patterns to support i18n.
  • Archive templates that are fallback to archive-product.html remain unchanged in favor of Remove unused archive templates woocommerce#42481

Accessibility

Other Checks

  • This PR adds/removes a feature flag & I've updated this doc.
  • This PR adds/removes an experimental interfaces and I've updated this doc.
  • I tagged two reviewers because this PR makes queries to the database or I think it might have some security impact.

Screenshots

Before After
image image
image image

Testing

Automated Tests

  • Changes in this PR are covered by Automated Tests.
    • Unit tests
    • E2E tests

User Facing Testing

  1. Activate a block theme (TT3),
  2. [Prerequisite] Reset customization made to Product Catalog and Product Search Results templates.
  3. Uncomment this and these lines (don't forget to remove the trailing dot)
  4. Activate the Storefront theme.
  5. Active the block theme again. See Add migration strategy and load blockified templates #6538 for why we need this.
  6. See new templates work in the Site Editor and on the front end.
  • Do not include in the Testing Notes

WooCommerce Visibility

  • WooCommerce Core
  • Feature plugin
  • Experimental

Performance Impact

Changelog

Update the blockified archive templates to use the Products block.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 27, 2023

The release ZIP for this PR is accessible via:

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

Script Dependencies Report

The compare-assets action has detected some changed script dependencies between this branch and trunk. Please review and confirm the following are correct before merging.

Script Handle Added Removed
reviews-frontend.js react, wc-settings, wp-a11y, wp-api-fetch, wp-compose, wp-element, wp-i18n, wp-is-shallow-equal, wp-polyfill ⚠️
active-filters-frontend.js lodash, react, wc-blocks-data-store, wc-price-format, wc-settings, wp-data, wp-element, wp-html-entities, wp-i18n, wp-is-shallow-equal, wp-polyfill, wp-primitives, wp-url ⚠️
all-products-frontend.js lodash, react, wc-blocks-checkout, wc-blocks-data-store, wc-blocks-registry, wc-blocks-shared-context, wc-blocks-shared-hocs, wc-price-format, wc-settings, wp-a11y, wp-api-fetch, wp-autop, wp-block-editor, wp-blocks, wp-compose, wp-data, wp-deprecated, wp-dom, wp-element, wp-hooks, wp-html-entities, wp-i18n, wp-is-shallow-equal, wp-polyfill, wp-primitives, wp-url, wp-warning, wp-wordcount ⚠️
attribute-filter-frontend.js lodash, react, wc-blocks-checkout, wc-blocks-data-store, wc-settings, wp-a11y, wp-block-editor, wp-blocks, wp-compose, wp-data, wp-deprecated, wp-dom, wp-element, wp-html-entities, wp-i18n, wp-is-shallow-equal, wp-keycodes, wp-polyfill, wp-primitives, wp-url, wp-warning ⚠️
cart-frontend.js lodash, react, wc-blocks-checkout, wc-blocks-data-store, wc-blocks-registry, wc-blocks-shared-context, wc-blocks-shared-hocs, wc-price-format, wc-settings, wp-a11y, wp-api-fetch, wp-autop, wp-block-editor, wp-blocks, wp-compose, wp-data, wp-deprecated, wp-dom, wp-element, wp-hooks, wp-html-entities, wp-i18n, wp-is-shallow-equal, wp-keycodes, wp-plugins, wp-polyfill, wp-primitives, wp-url, wp-warning, wp-wordcount ⚠️
checkout-frontend.js lodash, react, wc-blocks-checkout, wc-blocks-data-store, wc-blocks-registry, wc-blocks-shared-hocs, wc-price-format, wc-settings, wp-a11y, wp-api-fetch, wp-autop, wp-compose, wp-data, wp-deprecated, wp-dom, wp-element, wp-hooks, wp-html-entities, wp-i18n, wp-is-shallow-equal, wp-keycodes, wp-plugins, wp-polyfill, wp-primitives, wp-url, wp-warning, wp-wordcount ⚠️
filter-wrapper-frontend.js lodash, react, wc-blocks-checkout, wc-blocks-data-store, wc-blocks-registry, wc-price-format, wc-settings, wp-a11y, wp-block-editor, wp-blocks, wp-compose, wp-data, wp-deprecated, wp-dom, wp-element, wp-html-entities, wp-i18n, wp-is-shallow-equal, wp-keycodes, wp-polyfill, wp-primitives, wp-url, wp-warning ⚠️
mini-cart-frontend.js wc-settings, wp-polyfill ⚠️
price-filter-frontend.js lodash, react, wc-blocks-data-store, wc-price-format, wc-settings, wp-data, wp-element, wp-i18n, wp-is-shallow-equal, wp-polyfill, wp-url ⚠️
rating-filter-frontend.js lodash, react, wc-blocks-checkout, wc-blocks-data-store, wc-settings, wp-a11y, wp-block-editor, wp-blocks, wp-compose, wp-data, wp-deprecated, wp-dom, wp-element, wp-i18n, wp-is-shallow-equal, wp-keycodes, wp-polyfill, wp-primitives, wp-url, wp-warning ⚠️
single-product-frontend.js lodash, react, wc-blocks-checkout, wc-blocks-data-store, wc-blocks-registry, wc-blocks-shared-context, wc-blocks-shared-hocs, wc-price-format, wc-settings, wp-api-fetch, wp-autop, wp-block-editor, wp-blocks, wp-compose, wp-data, wp-deprecated, wp-dom, wp-element, wp-hooks, wp-html-entities, wp-i18n, wp-is-shallow-equal, wp-polyfill, wp-primitives, wp-url, wp-warning, wp-wordcount ⚠️
stock-filter-frontend.js lodash, react, wc-blocks-checkout, wc-blocks-data-store, wc-settings, wp-a11y, wp-block-editor, wp-blocks, wp-compose, wp-data, wp-deprecated, wp-dom, wp-element, wp-html-entities, wp-i18n, wp-is-shallow-equal, wp-keycodes, wp-polyfill, wp-primitives, wp-url, wp-warning ⚠️
mini-cart-component-frontend.js lodash, react, wc-blocks-checkout, wc-blocks-data-store, wc-blocks-registry, wc-price-format, wc-settings, wp-a11y, wp-autop, wp-compose, wp-data, wp-deprecated, wp-dom, wp-element, wp-hooks, wp-html-entities, wp-i18n, wp-is-shallow-equal, wp-keycodes, wp-polyfill, wp-primitives, wp-url, wp-warning, wp-wordcount ⚠️

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

TypeScript Errors Report

  • Files with errors: 492
  • Total errors: 2339

🎉 🎉 This PR does not introduce new TS errors.

comments-aggregator

@github-actions
Copy link
Contributor

github-actions bot commented Jan 27, 2023

Size Change: +38 B (0%)

Total Size: 1.1 MB

Filename Size Change
build/store-notices.js 1.69 kB +38 B (+2%)
ℹ️ 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.32 kB
build/add-to-cart-form.js 1.48 kB
build/all-products-frontend.js 11.7 kB
build/all-products.js 34.6 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.04 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.67 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 321 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 274 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.3 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.78 kB
build/checkout-blocks/order-summary-discount-frontend.js 2.29 kB
build/checkout-blocks/order-summary-fee-frontend.js 277 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 434 B
build/checkout-blocks/payment-frontend.js 8.44 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.27 kB
build/checkout-blocks/shipping-methods-frontend.js 4.78 kB
build/checkout-blocks/terms-frontend.js 1.56 kB
build/checkout-blocks/totals-frontend.js 324 B
build/checkout-frontend.js 30.4 kB
build/checkout.js 43.9 kB
build/customer-account.js 3.12 kB
build/featured-category.js 13.4 kB
build/featured-product.js 13.6 kB
build/filter-wrapper-frontend.js 14 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 2.85 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 590 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.3 kB
build/price-filter-frontend.js 13.8 kB
build/price-filter-wrapper-frontend.js 6.99 kB
build/price-filter.js 8.38 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 496 B
build/product-button--product-image--product-price--product-rating--product-sale-badge--product-title.js 259 B
build/product-button-frontend.js 2.19 kB
build/product-button.js 4 kB
build/product-categories.js 2.36 kB
build/product-category-list-frontend.js 1.19 kB
build/product-category-list.js 503 B
build/product-category.js 8.58 kB
build/product-image-frontend.js 2.2 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.29 kB
build/product-price.js 1.58 kB
build/product-query.js 6.08 kB
build/product-rating-frontend.js 1.62 kB
build/product-rating.js 919 B
build/product-results-count.js 1.65 kB
build/product-sale-badge-frontend.js 1.43 kB
build/product-sale-badge.js 819 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.32 kB
build/product-stock-indicator.js 645 B
build/product-summary-frontend.js 1.58 kB
build/product-summary.js 919 B
build/product-tag-list-frontend.js 1.18 kB
build/product-tag-list.js 497 B
build/product-tag.js 8.06 kB
build/product-title-frontend.js 1.62 kB
build/product-title.js 3.46 kB
build/product-top-rated.js 7.83 kB
build/products-by-attribute.js 8.53 kB
build/rating-filter-frontend.js 20.9 kB
build/rating-filter-wrapper-frontend.js 5.61 kB
build/rating-filter.js 7.41 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.8 kB
build/single-product.js 9.98 kB
build/stock-filter-frontend.js 21.1 kB
build/stock-filter-wrapper-frontend.js 5.85 kB
build/stock-filter.js 8.12 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 9.44 kB
build/wc-blocks-data.js 21.4 kB
build/wc-blocks-editor-style-rtl.css 5.68 kB
build/wc-blocks-editor-style.css 5.68 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.65 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

@dinhtungdu
Copy link
Member Author

In 001685f, I reverted changes made to some archive templates that are fallback to archive-product in favor of woocommerce/woocommerce#42481

@dinhtungdu dinhtungdu added focus: FSE Work related to prepare WooCommerce for FSE. focus: template Related to API powering block template functionality in the Site Editor labels Jan 30, 2023
@dinhtungdu dinhtungdu marked this pull request as ready for review January 30, 2023 12:01
@woocommercebot woocommercebot requested review from a team and tjcafferkey and removed request for a team January 30, 2023 12:01
* Inserter: no
*/
?>
<!-- wp:search {"label":"<?php echo esc_html_x( 'Search', 'label', 'woo-gutenberg-products-block' ); ?>","showLabel":false,"placeholder":"<?php echo esc_attr_x( 'Search products…', 'placeholder for search field', 'woo-gutenberg-products-block' ); ?>","buttonText":"<?php esc_attr_e( 'Search', 'woo-gutenberg-products-block' ); ?>","query":{"post_type":"product"}} /-->
Copy link
Contributor

Choose a reason for hiding this comment

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

Considering "showLabel":false, you can skip providing a label:

Suggested change
<!-- wp:search {"label":"<?php echo esc_html_x( 'Search', 'label', 'woo-gutenberg-products-block' ); ?>","showLabel":false,"placeholder":"<?php echo esc_attr_x( 'Search products…', 'placeholder for search field', 'woo-gutenberg-products-block' ); ?>","buttonText":"<?php esc_attr_e( 'Search', 'woo-gutenberg-products-block' ); ?>","query":{"post_type":"product"}} /-->
<!-- wp:search {"showLabel":false,"placeholder":"<?php echo esc_attr_x( 'Search products…', 'placeholder for search field', 'woo-gutenberg-products-block' ); ?>","buttonText":"<?php esc_attr_e( 'Search', 'woo-gutenberg-products-block' ); ?>","query":{"post_type":"product"}} /-->

<div class="wp-block-query alignwide">
<!-- wp:query-title {"type":"archive","showPrefix":false} /-->

<!-- wp:term-description /-->
Copy link
Contributor

@tjcafferkey tjcafferkey Feb 1, 2023

Choose a reason for hiding this comment

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

For the Product Catalog template there will be no term, or term-description however it is displayed in the Site Editor. Is it possible to conditionally render this if the user is viewing the templates:

  • Products by Category
  • Products by Attribute
  • Products by Tag (which by the way is not displaying the blockified version at this point, is this correct?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, good catch.

Is it possible to conditionally render this if the user is viewing the templates:

Currently, all archive templates use the same archive-product.html template (see #7712). I think we can do one of:

  • Create a new archive template with description, fallback all other templates to use the one with description instead of the archive-product.html.
  • Chime in the template parsing process to remove the description block for Product Catalog template.
  • Remove the description block.

@albarin @tjcafferkey what do you think is the best direction here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Chime in the template parsing process to remove the description block for Product Catalog template.

This feels a little bit hacky and we could end up setting a precedent for other people to do the same thing for other template scenarios which might not be ideal. I'm open to people disagreeing though.

Create a new archive template with description, fallback all other templates to use the one with description instead of the archive-product.html.

This feels like a better option but comes with the overhead of maintaining two templates, would that be a problem?

Copy link
Member Author

Choose a reason for hiding this comment

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

You read my mind Tom! If I have to choose one now, that'd be the second direction. But I'm not happy with either of them.

Copy link
Contributor

Choose a reason for hiding this comment

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

I missed this block in template conversion PR. I'll include it there as well for Products by Category, Products by Attribute and Products by Tag

Copy link
Contributor

Choose a reason for hiding this comment

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

Create a new archive template with description, fallback all other templates to use the one with description instead of the archive-product.html.

This feels like a better option but comes with the overhead of maintaining two templates, would that be a problem?

Not completely sure, but I think this would have more implications for the whole fallback system in place. Currently, if you make a modification to the Product Catalog template you should see it on the other three (cat, tag, attr). If we have a separate template with the description I think we'd loose this 🤔

Currently, all archive templates use the same archive-product.html template (see #7712). I think we can do one of:

  • Create a new archive template with description, fallback all other templates to use the one with description instead of the archive-product.html.
  • Chime in the template parsing process to remove the description block for Product Catalog template.
  • Remove the description block.

I'll throw another option there, maybe unpopular 😬 what about just keeping the description block in there?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll throw another option there, maybe unpopular 😬 what about just keeping the description block in there?

@albarin Aha! It's a legit one. Let's consider it also.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll throw another option there, maybe unpopular 😬 what about just keeping the description block in there?

Definitely an option for now, the only problem is that it does not reflect what users will experience on the frontend. I wonder if its possible to put a note next to these blocks perhaps which explains "On the main Product Catalog page this information will not be visible" etc.

Just cc'ing @vivialice into this incase she has any ideas or would like to weigh in on one of the options.

Copy link
Contributor

@tjcafferkey tjcafferkey left a comment

Choose a reason for hiding this comment

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

Nice work! I have just left some comments in the code regarding some things I have noticed. Also, the blockified template is not rendering for the Products by Tag template. Is this correct?

@dinhtungdu
Copy link
Member Author

Also, the blockified template is not rendering for the Products by Tag template. Is this correct?

Are you getting this issue? If yes, I notice the same, @albarin saved me by showing me the 7976 😄

@tjcafferkey
Copy link
Contributor

Are you getting woocommerce/woocommerce#42499? If yes, I notice the same, @albarin saved me by showing me the 7976 😄

@dinhtungdu this wasn't happening for that reason as none of the templates were customized. Trying to replicate this now it seems that there are some other issues and I'm not sure how many are related to my env/Gutenberg/this PR

  • I'm getting white screen on the templates view for more than just the Products by Tag option
  • I'm unable to scroll the left sidebar in the Side Editor

@dinhtungdu
Copy link
Member Author

@dinhtungdu this wasn't happening for that reason as none of the templates were customized. Trying to replicate this now it seems that there are some other issues and I'm not sure how many are related to my env/Gutenberg/this PR

  • I'm getting white screen on the templates view for more than just the Products by Tag option
  • I'm unable to scroll the left sidebar in the Side Editor

@tjcafferkey and I paired yesterday and we can confirm the template is loading unreliable. This isn't an issue introduced by this PR.

@albarin
Copy link
Contributor

albarin commented Feb 3, 2023

Testing this I was getting this error:
Screenshot 2023-02-03 at 10 07 34

Seems like the BlockPatterns.php expects all patterns to have a category. Should we include one in the two introduced here or maybe better to not make it required in the BlockPatterns.php?

@dinhtungdu
Copy link
Member Author

Seems like the BlockPatterns.php expects all patterns to have a category. Should we include one in the two introduced here or maybe better to not make it required in the BlockPatterns.php?

Nice catch! I think every pattern should have a category. Added in 9c2d701. Thank you!

@dinhtungdu
Copy link
Member Author

@tjcafferkey Because we're already injecting theme attributes into template content, I think it's fine to remove the term description block for the archive-product template (2f3fd99). Can you please take another look at this PR?

@@ -198,6 +236,9 @@ public static function build_template_result_from_file( $template_file, $templat
$template->id = $template_is_from_theme ? $theme_name . '//' . $template_file->slug : self::PLUGIN_SLUG . '//' . $template_file->slug;
$template->theme = $template_is_from_theme ? $theme_name : self::PLUGIN_SLUG;
$template->content = self::inject_theme_attribute_in_content( $template_content );
if ( 'archive-product' === $template_file->slug ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be great if we could leave a comment here just explaining why we're doing this.

Copy link
Contributor

@tjcafferkey tjcafferkey left a comment

Choose a reason for hiding this comment

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

Thanks for sorting @dinhtungdu this LGTM! I have just left one comment but approving.

@dinhtungdu
Copy link
Member Author

Failed tests are flaky. Merging with failed test.

@dinhtungdu dinhtungdu changed the title Update the archive templates to use Products block Update the archive templates to use Products block (#8308)Co-authored-by: Alba Rincón <alba.rincon@automattic.com> Feb 22, 2023
@dinhtungdu dinhtungdu merged commit 05b7838 into trunk Feb 22, 2023
@dinhtungdu dinhtungdu deleted the fix/8067 branch February 22, 2023 01:24
@dinhtungdu dinhtungdu changed the title Update the archive templates to use Products block (#8308)Co-authored-by: Alba Rincón <alba.rincon@automattic.com> Update the archive templates to use Products block (#8308) Feb 22, 2023
@dinhtungdu dinhtungdu changed the title Update the archive templates to use Products block (#8308) Update the archive templates to use Products block Feb 22, 2023
@dinhtungdu dinhtungdu added the type: enhancement The issue is a request for an enhancement. label Feb 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
focus: FSE Work related to prepare WooCommerce for FSE. focus: template Related to API powering block template functionality in the Site Editor type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update the archive templates to replace woocommerce/legacy-template by Products block
4 participants