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

Add default Single Product HTML template #8515

Merged
merged 18 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
d4f417c
Add default Single Product HTML template
thealexandrelara Feb 22, 2023
a5d8124
Fix style issues when adding blocks inside group/stack/columns blocks
thealexandrelara Feb 22, 2023
6720f96
Merge branch 'trunk' into feat/add-default-single-product-html-template
thealexandrelara Feb 23, 2023
4690ee5
Merge branch 'trunk' into feat/add-default-single-product-html-template
thealexandrelara Feb 24, 2023
9f167f5
Add Related Products to the default single product template HTML file
thealexandrelara Feb 24, 2023
cfd96f4
Merge branch 'trunk' into feat/add-default-single-product-html-template
thealexandrelara Mar 3, 2023
35ff36f
Remove !important statement from Product Image Gallery block css
thealexandrelara Mar 11, 2023
76b112c
Change width of Product Image Gallery block to initial instead of unset
thealexandrelara Mar 11, 2023
b8e7bd0
Merge branch 'trunk' of https://github.com/woocommerce/woocommerce-bl…
gigitux Mar 20, 2023
66afe60
Merge branch 'trunk' of https://github.com/woocommerce/woocommerce-bl…
gigitux Mar 21, 2023
ae3d39f
Wrap up default single product html template (#8632)
gigitux Mar 21, 2023
4029fcf
Fix images width in the Single Product page
thealexandrelara Mar 21, 2023
ebda787
Remove the !important attribute from the Product Image Gallery block
thealexandrelara Mar 21, 2023
dc8e855
fix sku block
gigitux Mar 21, 2023
960194a
Merge branch 'feat/add-default-single-product-html-template' of https…
gigitux Mar 21, 2023
394ef49
improve layout
gigitux Mar 22, 2023
1822c58
fix header and footer template parts declaration
gigitux Mar 22, 2023
caf3ada
Merge branch 'trunk' into feat/add-default-single-product-html-template
gigitux Mar 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
.woocommerce-grouped-product-list-item__price del {
font-size: var(--wp--preset--font-size--large);
}
width: unset;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"description": "A block that allows your customers to see details and reviews about the product.",
"category": "woocommerce",
"keywords": [ "WooCommerce" ],
"supports": {},
"attributes": {},
Copy link
Contributor

@danielwrobert danielwrobert Mar 22, 2023

Choose a reason for hiding this comment

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

How come we're removing the attributes property here and adding it in product-image-gallery/block.json below?

I couldn't find the specific commit that made this change. Everything still tests as described, I'm really just curious! 🙂

Copy link
Contributor

@gigitux gigitux Mar 22, 2023

Choose a reason for hiding this comment

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

I updated this PR multiple times these weeks, so I'm unsure who and when the attributes key was removed.

I agree with you, we should remove the empty attributes on the product image gallery block.json. I created a PR #8825

Copy link
Contributor

Choose a reason for hiding this comment

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

Perfect, thank you. I'll put that on my list to review today!

"supports": {
"align": true
},
"textdomain": "woo-gutenberg-products-block",
"apiVersion": 2,
"$schema": "https://schemas.wp.org/trunk/block.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"align": true,
"multiple": false
},
"attributes": {},
"keywords": [ "WooCommerce" ],
"usesContext": [ "postId", "postType", "queryId" ],
"textdomain": "woo-gutenberg-products-block",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
.woocommerce .wp-block-woocommerce-product-image-gallery {
position: relative;

div.images {
width: unset !important;
}

span.onsale {
right: unset;
z-index: 1;
left: -1rem;
}
}

.woocommerce .wp-block-woocommerce-product-image-gallery .woocommerce-product-gallery.images {
width: initial;
}
10 changes: 7 additions & 3 deletions src/BlockTypes/ProductDetails.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

namespace Automattic\WooCommerce\Blocks\BlockTypes;

use Automattic\WooCommerce\Blocks\Utils\StyleAttributesUtils;

/**
* ProductDetails class.
*/
Expand Down Expand Up @@ -34,10 +35,13 @@ protected function render( $attributes, $content, $block ) {

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

$classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes );

