From eac1a460f0a50f073f01ee6d71b773c153830c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 21 Dec 2023 16:00:32 -0300 Subject: [PATCH] [Product Block Editor]: Add `Linked product` tab (#43009) * add linked-products to group IDs * add Linked Products tab * tweak hideConditions condition * changelog * fix typo in doc comment --- ...date-product-editor-add-product-linked-tab | 2 +- .../SimpleProductTemplate.php | 31 +++++++++++++++---- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/plugins/woocommerce/changelog/update-product-editor-add-product-linked-tab b/plugins/woocommerce/changelog/update-product-editor-add-product-linked-tab index c2432ee6109..358e1d0f080 100644 --- a/plugins/woocommerce/changelog/update-product-editor-add-product-linked-tab +++ b/plugins/woocommerce/changelog/update-product-editor-add-product-linked-tab @@ -1,4 +1,4 @@ Significance: patch Type: add -add `product-linked` feature flag +[Product Block Editor]: add `Linked products` tab diff --git a/plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/SimpleProductTemplate.php b/plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/SimpleProductTemplate.php index 4faf7945115..b0d7becb491 100644 --- a/plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/SimpleProductTemplate.php +++ b/plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/SimpleProductTemplate.php @@ -16,12 +16,13 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ * The context name used to identify the editor. */ const GROUP_IDS = array( - 'GENERAL' => 'general', - 'ORGANIZATION' => 'organization', - 'PRICING' => 'pricing', - 'INVENTORY' => 'inventory', - 'SHIPPING' => 'shipping', - 'VARIATIONS' => 'variations', + 'GENERAL' => 'general', + 'ORGANIZATION' => 'organization', + 'PRICING' => 'pricing', + 'INVENTORY' => 'inventory', + 'SHIPPING' => 'shipping', + 'VARIATIONS' => 'variations', + 'LINKED_PRODUCTS' => 'linked-products', ); /** @@ -149,6 +150,24 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ ) ); } + + // Linked Products tab. + if ( Features::is_enabled( 'product-linked' ) ) { + $this->add_group( + array( + 'id' => $this::GROUP_IDS['LINKED_PRODUCTS'], + 'order' => 60, + 'attributes' => array( + 'title' => __( 'Linked products', 'woocommerce' ), + ), + 'hideConditions' => Features::is_enabled( 'product-linked' ) ? array( + array( + 'expression' => 'editedProduct.type === "grouped"', + ), + ) : null, + ) + ); + } } /**