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

Add Product Meta Block #8484

Conversation

gigitux
Copy link
Contributor

@gigitux gigitux commented Feb 20, 2023

This PR adds a new block called Product Meta. This block will be used in the blockified Single Product Template and it will be used to wrap:

  • Product SKU
  • Product Categories

Consequentially, this PR added support to the Product SKU block to the Single Product Templates.

Also, this block supports those two hooks:

  • woocommerce_product_meta_start
  • woocommerce_product_meta_end

Fixes #8465

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

image

Testing

Automated Tests

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

User Facing Testing

  1. Edit the Single Product Template.
  2. Add the Product Meta block.
  3. Be sure that the blocks look like the image above.
  4. Save the template.
  5. On the front end, visit a Single Product page. Be sure that the blocks render the right data.
Developer Facing testing
  1. Install the Code Snippets plugin.
  2. Create a new snippet and copy-paste this gist.
  3. Remove the WooCommerce Single Product block.
  4. Edit the Single Product template and add the Product Details block too -> (there is a bug: Compatibility Layer: WP crashes if in the Single Product Template, there is only the Product Meta block #8629)
  5. Be sure that all the hooks work correctly.
  • Do not include in the Testing Notes

WooCommerce Visibility

  • WooCommerce Core
  • Feature plugin
  • Experimental

Performance Impact

Changelog

Add Product Meta block.

thealexandrelara and others added 30 commits January 17, 2023 18:57
Add Product Image Gallery
@gigitux gigitux force-pushed the 8465-single-product-template-create-a-template-part-called-product-meta branch from 6685fc0 to 4c8f30d Compare March 3, 2023 14:15
@gigitux gigitux changed the title Add Product Meta template part Add Product Meta Block Mar 3, 2023
@gigitux gigitux self-assigned this Mar 3, 2023
@gigitux gigitux added type: new block Applied to work that introduces a new block (typically used on an epic issue). type: enhancement The issue is a request for an enhancement. labels Mar 3, 2023
@gigitux gigitux marked this pull request as ready for review March 3, 2023 14:57
@woocommercebot woocommercebot requested a review from a team March 3, 2023 14:57
@gigitux gigitux requested a review from thealexandrelara March 7, 2023 10:59
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.

Nice work @gigitux ! Sharing the test results and also a suggestion:

User Facing Testing
Edit the Single Product Template.
Add the Product Meta template part by adding the Template Part block and selecting Product Meta.
Be sure that the blocks look like the image above.

✅ Confirmed the block is displayed as demonstrated on the image.
🗒️ Suggestion: since we are allowing users to customize both the text and link previews, it would be interesting to add a link on the editor preview so users can visualize how it will be displayed on the FE (similarly to what we did with the breadcrumbs block). To exemplify, the current editor preview is:

Screenshot 2023-03-07 at 10 48 53

but on the FE the display is:

Screenshot 2023-03-07 at 10 49 38

Save the template.
On the front end, visit a Single Product page. Be sure that the blocks render the right data.

✅ Confirmed the correct data is displayed.
❌ The classic WooCommerce Single Product Block is not displayed on this branch:

Editor:
Screenshot 2023-03-07 at 10 53 54

Frontend:
Screenshot 2023-03-07 at 10 54 06

This is probably related to the issue you shared below #8629 as the block is displayed correctly as soon as any other block is added, such as the "Add to cart form":

Screenshot 2023-03-07 at 11 08 08

Developer Facing testing
Install the Code Snippets plugin.
Create a new snippet and copy-paste this gist.
Edit the Single Product template and add the Product Details block too -> (there is a bug: #8629)
Be sure that all the hooks work correctly.

❌ The hooks are not being correctly displayed:

Screenshot 2023-03-07 at 11 10 11

@gigitux
Copy link
Contributor Author

gigitux commented Mar 7, 2023

Thanks for the review, @nefeline

🗒️ Suggestion: since we are allowing users to customize both the text and link previews, it would be interesting to add a link on the editor preview so users can visualize how it will be displayed on the FE (similarly to what we did with the breadcrumbs block). To exemplify, the current editor preview is:

Those blocks are variations of core/blocks, so we can't do a lot. I would wait for designer feedback and, if it makes sense open an issue on Gutenberg.

✅ Confirmed the correct data is displayed.
❌ The classic WooCommerce Single Product Block is not displayed on this branch:

I'm not able to replicate it:

image

❌ The hooks are not being correctly displayed:

Via #8550, the compatibility layer isn't enabled when the classic block is on the page. I will update the testing instructions specifying to remove the WooCommerce Single Product Block.

gigitux added 2 commits March 7, 2023 16:48
…ocks into 8465-single-product-template-create-a-template-part-called-product-meta
@gigitux gigitux requested a review from nefeline March 7, 2023 16:09
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 @gigitux !

I'm not able to replicate it:

Hm, this is odd: I've repeated the process a couple of times as a quick sanity check, and there's not a single scenario where the Product meta block doesn't prevent the display of the classic block template. Here's the screencast:

Screen.Recording.2023-03-07.at.16.44.22.mov

As mentioned previously: the issue is gone if any other single product block is added to the template alongside the Product Meta (on this new test, the Product Details block was added):

Screen.Recording.2023-03-07.at.16.50.43.mov

I'm happy to jump on a call to demo & brainstorm/debug if that helps!

Via #8550, the compatibility layer isn't enabled when the classic block is on the page. I will update the testing instructions specifying to remove the WooCommerce Single Product Block.

Thanks for updating the test instructions for the hooks and sharing these additional details! In this second round of tests, with the WooCommerce Single Product Block removed, the hooks are appropriately added only when there's any another single product block in the template (on this test, the Product Details block was used):

Screen.Recording.2023-03-07.at.17.17.06.mov

Edit the Single Product template and add the Product Details block too -> (there is a bug: #8629)

I see #8629 was closed out, but based on the test results here (without any additional third-party plugins enabled), IMO we shouldn't condition the availability of the 'woocommerce_product_meta_start' and 'woocommerce_product_meta_end' actions to the existence of other single product blocks in the template: they should always be available whenever the product meta block is added, independent of the neighbors.

@gigitux gigitux force-pushed the 8465-single-product-template-create-a-template-part-called-product-meta branch from 3a67431 to d9c9b96 Compare March 8, 2023 14:29
…ocks into 8465-single-product-template-create-a-template-part-called-product-meta
@gigitux
Copy link
Contributor Author

gigitux commented Mar 8, 2023

Thanks @gigitux !

I'm not able to replicate it:

Hm, this is odd: I've repeated the process a couple of times as a quick sanity check, and there's not a single scenario where the Product meta block doesn't prevent the display of the classic block template. Here's the screencast:

As mentioned previously: the issue is gone if any other single product block is added to the template alongside the Product Meta (on this new test, the Product Details block was added):

I'm happy to jump on a call to demo & brainstorm/debug if that helps!

Via #8550, the compatibility layer isn't enabled when the classic block is on the page. I will update the testing instructions specifying to remove the WooCommerce Single Product Block.

Thanks for updating the test instructions for the hooks and sharing these additional details! In this second round of tests, with the WooCommerce Single Product Block removed, the hooks are appropriately added only when there's any another single product block in the template (on this test, the Product Details block was used):

Edit the Single Product template and add the Product Details block too -> (there is a bug: #8629)

I see #8629 was closed out, but based on the test results here (without any additional third-party plugins enabled), IMO we shouldn't condition the availability of the 'woocommerce_product_meta_start' and 'woocommerce_product_meta_end' actions to the existence of other single product blocks in the template: they should always be available whenever the product meta block is added, independent of the neighbors.

I understood now. I added the block inside the first group block! Thanks to your video, I was able to replicate the issue! Thanks a lot for your great patience! 🙇

You found two issues:

  • the Compatibility Layer added the wrap even if the Classic Block is in the template.
  • the Compatibility Layer didn't add the hooks related to the specific block if this was the first and/or the last.

All the issues that you raised should be fixed! Let me know! 💪

@gigitux gigitux requested a review from nefeline March 8, 2023 14:55
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.

I understood now. I added the block inside the first group block! Thanks to your video, I was able to replicate the issue! Thanks a lot for your great patience! 🙇

Thanks for addressing all feedback! Confirmed that both bugs were fixed:

✅ The Product meta block is no longer preventing the display on the WooCommerce Single Product Block.
✅ Hooks are now appropriately added when the product meta block is added individually on a page (independent of the neighboring blocks).

@github-actions github-actions bot added this to the 9.8.0 milestone Mar 8, 2023
@gigitux gigitux merged commit 0fdb926 into trunk Mar 9, 2023
@gigitux gigitux deleted the 8465-single-product-template-create-a-template-part-called-product-meta branch March 9, 2023 08:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: enhancement The issue is a request for an enhancement. type: new block Applied to work that introduces a new block (typically used on an epic issue).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Single Product Template: Create a template part called Product Meta
3 participants