return sprintf(
'<div class="wp-block-woocommerce-product-details %1$s">
%2$s
'<div class="wp-block-woocommerce-product-details %1$s %2$s">
%3$s
</div>',
esc_attr( $classes_and_styles['classes'] ),
esc_attr( $classname ),
$tabs
);
Expand Down
70 changes: 63 additions & 7 deletions templates/templates/blockified/single-product.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,64 @@
<!-- wp:template-part {"slug":"header"} /-->
<!-- wp:group {"layout":{"inherit":true}} -->
<div class="wp-block-group">
<!-- wp:paragraph -->
<p>Single product blockified</p>
<!-- /wp:paragraph --></div>
<!-- wp:template-part {"slug":"header","theme":"twentytwentythree","tagName":"header"} /-->
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure we wanna add the header and footer for twentytwentythree theme here? What happens if the user is using another theme?

Copy link
Contributor

Choose a reason for hiding this comment

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

Great catch! I fixed via 1822c58


<!-- wp:group {"layout":{"inherit":true,"type":"constrained"}} -->
<div class="wp-block-group"><!-- wp:woocommerce/breadcrumbs /-->

<!-- wp:columns {"align":"wide"} -->
<div class="wp-block-columns alignwide"><!-- wp:column -->
<div class="wp-block-column"><!-- wp:woocommerce/product-image-gallery /--></div>
<!-- /wp:column -->

<!-- wp:column -->
<div class="wp-block-column">
<!-- wp:post-title {"__woocommerceNamespace":"woocommerce/product-query/product-title"} /-->

<!-- wp:woocommerce/product-price {"isDescendentOfSingleProductTemplate":true, "fontSize":"large"} /-->

<!-- wp:post-excerpt {"__woocommerceNamespace":"woocommerce/product-query/product-summary"} /-->

<!-- wp:woocommerce/add-to-cart-form /-->

<!-- wp:woocommerce/product-meta -->
<div class="wp-block-woocommerce-product-meta">
<!-- wp:group {"layout":{"type":"flex","flexWrap":"nowrap"}} -->
<div class="wp-block-group">
<!-- wp:woocommerce/product-sku {"isDescendentOfSingleProductTemplate":true} /-->

<!-- wp:post-terms {"term":"product_cat","prefix":"Category: "} /-->

<!-- wp:post-terms {"term":"product_tag","prefix":"Tags: "} /-->
</div>
<!-- /wp:group -->
</div>
<!-- /wp:woocommerce/product-meta -->
</div>
<!-- /wp:column -->
</div>
<!-- /wp:columns -->

<!-- wp:woocommerce/product-details {"align":"wide"} /-->

<!-- wp:woocommerce/related-products {"align":"wide"} -->
<div class="wp-block-woocommerce-related-products alignwide">
<!-- wp:query {"queryId":0,"query":{"perPage":5,"pages":0,"offset":0,"postType":"product","order":"asc","orderBy":"title","author":"","search":"","exclude":[],"sticky":"","inherit":false},"displayLayout":{"type":"flex","columns":5},"namespace":"woocommerce/related-products","lock":{"remove":true,"move":true}} -->
<div class="wp-block-query"><!-- wp:heading -->
<h2 class="wp-block-heading">Related products</h2>
<!-- /wp:heading -->

<!-- wp:post-template {"__woocommerceNamespace":"woocommerce/product-query/product-template"} -->
<!-- wp:woocommerce/product-image {"isDescendentOfQueryLoop":true} /-->

<!-- wp:post-title {"textAlign":"center","level":3,"fontSize":"medium","__woocommerceNamespace":"woocommerce/product-query/product-title"} /-->

<!-- wp:woocommerce/product-price {"isDescendentOfQueryLoop":true,"textAlign":"center","fontSize":"small","style":{"spacing":{"margin":{"bottom":"1rem"}}}} /-->

<!-- wp:woocommerce/product-button {"isDescendentOfQueryLoop":true,"textAlign":"center","fontSize":"small","style":{"spacing":{"margin":{"bottom":"1rem"}}}} /-->
<!-- /wp:post-template -->
</div>
<!-- /wp:query -->
</div>
<!-- /wp:woocommerce/related-products -->
</div>
<!-- /wp:group -->
<!-- wp:template-part {"slug":"footer"} /-->

<!-- wp:template-part {"slug":"footer","theme":"twentytwentythree","tagName":"footer"} /-->