From 84acc01290b48bbbba34a0e0380ff4463f7eb3a3 Mon Sep 17 00:00:00 2001 From: Alexandre Lara Date: Wed, 22 Mar 2023 12:00:48 -0300 Subject: [PATCH] Add default Single Product HTML template (#8515) * Add default Single Product HTML template * Fix style issues when adding blocks inside group/stack/columns blocks * Add Related Products to the default single product template HTML file * Remove !important statement from Product Image Gallery block css * Change width of Product Image Gallery block to initial instead of unset * Wrap up default single product html template (#8632) * Add minimum structure for Single Product Details block * Add Product Image Gallery #8233 Add Product Image Gallery * Add tests for Single Product Details block * Add the initial basis for the Add to Cart button * Trigger the single product add to cart action for each product type. * wip: create block structure and add initial styles * Add block details to the SingleProductDetails.php file * Rename the block from add-to-cart-button to add-to-cart-form * Update to use the cart icon. * Implement the skeleton for the editor preview. * Render tabs title with empty content * Use woocommerce_output_product_data_tabs function to retrieve tabs data * Update styles and add Notice for the display in the Editor. * Update CSS. * Add base tests for the new Add to Cart Form component. * Add Product Image Gallery block * remove support global styles * remove support global styles * Update the button CSS. * Remove customizations for the Single Product Details block * Update styles for the cart form. * update td style. * Update divs and CSS. * Use conventional input instead of the experimental InputControl * address CSS feedback * add support for the custom classname * remove save function * Remove unnecessary console.log from the Edit.tsx file * Remove block classname from block wrapper * Remove unnecessary WooCommerce tabs filter from the BlockTemplatesController * Remove attributes property from the block registration * Remove isExperimental flag for the Single Product Details block * Remove get_classes_and_styles_by_attributes method from SingleProductDetails block * Prevent Single Product Details block from apppearing in Pages or Posts * add second parameter to the subscribe function * Implement the new design and copy provided for the editor. * Make the notice compatible with dark themes. * Some additional CSS tweaks * adjust the padding for the input * wrap the Single Product Template in a div with the product class * Fix PHP Coding Standards warnings * improve logic and increase coverage of unit test * improve logic and increase coverage of unit test * fix test * format HTML * fix edge case * update @types/wordpress__data package * update placeholder, icon and description * update tsconfig * update block name * fix SCSS linter error * address feedback * create SingleProductTemplateCompatibility class * Add Hooks compatibility * remove not used file * remove not used files * Add compatibility layer for the Single Product template * fix check * implement Product meta template header * Product Price Block: Add support Single Product Template * fix missing import * add comment * return a value * improve comment * fix import * Add Product Meta block * wrap up default single product html * fix: related products and grouped products result #8589 * remove classname * fix crash * update template --------- Co-authored-by: Alexandre Lara Co-authored-by: Patricia Hillebrandt * Fix images width in the Single Product page * Remove the !important attribute from the Product Image Gallery block * fix sku block * improve layout * fix header and footer template parts declaration --------- Co-authored-by: Luigi Co-authored-by: Patricia Hillebrandt --- .../add-to-cart-form/style.scss | 1 + .../product-details/block.json | 5 +- .../product-image-gallery/block.json | 1 + .../product-image-gallery/style.scss | 8 +-- src/BlockTypes/ProductDetails.php | 10 ++- .../templates/blockified/single-product.html | 68 +++++++++++++++++-- 6 files changed, 78 insertions(+), 15 deletions(-) diff --git a/assets/js/atomic/blocks/product-elements/add-to-cart-form/style.scss b/assets/js/atomic/blocks/product-elements/add-to-cart-form/style.scss index 4752f860783..ebaed422715 100644 --- a/assets/js/atomic/blocks/product-elements/add-to-cart-form/style.scss +++ b/assets/js/atomic/blocks/product-elements/add-to-cart-form/style.scss @@ -3,4 +3,5 @@ .woocommerce-grouped-product-list-item__price del { font-size: var(--wp--preset--font-size--large); } + width: unset; } diff --git a/assets/js/atomic/blocks/product-elements/product-details/block.json b/assets/js/atomic/blocks/product-elements/product-details/block.json index 02deaacac05..c5133768f27 100644 --- a/assets/js/atomic/blocks/product-elements/product-details/block.json +++ b/assets/js/atomic/blocks/product-elements/product-details/block.json @@ -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": {}, + "supports": { + "align": true + }, "textdomain": "woo-gutenberg-products-block", "apiVersion": 2, "$schema": "https://schemas.wp.org/trunk/block.json" diff --git a/assets/js/atomic/blocks/product-elements/product-image-gallery/block.json b/assets/js/atomic/blocks/product-elements/product-image-gallery/block.json index 92def860465..836538cf400 100644 --- a/assets/js/atomic/blocks/product-elements/product-image-gallery/block.json +++ b/assets/js/atomic/blocks/product-elements/product-image-gallery/block.json @@ -9,6 +9,7 @@ "align": true, "multiple": false }, + "attributes": {}, "keywords": [ "WooCommerce" ], "usesContext": [ "postId", "postType", "queryId" ], "textdomain": "woo-gutenberg-products-block", diff --git a/assets/js/atomic/blocks/product-elements/product-image-gallery/style.scss b/assets/js/atomic/blocks/product-elements/product-image-gallery/style.scss index c678700a56e..d3740e8a5da 100644 --- a/assets/js/atomic/blocks/product-elements/product-image-gallery/style.scss +++ b/assets/js/atomic/blocks/product-elements/product-image-gallery/style.scss @@ -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; +} diff --git a/src/BlockTypes/ProductDetails.php b/src/BlockTypes/ProductDetails.php index 3a1795279e5..8c269404e89 100644 --- a/src/BlockTypes/ProductDetails.php +++ b/src/BlockTypes/ProductDetails.php @@ -1,7 +1,8 @@ - %2$s + '
+ %3$s
', + esc_attr( $classes_and_styles['classes'] ), esc_attr( $classname ), $tabs ); diff --git a/templates/templates/blockified/single-product.html b/templates/templates/blockified/single-product.html index 8579ad7a29e..b8a173bb5d1 100644 --- a/templates/templates/blockified/single-product.html +++ b/templates/templates/blockified/single-product.html @@ -1,8 +1,64 @@ - -
- -

Single product blockified

-
+ + +
+ + +
+
+ + + +
+ + + + + + + + + +
+ +
+ + + + + +
+ +
+ +
+ +
+ + + + + + + +
- + + \ No newline at end of file