From 26a546954a9a5049a9305b4f114ca52fb76cbb5f Mon Sep 17 00:00:00 2001 From: Maikel Perez Date: Tue, 23 Jan 2024 12:12:52 -0300 Subject: [PATCH] Hide Downloads section under Toggle (#43864) * Add Include downloads to show/hide the Downloads section * Fix margin top for none first child nested sections * Add changelog files * Fix php linter errors --- .../js/product-editor/changelog/add-43807 | 4 +++ .../src/blocks/generic/section/editor.scss | 14 ++++++-- plugins/woocommerce/changelog/add-43807 | 4 +++ .../SimpleProductTemplate.php | 33 +++++++++++++++++-- 4 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 packages/js/product-editor/changelog/add-43807 create mode 100644 plugins/woocommerce/changelog/add-43807 diff --git a/packages/js/product-editor/changelog/add-43807 b/packages/js/product-editor/changelog/add-43807 new file mode 100644 index 00000000000..7e9ba52236a --- /dev/null +++ b/packages/js/product-editor/changelog/add-43807 @@ -0,0 +1,4 @@ +Significance: minor +Type: add + +Fix margin top for none first child nested sections diff --git a/packages/js/product-editor/src/blocks/generic/section/editor.scss b/packages/js/product-editor/src/blocks/generic/section/editor.scss index 7ad91c364fc..82190b76b10 100644 --- a/packages/js/product-editor/src/blocks/generic/section/editor.scss +++ b/packages/js/product-editor/src/blocks/generic/section/editor.scss @@ -53,7 +53,9 @@ } .wp-block-woocommerce-product-section { - margin-top: 0; + &:first-child { + margin-top: 0; + } padding-bottom: 0; border-bottom: none; } @@ -74,9 +76,15 @@ * Core removes the "loading" animation styles * from the button when it's disabled, so we * let's add them back. - */ + */ .components-button.is-tertiary.is-busy:disabled { - background-image: linear-gradient( -45deg, #fafafa 33%, #e0e0e0 0, #e0e0e0 70%, #fafafa 0 ); + background-image: linear-gradient( + -45deg, + #fafafa 33%, + #e0e0e0 0, + #e0e0e0 70%, + #fafafa 0 + ); background-size: 100px 100%; opacity: 1; } diff --git a/plugins/woocommerce/changelog/add-43807 b/plugins/woocommerce/changelog/add-43807 new file mode 100644 index 00000000000..53dff4d0e72 --- /dev/null +++ b/plugins/woocommerce/changelog/add-43807 @@ -0,0 +1,4 @@ +Significance: minor +Type: add + +Add Include downloads to show/hide the Downloads section diff --git a/plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/SimpleProductTemplate.php b/plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/SimpleProductTemplate.php index 26b6c854ab3..00858a1186c 100644 --- a/plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/SimpleProductTemplate.php +++ b/plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/SimpleProductTemplate.php @@ -455,10 +455,37 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ ); // Downloads section. if ( Features::is_enabled( 'product-virtual-downloadable' ) ) { - $general_group->add_section( + $product_downloads_section_group = $general_group->add_section( + array( + 'id' => 'product-downloads-section-group', + 'order' => 50, + 'attributes' => array( + 'blockGap' => 'unit-40', + ), + 'hideConditions' => array( + array( + 'expression' => 'editedProduct.type !== "simple"', + ), + ), + ) + ); + + $product_downloads_section_group->add_block( + array( + 'id' => 'product-downloadable', + 'blockName' => 'woocommerce/product-checkbox-field', + 'order' => 10, + 'attributes' => array( + 'property' => 'downloadable', + 'label' => __( 'Include downloads', 'woocommerce' ), + ), + ) + ); + + $product_downloads_section_group->add_section( array( 'id' => 'product-downloads-section', - 'order' => 50, + 'order' => 20, 'attributes' => array( 'title' => __( 'Downloads', 'woocommerce' ), 'description' => sprintf( @@ -470,7 +497,7 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ ), 'hideConditions' => array( array( - 'expression' => 'editedProduct.type !== "simple"', + 'expression' => 'editedProduct.downloadable !== true', ), ), )