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

Add Single Product Details block #8225

Merged
merged 25 commits into from
Feb 16, 2023
Merged

Conversation

thealexandrelara
Copy link
Contributor

@thealexandrelara thealexandrelara commented Jan 17, 2023

Create a block version of the product details (visible on the single product template), so merchants can add the product description, information, and reviews to their stores. In this first iteration, we are focusing in porting the existing functionality without allowing users to customize the block

Fixes #8186

Accessibility

Screenshots

Before After
image image

Testing

Automated Tests

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

User Facing Testing

  1. Enable a blocked theme in your WordPress installation (go to Appearance > Themes, and select one of the blocked themes options, such as: Twenty-Twenty Three);
  2. Once the theme is enabled, go to Appearance > Editor (Beta);
  3. On the left side menu, click on Templates;
  4. Select the Single Product template, and click Edit;
  5. Select the WooCommerce Single Product Block that comes by default with the template, remove it, and Save;
  6. Using the Block Inserter, type: Single Product Details. Add it to the Editor and position the block as you want.
  7. Make sure the Single Product Details block is being displayed and contains the tabs: Description, Additional Information and Reviews;
  8. Save the changes. Access your website and click on a product;
  9. Make sure the Single Product Details block appears and contains the product description (Description tab), product attributes (Additional Information tab) and the product reviews (Reviews tab).

Changelog

Add Single Product Details block that displays the product description, information, and reviews

@github-actions
Copy link
Contributor

github-actions bot commented Jan 17, 2023

The release ZIP for this PR is accessible via:

https://wcblocks.wpcomstaging.com/wp-content/uploads/woocommerce-gutenberg-products-block-8225.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: 496
  • Total errors: 2341

🎉 🎉 This PR does not introduce new TS errors.

comments-aggregator

@github-actions
Copy link
Contributor

github-actions bot commented Jan 17, 2023

Size Change: +712 B (0%)

Total Size: 1.1 MB

Filename Size Change
build/active-filters.js 7.33 kB +1 B (0%)
build/all-products-frontend.js 11.7 kB +2 B (0%)
build/all-products.js 34.6 kB +376 B (+1%)
build/all-reviews.js 7.67 kB -1 B (0%)
build/attribute-filter.js 12.3 kB -4 B (0%)
build/blocks-checkout.js 41.2 kB +15 B (0%)
build/breadcrumbs.js 2.04 kB -2 B (0%)
build/cart-blocks/cart-cross-sells-products-frontend.js 9.7 kB +4 B (0%)
build/cart.js 47.2 kB -2 B (0%)
build/featured-category.js 13.1 kB -1 B (0%)
build/featured-product.js 13.4 kB -1 B (0%)
build/filter-wrapper.js 2.4 kB +2 B (0%)
build/handpicked-products.js 7.24 kB +2 B (0%)
build/legacy-template.js 2.85 kB -3 B (0%)
build/mini-cart-contents.js 17 kB -2 B (0%)
build/mini-cart.js 4.3 kB +2 B (0%)
build/price-filter.js 8.38 kB -1 B (0%)
build/product-add-to-cart.js 8.63 kB +3 B (0%)
build/product-button.js 3.99 kB +3 B (0%)
build/product-categories.js 2.36 kB -1 B (0%)
build/product-category-list.js 504 B +1 B (0%)
build/product-category.js 8.58 kB +3 B (0%)
build/product-new.js 7.58 kB -1 B (0%)
build/product-on-sale.js 7.91 kB +3 B (0%)
build/product-price-frontend.js 2.29 kB +4 B (0%)
build/product-price.js 1.58 kB +1 B (0%)
build/product-query.js 6.08 kB -3 B (0%)
build/product-sale-badge.js 819 B +3 B (0%)
build/product-search.js 2.63 kB +2 B (0%)
build/product-tag-list.js 497 B -1 B (0%)
build/product-tag.js 8.07 kB -5 B (0%)
build/product-title.js 3.46 kB -2 B (0%)
build/product-top-rated.js 7.83 kB -2 B (0%)
build/products-by-attribute.js 8.52 kB -2 B (0%)
build/rating-filter.js 7.4 kB +2 B (0%)
build/single-product-frontend.js 17.8 kB +1 B (0%)
build/single-product.js 9.98 kB +1 B (0%)
build/store-notices.js 1.65 kB +2 B (0%)
build/wc-blocks-data.js 21.4 kB +60 B (0%)
build/wc-blocks-style-rtl.css 26.7 kB +124 B (0%)
build/wc-blocks-style.css 26.6 kB +125 B (0%)
build/wc-blocks-vendors.js 64.4 kB +4 B (0%)
ℹ️ View Unchanged
Filename Size
build/active-filters-frontend.js 7.98 kB
build/active-filters-wrapper-frontend.js 6 kB
build/attribute-filter-frontend.js 22.9 kB
build/attribute-filter-wrapper-frontend.js 7.67 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-express-payment--checkout-blocks/express-payment-frontend.js 5.17 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.36 kB
build/cart-blocks/cart-line-items-frontend.js 1.07 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 654 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 435 B
build/cart-blocks/proceed-to-checkout-frontend.js 1.24 kB
build/cart-frontend.js 28.7 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 344 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 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.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.3 kB
build/checkout.js 43.7 kB
build/customer-account.js 3.12 kB
build/filter-wrapper-frontend.js 14.1 kB
build/general-style-rtl.css 1.31 kB
build/general-style.css 1.31 kB
build/mini-cart-component-frontend.js 27.9 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.79 kB
build/mini-cart-contents-block/items-frontend.js 237 B
build/mini-cart-contents-block/products-table-frontend.js 591 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-frontend.js 2 kB
build/price-filter-frontend.js 13.9 kB
build/price-filter-wrapper-frontend.js 6.99 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.73 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 258 B
build/product-button-frontend.js 2.19 kB
build/product-category-list-frontend.js 1.19 kB
build/product-image-frontend.js 2.2 kB
build/product-image.js 4.09 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-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 646 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-title-frontend.js 1.62 kB
build/rating-filter-frontend.js 21.4 kB
build/rating-filter-wrapper-frontend.js 6.19 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/stock-filter-frontend.js 21.1 kB
build/stock-filter-wrapper-frontend.js 5.85 kB
build/stock-filter.js 8.13 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.7 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.53 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.48 kB
build/wc-blocks-editor-style-rtl.css 5.54 kB
build/wc-blocks-editor-style.css 5.54 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-vendors-style-rtl.css 1.96 kB
build/wc-blocks-vendors-style.css 1.96 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/wp-directives-runtime.js 2.4 kB
build/wp-directives-vendors.js 7.89 kB

