-
Notifications
You must be signed in to change notification settings - Fork 221
Use the single product block on the Hero Product pattern #9935
Conversation
The release ZIP for this PR is accessible via:
Script Dependencies ReportThe
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.17 MB ℹ️ View Unchanged
|
This is a regression, as our codebase was already prepared to circumvent this, while the two fixes ( WordPress/gutenberg#48001 and WordPress/gutenberg#49495) are not added to the core of WordPress. I'm taking a look. |
Here's the fix for the Product Summary block: #9968 |
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 is looking good 🎉 !
I left a couple of suggestions; looking forward to hearing your thoughts!
<div class="wp-block-columns has-base-color has-text-color has-background has-link-color" style="background-color:#6b7ba8;padding-left:20px"> | ||
<!-- wp:column {"width":"40%","style":{"spacing":{"padding":{"top":"0","right":"0","bottom":"0","left":"0"}}}} --> | ||
<div class="wp-block-column" style="padding-top:0;padding-right:0;padding-bottom:0;padding-left:0;flex-basis:40%"> | ||
<!-- wp:post-featured-image {"height":"300px"} /--> |
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.
Instead of using the post's featured image, how about using the Product Image block (as we have within the single product 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.
I first tried to use the Product Image
block, but it does not have image size settings available, so I could not achieve the design. Do you think it's a problem using the Post Featured Image
?
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 first tried to use the Product Image block, but it does not have image size settings available, so I could not achieve the design.
Gotcha! Maybe we should open an issue to enable these size settings for this block later on. What do you think?
As a second and contradictory thought: I'm not sure why we have a Product Image block if the purpose is just to render the image as any regular post would; I guess it's just for the sake of displaying our custom title and description for the block in the editor side? 🤔
Do you think it's a problem using the Post Featured Image?
It can be a bit confusing to have everything in this pattern converted to the blocks that power the Single Product block except for the image, but that's just a loose opinion/not a blocker :)
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.
Yeah, I'm not sure about the Product Image
block either.
I'll create an issue to add the size settings to it and replace the image in this pattern, so we can go ahead with this PR but remember to switch blocks when possible.
); | ||
|
||
$products = $query->get_products(); | ||
$product_id = $products ? $products[0] : null; |
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.
While I agree this is a valid way to provide an initial/default product for the user to work with, I believe, ideally, we should somehow display a list of available products for the user to choose from before inserting the pattern, similar to what is displayed when inserting the single product block itself in the editor:
![Screenshot 2023-06-27 at 17 32 30](https://private-user-images.githubusercontent.com/15730971/249204153-b7ab2bd1-8cce-4485-9095-60e790452b8c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzMzkwMzksIm5iZiI6MTczOTMzODczOSwicGF0aCI6Ii8xNTczMDk3MS8yNDkyMDQxNTMtYjdhYjJiZDEtOGNjZS00NDg1LTkwOTUtNjBlNzkwNDUyYjhjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDA1Mzg1OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTY5NzI3NGJmMWU1OWY4ODg3Zjc1M2VhYzBkYjQxMzQ5MDhmZTc4OGZkNDE0YzU1NzlhMGE3YWM1ZGQ4MGE5MWYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.7l7Rp1tU2K23hmExIFeXsGsuaEP6c5Npy6DOxNAQFGc)
We don't necessarily have to solve this problem on this PR, but IMO it would be a good idea to open a separate issue and explore the feasibility of something along these lines. What are your thoughts?
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.
Removing that PHP snippet to select a product would give us that same single product selector from the image above, but the problem then is that we lose the preview 👇 so the pattern is not really visible until inserted, making it less likely for a user to insert it.
I think eventually GB will have something to provide a custom preview, but until now, that's the only way to show the actual pattern there.
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.
Removing that PHP snippet to select a product would give us that same single product selector from the image above, but the problem then is that we lose the preview 👇 so the pattern is not really visible until inserted, making it less likely for a user to insert it.
Oh ok, gotcha! Feels like we are stuck in a bad loop: without a preview, the user might not insert the pattern, but if they do insert it and can't change the product, they may not use it either 😭
I think eventually GB will have something to provide a custom preview, but until now, that's the only way to show the actual pattern there.
Out of curiosity, do you know if there's an issue on GB already for allowing us to modify this custom preview?
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.
Opened https://github.com/woocommerce/woocommerce-blocks/issues/10022 so we can discuss this separately and unblock this work =)
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 found this issue WordPress/gutenberg#28135 but there's not much activity, not sure if there are more.
They can actually change the product (it's still a Single Product
block) though it may not be obvious after inserting, that's true.
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.
Going ahead and hitting the approve button here!
Thanks for addressing the feedback; great work! We are now a few steps closer to using the Single Product block for all relevant patterns! 🎉
I'm opening a new issue to investigate this limitation in particular (assuming we don't have one yet!)
This PR replaces the current
Hero Product
pattern with theSingle Product
block.Fixes #9855
Screenshots
Testing
User-Facing Testing
Hero product
pattern and save.Single Product
block and has a default product selected.WooCommerce Visibility
Changelog