compressed-size-action

@thealexandrelara thealexandrelara changed the title Add minimum structure for Single Product Details block WIP: Add Single Product Details block Jan 17, 2023
@thealexandrelara thealexandrelara self-assigned this Jan 18, 2023
@thealexandrelara thealexandrelara changed the title WIP: Add Single Product Details block Add Single Product Details block Jan 30, 2023
@thealexandrelara thealexandrelara marked this pull request as ready for review January 30, 2023 18:39
@woocommercebot woocommercebot requested a review from a team January 30, 2023 18:39
@thealexandrelara thealexandrelara requested review from nefeline and removed request for a team January 30, 2023 18:39
Copy link
Contributor

@gigitux gigitux 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 working on this! Great job! I left some comments 💪

{
"name": "woocommerce/single-product-details",
"version": "1.0.0",
"title": "Single Product Details",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we name it Product Details or Single Product Details? 🤔 cc @vivialice

Copy link
Contributor

Choose a reason for hiding this comment

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

Just name it Product Details for now.

"attributes": {},
"textdomain": "woo-gutenberg-products-block",
"apiVersion": 2,
"$schema": "https://schemas.wp.org/trunk/block.json"
Copy link
Contributor

Choose a reason for hiding this comment

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

Miss the declaration for the icon. Any idea about what icon should we pick? @vivialice

assets/js/blocks/single-product-details/block.tsx Outdated Show resolved Hide resolved
assets/js/blocks/single-product-details/edit.tsx Outdated Show resolved Hide resolved
assets/js/blocks/single-product-details/edit.tsx Outdated Show resolved Hide resolved
assets/js/blocks/single-product-details/index.tsx Outdated Show resolved Hide resolved
@@ -0,0 +1,46 @@
.wp-block-woocommerce-single-product-details {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we resolve #8314, is this CSS still necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hope we don't need it anymore after solving that issue; however, if we need to change some things in the UX I think we still are going to need this

bin/webpack-entries.js Outdated Show resolved Hide resolved
src/BlockTemplatesController.php Outdated Show resolved Hide resolved
src/BlockTypes/SingleProductDetails.php Outdated Show resolved Hide resolved
import metadata from './block.json';
import edit from './edit';

registerBlockType( metadata, {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should make the block available only on the Single Product Template. I created a util function to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that function is not merged into trunk yet, right?

Copy link
Contributor

@nefeline nefeline left a comment

Choose a reason for hiding this comment

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

Hi there @thealexandrelara! Good to see this block shaping up here, well done! It works like a charm, but there's one caveat, the star ratings are still duplicated:

Screenshot 2023-01-31 at 20 39 50

Did you have the chance to look into this? I'm glad to jump on a call & try to figure this out if that helps!

Apart from that I'd also recommend addressing the PHP CS warnings.

src/BlockTypesController.php Outdated Show resolved Hide resolved
src/BlockTemplatesController.php Outdated Show resolved Hide resolved
@thealexandrelara
Copy link
Contributor Author

Thanks for working on this! Great job! I left some comments 💪

Thank you for reviewing it! I'll be addressing all of those and let's wait for @vivialice to decide about the ones related to UX.

Hi there @thealexandrelara! Good to see this block shaping up here, well done! It works like a charm, but there's one caveat, the star ratings are still duplicated:

Screenshot 2023-01-31 at 20 39 50

Did you have the chance to look into this? I'm glad to jump on a call & try to figure this out if that helps!

Apart from that I'd also recommend addressing the PHP CS warnings.

Hey @nefeline, thank you for your review! Yeah, I took a look into this, this issue occurs if you put the block in the Single Product template together with the classic template for the WooCommerce Single Product Block. To avoid that, I suggest to remove the default Single Product Block from the Single Product template before testing (step 5 of the User Facing Testing section in this PR)

About the PHP CS warnings, I'm going to address them now, thank you for pointing this out!

@gigitux
Copy link
Contributor

gigitux commented Feb 13, 2023

Should we put this block inside the folder product-elements? Furthermore, it could make sense to rename the block name (and relative folder) into product-details. What do you think? @nefeline

@tjcafferkey
Copy link
Contributor

I think that addressing the issue could require time, and I don't believe that it makes sense to make this effort (at least now), especially because:

  • This block is an alternative to the Classic Single Product Block. Use the block with the Classic Product Block is an edge case.
  • In the next future, we will deprecate the Classic Product Block.

I think if this requires a significant time investment then it's fine to ship. We can later work out whether it's worth fixing before deprecating the Classic Product block depending on at what point in the future that will be happening.

But yes, it seems that this issue only occurs in a specific scenario which I would consider an edge case.

@nefeline
Copy link
Contributor

Should we put this block inside the folder product-elements?

By product elements, do you mean within woocommerce-blocks/assets/js/atomic/blocks/product-elements ? That's a good question; I'm not sure: does this block have all prerequisites to be classified as atomic? If we follow this route, we might have to move the Add to Cart Form block #8284 and any other blocks that belong to the single product template to this directory as well for consistency.

Furthermore, it could make sense to rename the block name (and relative folder) into product-details. What do you think? @nefeline

Naming it Product Details and updating the relative folder makes sense to me 👍 .

Regarding the duplicate star ratings issue:

I think if this requires a significant time investment then it's fine to ship. We can later work out whether it's worth fixing before deprecating the Classic Product block depending on at what point in the future that will be happening.
But yes, it seems that this issue only occurs in a specific scenario which I would consider an edge case.

I have created woocommerce/woocommerce#42475, so we can keep track: I'm not entirely sure if this is something that takes a significant amount of time to fix as I didn't investigate it myself; there could be alternative paths/workarounds to explore. I'll spend some time on it between today/tomorrow just in case: if no quick fix is available, then I agree it makes sense to work on it later as it occurs only under specific circumstances.

@gigitux
Copy link
Contributor

gigitux commented Feb 14, 2023

By product elements, do you mean within woocommerce-blocks/assets/js/atomic/blocks/product-elements ? That's a good question; I'm not sure: does this block have all prerequisites to be classified as atomic? If we follow this route, we might have to move the Add to Cart Form block #8284 and any other blocks that belong to the single product template to this directory as well for consistency.

Technically, there isn't any difference between atomic blocks and other blocks. For now, I would put all of them into the product-elements. The reason is that the blocks used by the Single Product Block (and now by the Products block) are in this folder. We could always revisit this choice.

Via 96fab80, I addressed those two points. Furthermore, I created a follow-up about icon #8427.

@nefeline, could you do another look?

$classname = $attributes['className'] ?? '';

return sprintf(
'<div class="wp-block-woocommerce-single-product-details %1$s">
Copy link
Contributor

Choose a reason for hiding this comment

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

The styles are now broken due to the latest changes to rename the block from single-product-details to product-details. The following should do the trick:

Suggested change
'<div class="wp-block-woocommerce-single-product-details %1$s">
'<div class="wc-block-woocommerce-product-details %1$s">

I also suggest renaming the class prefix from wp-block to wc-block so it is aligned with the standards we are using in other blocks.

Copy link
Contributor

Choose a reason for hiding this comment

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

We decided to avoid adding a custom class. We should use WP generated class (more context: p1675160559571929-slack-C02UBB1EPEF)

Copy link
Contributor

Choose a reason for hiding this comment

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

We decided to avoid adding a custom class. We should use WP generated class (more context: p1675160559571929-slack-C02UBB1EPEF)

Oh cool, I missed that convo, thanks for sharing! I'll also go ahead and update #8284 with this prefix.

In case someone else comes across this convo: the reason for this decision was that for new blocks, it's a good idea not to introduce new classes, as block themes interact with blocks via theme.json.

@nefeline
Copy link
Contributor

Nice work! Apart from the issue with the styles flagged in the review, everything else looks a-ok 👍

Technically, there isn't any difference between atomic blocks and other blocks.

Isn't it the case that the atomic blocks for Product Elements are supposed to be used as children of contextual blocks? In other words, the context can be used to pass product data down to all children blocks in a given tree?

@nefeline
Copy link
Contributor

I just noticed some oddities: there are two console errors related to the product-details block and the product-image-gallery:

Screenshot 2023-02-15 at 09 24 03

In the context of this block (the Product Details), I suspect it might be related to the recent changes that migrated this block to woocommerce-blocks/assets/js/atomic/blocks/product-elements as it didn't occur previously (the error is only visible after 96fab80)

@gigitux
Copy link
Contributor

gigitux commented Feb 15, 2023

Nice work! Apart from the issue with the styles flagged in the review, everything else looks a-ok 👍

Technically, there isn't any difference between atomic blocks and other blocks.

Isn't it the case that the atomic blocks for Product Elements are supposed to be used as children of contextual blocks? In other words, the context can be used to pass product data down to all children blocks in a given tree?

Mmm, good observation. All the more reason we have to add the blocks in the product-elements block: the Single Product block will use those blocks :D

I just noticed some oddities: there are two console errors related to the product-details block and the product-image-gallery:

Fixed for the Single Product Details, I will create a dedicated issue for the Product Image Gallery #8436! Good catch!

EDIT: My first attempt was 43dd558, but after worked on #8445 I realized that there is a better approach. Check 85e6247.

Copy link
Contributor

@nefeline nefeline 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 addressing all the feedback @gigitux ! Confirmed that:

  • Styles are fixed.
  • The console 404 error is fixed.

Ref. this discussion:

Mmm, good observation. All the more reason we have to add the blocks in the product-elements block: the Single Product block will use those blocks :D

Considering that you already moved this block and also the gallery block to this directory, sounds like it makes sense to have the Add to cart form block moved as well, right? I'll open a separate PR to work on this so we can unblock & merge #8284

@github-actions github-actions bot added this to the 9.7.0 milestone Feb 16, 2023
@gigitux
Copy link
Contributor

gigitux commented Feb 16, 2023

Thanks for your great review! (and thanks @thealexandrelara for working on this block).

Considering that you already moved this block and also the gallery block to this directory, sounds like it makes sense to have the Add to cart form button moved as well, right? I'll open a separate PR to work on this so we can unblock & merge #8284

It makes sense! 👍

@gigitux gigitux merged commit 9095720 into trunk Feb 16, 2023
@gigitux gigitux deleted the feat/add-single-product-details-block branch February 16, 2023 10:18
@dinhtungdu dinhtungdu added type: enhancement The issue is a request for an enhancement. focus: FSE Work related to prepare WooCommerce for FSE. labels Feb 27, 2023
@gigitux gigitux mentioned this pull request Feb 28, 2023
52 tasks
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. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create the Single Product Details block
6 participants