From 7b0ef3db00ee75e704188c98f3c257f036f42702 Mon Sep 17 00:00:00 2001 From: Nathan Silveira Date: Thu, 9 Nov 2023 16:21:33 -0300 Subject: [PATCH] Move Template implementation classes to internal namespace (#41170) * Move Template implementation classes to internal namespace * Fix namespaces that were changed by mistake * Add missing imports to files since they were moved to another namespace * Adapt to new lint rules --- .../changelog/tweak-template-internal | 4 + .../Features/ProductBlockEditor/Init.php | 4 +- .../AbstractProductFormTemplate.php | 5 +- .../ProductTemplates/Group.php | 9 +- .../ProductTemplates/ProductBlock.php | 2 +- .../ProductVariationTemplate.php | 303 +++++----- .../ProductTemplates/Section.php | 6 +- .../SimpleProductTemplate.php | 555 +++++++++--------- .../CustomProductFormTemplate.php | 2 +- 9 files changed, 452 insertions(+), 438 deletions(-) create mode 100644 plugins/woocommerce/changelog/tweak-template-internal rename plugins/woocommerce/src/{Admin => Internal}/Features/ProductBlockEditor/ProductTemplates/AbstractProductFormTemplate.php (82%) rename plugins/woocommerce/src/{Admin => Internal}/Features/ProductBlockEditor/ProductTemplates/Group.php (80%) rename plugins/woocommerce/src/{Admin => Internal}/Features/ProductBlockEditor/ProductTemplates/ProductBlock.php (89%) rename plugins/woocommerce/src/{Admin => Internal}/Features/ProductBlockEditor/ProductTemplates/ProductVariationTemplate.php (88%) rename plugins/woocommerce/src/{Admin => Internal}/Features/ProductBlockEditor/ProductTemplates/Section.php (82%) rename plugins/woocommerce/src/{Admin => Internal}/Features/ProductBlockEditor/ProductTemplates/SimpleProductTemplate.php (86%) diff --git a/plugins/woocommerce/changelog/tweak-template-internal b/plugins/woocommerce/changelog/tweak-template-internal new file mode 100644 index 00000000000..5c91119f355 --- /dev/null +++ b/plugins/woocommerce/changelog/tweak-template-internal @@ -0,0 +1,4 @@ +Significance: patch +Type: tweak + +Move Template implementation classes to internal namespace diff --git a/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/Init.php b/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/Init.php index d81e3ff8e57..1ab47ab4b12 100644 --- a/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/Init.php +++ b/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/Init.php @@ -6,8 +6,8 @@ namespace Automattic\WooCommerce\Admin\Features\ProductBlockEditor; use Automattic\WooCommerce\Admin\Features\Features; -use Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates\SimpleProductTemplate; -use Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates\ProductVariationTemplate; +use Automattic\WooCommerce\Internal\Admin\Features\ProductBlockEditor\ProductTemplates\SimpleProductTemplate; +use Automattic\WooCommerce\Internal\Admin\Features\ProductBlockEditor\ProductTemplates\ProductVariationTemplate; use Automattic\WooCommerce\Admin\PageController; use Automattic\WooCommerce\Internal\Admin\BlockTemplateRegistry\BlockTemplateRegistry; use WP_Block_Editor_Context; diff --git a/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/ProductTemplates/AbstractProductFormTemplate.php b/plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/AbstractProductFormTemplate.php similarity index 82% rename from plugins/woocommerce/src/Admin/Features/ProductBlockEditor/ProductTemplates/AbstractProductFormTemplate.php rename to plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/AbstractProductFormTemplate.php index e62be41d0aa..192c6140eee 100644 --- a/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/ProductTemplates/AbstractProductFormTemplate.php +++ b/plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/AbstractProductFormTemplate.php @@ -1,8 +1,11 @@ 'woocommerce/product-tab' ), $config ), $root_template, $parent ); } + // phpcs:enable Squiz.Commenting.FunctionCommentThrowTag.WrongNumber /** * Add a section block type to this template. diff --git a/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/ProductTemplates/ProductBlock.php b/plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/ProductBlock.php similarity index 89% rename from plugins/woocommerce/src/Admin/Features/ProductBlockEditor/ProductTemplates/ProductBlock.php rename to plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/ProductBlock.php index 72a600e5d08..0e6f5deb8e6 100644 --- a/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/ProductTemplates/ProductBlock.php +++ b/plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/ProductBlock.php @@ -3,7 +3,7 @@ * WooCommerce Product Block class. */ -namespace Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates; +namespace Automattic\WooCommerce\Internal\Admin\Features\ProductBlockEditor\ProductTemplates; use Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface; use Automattic\WooCommerce\Admin\BlockTemplates\ContainerInterface; diff --git a/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/ProductTemplates/ProductVariationTemplate.php b/plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/ProductVariationTemplate.php similarity index 88% rename from plugins/woocommerce/src/Admin/Features/ProductBlockEditor/ProductTemplates/ProductVariationTemplate.php rename to plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/ProductVariationTemplate.php index 958cb25ef08..309bbc66dad 100644 --- a/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/ProductTemplates/ProductVariationTemplate.php +++ b/plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/ProductVariationTemplate.php @@ -3,9 +3,10 @@ * ProductVariationTemplate */ -namespace Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates; +namespace Automattic\WooCommerce\Internal\Admin\Features\ProductBlockEditor\ProductTemplates; use Automattic\WooCommerce\Admin\Features\Features; +use Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates\ProductFormTemplateInterface; /** * Simple Product Template. @@ -63,40 +64,40 @@ class ProductVariationTemplate extends AbstractProductFormTemplate implements Pr */ private function add_group_blocks() { $this->add_group( - [ + array( 'id' => $this::GROUP_IDS['GENERAL'], 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'General', 'woocommerce' ), - ], - ] + ), + ) ); $this->add_group( - [ + array( 'id' => $this::GROUP_IDS['PRICING'], 'order' => 20, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Pricing', 'woocommerce' ), - ], - ] + ), + ) ); $this->add_group( - [ + array( 'id' => $this::GROUP_IDS['INVENTORY'], 'order' => 30, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Inventory', 'woocommerce' ), - ], - ] + ), + ) ); $this->add_group( - [ + array( 'id' => $this::GROUP_IDS['SHIPPING'], 'order' => 40, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Shipping', 'woocommerce' ), - ], - ] + ), + ) ); } @@ -106,61 +107,61 @@ class ProductVariationTemplate extends AbstractProductFormTemplate implements Pr private function add_general_group_blocks() { $general_group = $this->get_group_by_id( $this::GROUP_IDS['GENERAL'] ); $general_group->add_block( - [ + array( 'id' => 'general-single-variation-notice', 'blockName' => 'woocommerce/product-single-variation-notice', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'content' => __( 'You’re editing details specific to this variation. Some information, like description and images, will be inherited from the main product, .', 'woocommerce' ), 'type' => 'info', 'isDismissible' => true, 'name' => $this::SINGLE_VARIATION_NOTICE_DISMISSED_OPTION, - ], - ] + ), + ) ); // Basic Details Section. $basic_details = $general_group->add_section( - [ + array( 'id' => 'product-variation-details-section', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Variation details', 'woocommerce' ), 'description' => __( 'This info will be displayed on the product page, category pages, social media, and search results.', 'woocommerce' ), - ], - ] + ), + ) ); $basic_details->add_block( - [ + array( 'id' => 'product-variation-note', 'blockName' => 'woocommerce/product-summary-field', 'order' => 20, - 'attributes' => [ + 'attributes' => array( 'property' => 'description', 'label' => __( 'Note ', 'woocommerce' ), 'helpText' => 'Enter an optional note displayed on the product page when customers select this variation.', - ], - ] + ), + ) ); $basic_details->add_block( - [ + array( 'id' => 'product-variation-visibility', 'blockName' => 'woocommerce/product-checkbox-field', 'order' => 30, - 'attributes' => [ + 'attributes' => array( 'property' => 'status', 'label' => __( 'Hide in product catalog', 'woocommerce' ), 'checkedValue' => 'private', 'uncheckedValue' => 'publish', - ], - ] + ), + ) ); // Images section. $images_section = $general_group->add_section( - [ + array( 'id' => 'product-variation-images-section', 'order' => 30, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Image', 'woocommerce' ), 'description' => sprintf( /* translators: %1$s: Images guide link opening tag. %2$s: Images guide link closing tag. */ @@ -168,38 +169,38 @@ class ProductVariationTemplate extends AbstractProductFormTemplate implements Pr '', '' ), - ], - ] + ), + ) ); $images_section->add_block( - [ + array( 'id' => 'product-variation-image', 'blockName' => 'woocommerce/product-images-field', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'property' => 'image', 'multiple' => false, - ], - ] + ), + ) ); // Downloads section. if ( Features::is_enabled( 'product-virtual-downloadable' ) ) { $general_group->add_section( - [ + array( 'id' => 'product-variation-downloads-section', 'order' => 40, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Downloads', 'woocommerce' ), 'description' => __( "Add any files you'd like to make available for the customer to download after purchasing, such as instructions or warranty info.", 'woocommerce' ), - ], - ] + ), + ) )->add_block( - [ + array( 'id' => 'product-variation-downloads', 'blockName' => 'woocommerce/product-downloads-field', 'order' => 10, - ] + ) ); } } @@ -210,24 +211,24 @@ class ProductVariationTemplate extends AbstractProductFormTemplate implements Pr private function add_pricing_group_blocks() { $pricing_group = $this->get_group_by_id( $this::GROUP_IDS['PRICING'] ); $pricing_group->add_block( - [ + array( 'id' => 'pricing-single-variation-notice', 'blockName' => 'woocommerce/product-single-variation-notice', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'content' => __( 'You’re editing details specific to this variation. Some information, like description and images, will be inherited from the main product, .', 'woocommerce' ), 'type' => 'info', 'isDismissible' => true, 'name' => $this::SINGLE_VARIATION_NOTICE_DISMISSED_OPTION, - ], - ] + ), + ) ); // Product Pricing Section. $product_pricing_section = $pricing_group->add_section( - [ + array( 'id' => 'product-pricing-section', 'order' => 20, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Pricing', 'woocommerce' ), 'description' => sprintf( /* translators: %1$s: Images guide link opening tag. %2$s: Images guide link closing tag.*/ @@ -236,72 +237,72 @@ class ProductVariationTemplate extends AbstractProductFormTemplate implements Pr '' ), 'blockGap' => 'unit-40', - ], - ] + ), + ) ); $pricing_columns = $product_pricing_section->add_block( - [ + array( 'id' => 'product-pricing-group-pricing-columns', 'blockName' => 'core/columns', 'order' => 10, - ] + ) ); $pricing_column_1 = $pricing_columns->add_block( - [ + array( 'id' => 'product-pricing-group-pricing-column-1', 'blockName' => 'core/column', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'templateLock' => 'all', - ], - ] + ), + ) ); $pricing_column_1->add_block( - [ + array( 'id' => 'product-pricing-regular-price', 'blockName' => 'woocommerce/product-regular-price-field', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'name' => 'regular_price', 'label' => __( 'Regular price', 'woocommerce' ), 'isRequired' => true, - ], - ] + ), + ) ); $pricing_column_2 = $pricing_columns->add_block( - [ + array( 'id' => 'product-pricing-group-pricing-column-2', 'blockName' => 'core/column', 'order' => 20, - 'attributes' => [ + 'attributes' => array( 'templateLock' => 'all', - ], - ] + ), + ) ); $pricing_column_2->add_block( - [ + array( 'id' => 'product-pricing-sale-price', 'blockName' => 'woocommerce/product-sale-price-field', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'label' => __( 'Sale price', 'woocommerce' ), - ], - ] + ), + ) ); $product_pricing_section->add_block( - [ + array( 'id' => 'product-pricing-schedule-sale-fields', 'blockName' => 'woocommerce/product-schedule-sale-fields', 'order' => 20, - ] + ) ); $product_pricing_section->add_block( - [ + array( 'id' => 'product-tax-class', 'blockName' => 'woocommerce/product-radio-field', 'order' => 40, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Tax class', 'woocommerce' ), 'description' => sprintf( /* translators: %1$s: Learn more link opening tag. %2$s: Learn more link closing tag.*/ @@ -310,26 +311,26 @@ class ProductVariationTemplate extends AbstractProductFormTemplate implements Pr '' ), 'property' => 'tax_class', - 'options' => [ - [ + 'options' => array( + array( 'label' => __( 'Same as main product', 'woocommerce' ), 'value' => 'parent', - ], - [ + ), + array( 'label' => __( 'Standard', 'woocommerce' ), 'value' => '', - ], - [ + ), + array( 'label' => __( 'Reduced rate', 'woocommerce' ), 'value' => 'reduced-rate', - ], - [ + ), + array( 'label' => __( 'Zero rate', 'woocommerce' ), 'value' => 'zero-rate', - ], - ], - ], - ] + ), + ), + ), + ) ); } @@ -339,24 +340,24 @@ class ProductVariationTemplate extends AbstractProductFormTemplate implements Pr private function add_inventory_group_blocks() { $inventory_group = $this->get_group_by_id( $this::GROUP_IDS['INVENTORY'] ); $inventory_group->add_block( - [ + array( 'id' => 'inventory-single-variation-notice', 'blockName' => 'woocommerce/product-single-variation-notice', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'content' => __( 'You’re editing details specific to this variation. Some information, like description and images, will be inherited from the main product, .', 'woocommerce' ), 'type' => 'info', 'isDismissible' => true, 'name' => $this::SINGLE_VARIATION_NOTICE_DISMISSED_OPTION, - ], - ] + ), + ) ); // Product Inventory Section. $product_inventory_section = $inventory_group->add_section( - [ + array( 'id' => 'product-variation-inventory-section', 'order' => 20, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Inventory', 'woocommerce' ), 'description' => sprintf( /* translators: %1$s: Inventory settings link opening tag. %2$s: Inventory settings link closing tag.*/ @@ -365,28 +366,28 @@ class ProductVariationTemplate extends AbstractProductFormTemplate implements Pr '' ), 'blockGap' => 'unit-40', - ], - ] + ), + ) ); $product_inventory_inner_section = $product_inventory_section->add_section( - [ + array( 'id' => 'product-variation-inventory-inner-section', 'order' => 10, - ] + ) ); $product_inventory_inner_section->add_block( - [ + array( 'id' => 'product-variation-sku-field', 'blockName' => 'woocommerce/product-sku-field', 'order' => 10, - ] + ) ); $product_inventory_inner_section->add_block( - [ + array( 'id' => 'product-variation-track-stock', 'blockName' => 'woocommerce/product-toggle-field', 'order' => 20, - 'attributes' => [ + 'attributes' => array( 'label' => __( 'Track stock quantity for this product', 'woocommerce' ), 'property' => 'manage_stock', 'disabled' => 'yes' !== get_option( 'woocommerce_manage_stock' ), @@ -396,64 +397,64 @@ class ProductVariationTemplate extends AbstractProductFormTemplate implements Pr '', '' ), - ], - ] + ), + ) ); $product_inventory_quantity_conditional = $product_inventory_inner_section->add_block( - [ + array( 'id' => 'product-variation-inventory-quantity-conditional-wrapper', 'blockName' => 'woocommerce/conditional', 'order' => 30, - 'attributes' => [ - 'mustMatch' => [ - 'manage_stock' => [ true ], - ], - ], - ] + 'attributes' => array( + 'mustMatch' => array( + 'manage_stock' => array( true ), + ), + ), + ) ); $product_inventory_quantity_conditional->add_block( - [ + array( 'id' => 'product-variation-inventory-quantity', 'blockName' => 'woocommerce/product-inventory-quantity-field', 'order' => 10, - ] + ) ); $product_stock_status_conditional = $product_inventory_section->add_block( - [ + array( 'id' => 'product-variation-stock-status-conditional-wrapper', 'blockName' => 'woocommerce/conditional', 'order' => 20, - 'attributes' => [ - 'mustMatch' => [ - 'manage_stock' => [ false ], - ], - ], - ] + 'attributes' => array( + 'mustMatch' => array( + 'manage_stock' => array( false ), + ), + ), + ) ); $product_stock_status_conditional->add_block( - [ + array( 'id' => 'product-variation-stock-status', 'blockName' => 'woocommerce/product-radio-field', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Stock status', 'woocommerce' ), 'property' => 'stock_status', - 'options' => [ - [ + 'options' => array( + array( 'label' => __( 'In stock', 'woocommerce' ), 'value' => 'instock', - ], - [ + ), + array( 'label' => __( 'Out of stock', 'woocommerce' ), 'value' => 'outofstock', - ], - [ + ), + array( 'label' => __( 'On backorder', 'woocommerce' ), 'value' => 'onbackorder', - ], - ], - ], - ] + ), + ), + ), + ) ); } @@ -463,43 +464,43 @@ class ProductVariationTemplate extends AbstractProductFormTemplate implements Pr private function add_shipping_group_blocks() { $shipping_group = $this->get_group_by_id( $this::GROUP_IDS['SHIPPING'] ); $shipping_group->add_block( - [ + array( 'id' => 'shipping-single-variation-notice', 'blockName' => 'woocommerce/product-single-variation-notice', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'content' => __( 'You’re editing details specific to this variation. Some information, like description and images, will be inherited from the main product, .', 'woocommerce' ), 'type' => 'info', 'isDismissible' => true, 'name' => $this::SINGLE_VARIATION_NOTICE_DISMISSED_OPTION, - ], - ] + ), + ) ); // Virtual section. $shipping_group->add_section( - [ + array( 'id' => 'product-variation-virtual-section', 'order' => 20, - ] + ) )->add_block( - [ + array( 'id' => 'product-variation-virtual', 'blockName' => 'woocommerce/product-toggle-field', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'property' => 'virtual', 'checkedValue' => false, 'uncheckedValue' => true, 'label' => __( 'This variation requires shipping or pickup', 'woocommerce' ), - ], - ] + ), + ) ); // Product Shipping Section. $product_fee_and_dimensions_section = $shipping_group->add_section( - [ + array( 'id' => 'product-variation-fee-and-dimensions-section', 'order' => 30, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Fees & dimensions', 'woocommerce' ), 'description' => sprintf( /* translators: %1$s: How to get started? link opening tag. %2$s: How to get started? link closing tag.*/ @@ -507,22 +508,22 @@ class ProductVariationTemplate extends AbstractProductFormTemplate implements Pr '', '' ), - ], - ] + ), + ) ); $product_fee_and_dimensions_section->add_block( - [ + array( 'id' => 'product-variation-shipping-class', 'blockName' => 'woocommerce/product-shipping-class-field', 'order' => 10, - ] + ) ); $product_fee_and_dimensions_section->add_block( - [ + array( 'id' => 'product-variation-shipping-dimensions', 'blockName' => 'woocommerce/product-shipping-dimensions-fields', 'order' => 20, - ] + ) ); } } diff --git a/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/ProductTemplates/Section.php b/plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/Section.php similarity index 82% rename from plugins/woocommerce/src/Admin/Features/ProductBlockEditor/ProductTemplates/Section.php rename to plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/Section.php index 99660e19d00..4205dcfe849 100644 --- a/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/ProductTemplates/Section.php +++ b/plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/Section.php @@ -3,16 +3,17 @@ * WooCommerce Section Block class. */ -namespace Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates; +namespace Automattic\WooCommerce\Internal\Admin\Features\ProductBlockEditor\ProductTemplates; use Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface; use Automattic\WooCommerce\Admin\BlockTemplates\ContainerInterface; +use Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates\SectionInterface; /** * Class for Section block. */ class Section extends ProductBlock implements SectionInterface { - + // phpcs:disable Squiz.Commenting.FunctionCommentThrowTag.WrongNumber /** * Section Block constructor. * @@ -30,6 +31,7 @@ class Section extends ProductBlock implements SectionInterface { } parent::__construct( array_merge( array( 'blockName' => 'woocommerce/product-section' ), $config ), $root_template, $parent ); } + // phpcs:enable Squiz.Commenting.FunctionCommentThrowTag.WrongNumber /** * Add a section block type to this template. diff --git a/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/ProductTemplates/SimpleProductTemplate.php b/plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/SimpleProductTemplate.php similarity index 86% rename from plugins/woocommerce/src/Admin/Features/ProductBlockEditor/ProductTemplates/SimpleProductTemplate.php rename to plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/SimpleProductTemplate.php index a28f2229b00..39e2d4dac1c 100644 --- a/plugins/woocommerce/src/Admin/Features/ProductBlockEditor/ProductTemplates/SimpleProductTemplate.php +++ b/plugins/woocommerce/src/Internal/Features/ProductBlockEditor/ProductTemplates/SimpleProductTemplate.php @@ -3,9 +3,10 @@ * SimpleProductTemplate */ -namespace Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates; +namespace Automattic\WooCommerce\Internal\Admin\Features\ProductBlockEditor\ProductTemplates; use Automattic\WooCommerce\Admin\Features\Features; +use Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates\ProductFormTemplateInterface; /** * Simple Product Template. @@ -62,59 +63,59 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ */ private function add_group_blocks() { $this->add_group( - [ + array( 'id' => $this::GROUP_IDS['GENERAL'], 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'General', 'woocommerce' ), - ], - ] + ), + ) ); $this->add_group( - [ + array( 'id' => $this::GROUP_IDS['ORGANIZATION'], 'order' => 15, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Organization', 'woocommerce' ), - ], - ] + ), + ) ); $this->add_group( - [ + array( 'id' => $this::GROUP_IDS['PRICING'], 'order' => 20, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Pricing', 'woocommerce' ), - ], - ] + ), + ) ); $this->add_group( - [ + array( 'id' => $this::GROUP_IDS['INVENTORY'], 'order' => 30, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Inventory', 'woocommerce' ), - ], - ] + ), + ) ); $this->add_group( - [ + array( 'id' => $this::GROUP_IDS['SHIPPING'], 'order' => 40, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Shipping', 'woocommerce' ), - ], - ] + ), + ) ); if ( Features::is_enabled( 'product-variation-management' ) ) { $this->add_group( - [ + array( 'id' => $this::GROUP_IDS['VARIATIONS'], 'order' => 50, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Variations', 'woocommerce' ), - ], - ] + ), + ) ); } } @@ -126,111 +127,111 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ $general_group = $this->get_group_by_id( $this::GROUP_IDS['GENERAL'] ); // Basic Details Section. $basic_details = $general_group->add_section( - [ + array( 'id' => 'basic-details', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Basic details', 'woocommerce' ), 'description' => __( 'This info will be displayed on the product page, category pages, social media, and search results.', 'woocommerce' ), - ], - ] + ), + ) ); $basic_details->add_block( - [ + array( 'id' => 'product-name', 'blockName' => 'woocommerce/product-name-field', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'name' => 'Product name', 'autoFocus' => true, - ], - ] + ), + ) ); $basic_details->add_block( - [ + array( 'id' => 'product-summary', 'blockName' => 'woocommerce/product-summary-field', 'order' => 20, - 'attributes' => [ + 'attributes' => array( 'property' => 'short_description', - ], - ] + ), + ) ); $pricing_columns = $basic_details->add_block( - [ + array( 'id' => 'product-pricing-columns', 'blockName' => 'core/columns', 'order' => 30, - ] + ) ); $pricing_column_1 = $pricing_columns->add_block( - [ + array( 'id' => 'product-pricing-column-1', 'blockName' => 'core/column', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'templateLock' => 'all', - ], - ] + ), + ) ); $pricing_column_1->add_block( - [ + array( 'id' => 'product-regular-price', 'blockName' => 'woocommerce/product-regular-price-field', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'name' => 'regular_price', 'label' => __( 'List price', 'woocommerce' ), /* translators: PricingTab: This is a link tag to the pricing tab. */ 'help' => __( 'Manage more settings in Pricing.', 'woocommerce' ), - ], - ] + ), + ) ); $pricing_column_2 = $pricing_columns->add_block( - [ + array( 'id' => 'product-pricing-column-2', 'blockName' => 'core/column', 'order' => 20, - 'attributes' => [ + 'attributes' => array( 'templateLock' => 'all', - ], - ] + ), + ) ); $pricing_column_2->add_block( - [ + array( 'id' => 'product-sale-price', 'blockName' => 'woocommerce/product-sale-price-field', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'label' => __( 'Sale price', 'woocommerce' ), - ], - ] + ), + ) ); // Description section. $description_section = $general_group->add_section( - [ + array( 'id' => 'product-description-section', 'order' => 20, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Description', 'woocommerce' ), 'description' => __( 'What makes this product unique? What are its most important features? Enrich the product page by adding rich content using blocks.', 'woocommerce' ), - ], - ] + ), + ) ); $description_section->add_block( - [ + array( 'id' => 'product-description', 'blockName' => 'woocommerce/product-description-field', 'order' => 10, - ] + ) ); // Images section. $images_section = $general_group->add_section( - [ + array( 'id' => 'product-images-section', 'order' => 30, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Images', 'woocommerce' ), 'description' => sprintf( /* translators: %1$s: Images guide link opening tag. %2$s: Images guide link closing tag. */ @@ -238,37 +239,37 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ '', '' ), - ], - ] + ), + ) ); $images_section->add_block( - [ + array( 'id' => 'product-images', 'blockName' => 'woocommerce/product-images-field', 'order' => 10, - 'attributes' => [ - 'images' => [], + 'attributes' => array( + 'images' => array(), 'property' => 'images', - ], - ] + ), + ) ); // Downloads section. if ( Features::is_enabled( 'product-virtual-downloadable' ) ) { $general_group->add_section( - [ + array( 'id' => 'product-downloads-section', 'order' => 40, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Downloads', 'woocommerce' ), 'description' => __( "Add any files you'd like to make available for the customer to download after purchasing, such as instructions or warranty info.", 'woocommerce' ), - ], - ] + ), + ) )->add_block( - [ + array( 'id' => 'product-downloads', 'blockName' => 'woocommerce/product-downloads-field', 'order' => 10, - ] + ) ); } } @@ -280,97 +281,97 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ $organization_group = $this->get_group_by_id( $this::GROUP_IDS['ORGANIZATION'] ); // Product Catalog Section. $product_catalog_section = $organization_group->add_section( - [ + array( 'id' => 'product-catalog-section', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Product catalog', 'woocommerce' ), - ], - ] + ), + ) ); $product_catalog_section->add_block( - [ + array( 'id' => 'product-categories', 'blockName' => 'woocommerce/product-taxonomy-field', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'slug' => 'product_cat', 'property' => 'categories', 'label' => __( 'Categories', 'woocommerce' ), 'createTitle' => __( 'Create new category', 'woocommerce' ), 'dialogNameHelpText' => __( 'Shown to customers on the product page.', 'woocommerce' ), 'parentTaxonomyText' => __( 'Parent category', 'woocommerce' ), - ], - ] + ), + ) ); $product_catalog_section->add_block( - [ + array( 'id' => 'product-tags', 'blockName' => 'woocommerce/product-tag-field', - 'attributes' => [ + 'attributes' => array( 'name' => 'tags', - ], - ] + ), + ) ); $product_catalog_section->add_block( - [ + array( 'id' => 'product-catalog-search-visibility', 'blockName' => 'woocommerce/product-catalog-visibility-field', 'order' => 20, - 'attributes' => [ + 'attributes' => array( 'label' => __( 'Hide in product catalog', 'woocommerce' ), 'visibility' => 'search', - ], - ] + ), + ) ); $product_catalog_section->add_block( - [ + array( 'id' => 'product-catalog-catalog-visibility', 'blockName' => 'woocommerce/product-catalog-visibility-field', 'order' => 30, - 'attributes' => [ + 'attributes' => array( 'label' => __( 'Hide from search results', 'woocommerce' ), 'visibility' => 'catalog', - ], - ] + ), + ) ); $product_catalog_section->add_block( - [ + array( 'id' => 'product-enable-product-reviews', 'blockName' => 'woocommerce/product-checkbox-field', 'order' => 40, - 'attributes' => [ + 'attributes' => array( 'label' => __( 'Enable product reviews', 'woocommerce' ), 'property' => 'reviews_allowed', - ], - ] + ), + ) ); $product_catalog_section->add_block( - [ + array( 'id' => 'product-post-password', 'blockName' => 'woocommerce/product-password-field', 'order' => 50, - 'attributes' => [ + 'attributes' => array( 'label' => __( 'Require a password', 'woocommerce' ), - ], - ] + ), + ) ); // Attributes section. $product_catalog_section = $organization_group->add_section( - [ + array( 'id' => 'product-attributes-section', 'order' => 20, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Attributes', 'woocommerce' ), - ], - ] + ), + ) ); $product_catalog_section->add_block( - [ + array( 'id' => 'product-attributes', 'blockName' => 'woocommerce/product-attributes-field', 'order' => 10, - ] + ) ); } @@ -380,23 +381,23 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ private function add_pricing_group_blocks() { $pricing_group = $this->get_group_by_id( $this::GROUP_IDS['PRICING'] ); $pricing_group->add_block( - [ + array( 'id' => 'pricing-has-variations-notice', 'blockName' => 'woocommerce/product-has-variations-notice', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'content' => __( 'This product has options, such as size or color. You can now manage each variation\'s price and other details individually.', 'woocommerce' ), 'buttonText' => __( 'Go to Variations', 'woocommerce' ), 'type' => 'info', - ], - ] + ), + ) ); // Product Pricing Section. $product_pricing_section = $pricing_group->add_section( - [ + array( 'id' => 'product-pricing-section', 'order' => 20, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Pricing', 'woocommerce' ), 'description' => sprintf( /* translators: %1$s: Images guide link opening tag. %2$s: Images guide link closing tag.*/ @@ -405,107 +406,107 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ '' ), 'blockGap' => 'unit-40', - ], - ] + ), + ) ); $pricing_columns = $product_pricing_section->add_block( - [ + array( 'id' => 'product-pricing-group-pricing-columns', 'blockName' => 'core/columns', 'order' => 10, - ] + ) ); $pricing_column_1 = $pricing_columns->add_block( - [ + array( 'id' => 'product-pricing-group-pricing-column-1', 'blockName' => 'core/column', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'templateLock' => 'all', - ], - ] + ), + ) ); $pricing_column_1->add_block( - [ + array( 'id' => 'product-pricing-regular-price', 'blockName' => 'woocommerce/product-regular-price-field', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'name' => 'regular_price', 'label' => __( 'List price', 'woocommerce' ), - ], - ] + ), + ) ); $pricing_column_2 = $pricing_columns->add_block( - [ + array( 'id' => 'product-pricing-group-pricing-column-2', 'blockName' => 'core/column', 'order' => 20, - 'attributes' => [ + 'attributes' => array( 'templateLock' => 'all', - ], - ] + ), + ) ); $pricing_column_2->add_block( - [ + array( 'id' => 'product-pricing-sale-price', 'blockName' => 'woocommerce/product-sale-price-field', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'label' => __( 'Sale price', 'woocommerce' ), - ], - ] + ), + ) ); $product_pricing_section->add_block( - [ + array( 'id' => 'product-pricing-schedule-sale-fields', 'blockName' => 'woocommerce/product-schedule-sale-fields', 'order' => 20, - ] + ) ); $product_pricing_section->add_block( - [ + array( 'id' => 'product-sale-tax', 'blockName' => 'woocommerce/product-radio-field', 'order' => 30, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Charge sales tax on', 'woocommerce' ), 'property' => 'tax_status', - 'options' => [ - [ + 'options' => array( + array( 'label' => __( 'Product and shipping', 'woocommerce' ), 'value' => 'taxable', - ], - [ + ), + array( 'label' => __( 'Only shipping', 'woocommerce' ), 'value' => 'shipping', - ], - [ + ), + array( 'label' => __( "Don't charge tax", 'woocommerce' ), 'value' => 'none', - ], - ], - ], - ] + ), + ), + ), + ) ); $pricing_advanced_block = $product_pricing_section->add_block( - [ + array( 'id' => 'product-pricing-advanced', 'blockName' => 'woocommerce/product-collapsible', 'order' => 40, - 'attributes' => [ + 'attributes' => array( 'toggleText' => __( 'Advanced', 'woocommerce' ), 'initialCollapsed' => true, 'persistRender' => true, - ], - ] + ), + ) ); $pricing_advanced_block->add_block( - [ + array( 'id' => 'product-tax-class', 'blockName' => 'woocommerce/product-radio-field', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Tax class', 'woocommerce' ), 'description' => sprintf( /* translators: %1$s: Learn more link opening tag. %2$s: Learn more link closing tag.*/ @@ -514,22 +515,22 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ '' ), 'property' => 'tax_class', - 'options' => [ - [ + 'options' => array( + array( 'label' => __( 'Standard', 'woocommerce' ), 'value' => '', - ], - [ + ), + array( 'label' => __( 'Reduced rate', 'woocommerce' ), 'value' => 'reduced-rate', - ], - [ + ), + array( 'label' => __( 'Zero rate', 'woocommerce' ), 'value' => 'zero-rate', - ], - ], - ], - ] + ), + ), + ), + ) ); } @@ -539,23 +540,23 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ private function add_inventory_group_blocks() { $inventory_group = $this->get_group_by_id( $this::GROUP_IDS['INVENTORY'] ); $inventory_group->add_block( - [ + array( 'id' => 'product_variation_notice_inventory_tab', 'blockName' => 'woocommerce/product-has-variations-notice', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'content' => __( 'This product has options, such as size or color. You can now manage each variation\'s price and other details individually.', 'woocommerce' ), 'buttonText' => __( 'Go to Variations', 'woocommerce' ), 'type' => 'info', - ], - ] + ), + ) ); // Product Pricing Section. $product_inventory_section = $inventory_group->add_section( - [ + array( 'id' => 'product-inventory-section', 'order' => 20, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Inventory', 'woocommerce' ), 'description' => sprintf( /* translators: %1$s: Inventory settings link opening tag. %2$s: Inventory settings link closing tag.*/ @@ -564,28 +565,28 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ '' ), 'blockGap' => 'unit-40', - ], - ] + ), + ) ); $product_inventory_inner_section = $product_inventory_section->add_section( - [ + array( 'id' => 'product-inventory-inner-section', 'order' => 10, - ] + ) ); $product_inventory_inner_section->add_block( - [ + array( 'id' => 'product-sku-field', 'blockName' => 'woocommerce/product-sku-field', 'order' => 10, - ] + ) ); $product_inventory_inner_section->add_block( - [ + array( 'id' => 'product-track-stock', 'blockName' => 'woocommerce/product-toggle-field', 'order' => 20, - 'attributes' => [ + 'attributes' => array( 'label' => __( 'Track stock quantity for this product', 'woocommerce' ), 'property' => 'manage_stock', 'disabled' => 'yes' !== get_option( 'woocommerce_manage_stock' ), @@ -595,140 +596,140 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ '', '' ), - ], - ] + ), + ) ); $product_inventory_quantity_conditional = $product_inventory_inner_section->add_block( - [ + array( 'id' => 'product-inventory-quantity-conditional-wrapper', 'blockName' => 'woocommerce/conditional', 'order' => 30, - 'attributes' => [ - 'mustMatch' => [ - 'manage_stock' => [ true ], - ], - ], - ] + 'attributes' => array( + 'mustMatch' => array( + 'manage_stock' => array( true ), + ), + ), + ) ); $product_inventory_quantity_conditional->add_block( - [ + array( 'id' => 'product-inventory-quantity', 'blockName' => 'woocommerce/product-inventory-quantity-field', 'order' => 10, - ] + ) ); $product_stock_status_conditional = $product_inventory_section->add_block( - [ + array( 'id' => 'product-stock-status-conditional-wrapper', 'blockName' => 'woocommerce/conditional', 'order' => 20, - 'attributes' => [ - 'mustMatch' => [ - 'manage_stock' => [ false ], - ], - ], - ] + 'attributes' => array( + 'mustMatch' => array( + 'manage_stock' => array( false ), + ), + ), + ) ); $product_stock_status_conditional->add_block( - [ + array( 'id' => 'product-stock-status', 'blockName' => 'woocommerce/product-radio-field', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Stock status', 'woocommerce' ), 'property' => 'stock_status', - 'options' => [ - [ + 'options' => array( + array( 'label' => __( 'In stock', 'woocommerce' ), 'value' => 'instock', - ], - [ + ), + array( 'label' => __( 'Out of stock', 'woocommerce' ), 'value' => 'outofstock', - ], - [ + ), + array( 'label' => __( 'On backorder', 'woocommerce' ), 'value' => 'onbackorder', - ], - ], - ], - ] + ), + ), + ), + ) ); $product_inventory_advanced = $product_inventory_section->add_block( - [ + array( 'id' => 'product-inventory-advanced', 'blockName' => 'woocommerce/product-collapsible', 'order' => 30, - 'attributes' => [ + 'attributes' => array( 'toggleText' => __( 'Advanced', 'woocommerce' ), 'initialCollapsed' => true, 'persistRender' => true, - ], - ] + ), + ) ); $product_inventory_advanced_wrapper = $product_inventory_advanced->add_block( - [ + array( 'blockName' => 'woocommerce/product-section', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'blockGap' => 'unit-40', - ], - ] + ), + ) ); $product_out_of_stock_conditional = $product_inventory_advanced_wrapper->add_block( - [ + array( 'id' => 'product-out-of-stock-conditional-wrapper', 'blockName' => 'woocommerce/conditional', 'order' => 10, - 'attributes' => [ - 'mustMatch' => [ - 'manage_stock' => [ true ], - ], - ], - ] + 'attributes' => array( + 'mustMatch' => array( + 'manage_stock' => array( true ), + ), + ), + ) ); $product_out_of_stock_conditional->add_block( - [ + array( 'id' => 'product-out-of-stock', 'blockName' => 'woocommerce/product-radio-field', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'When out of stock', 'woocommerce' ), 'property' => 'backorders', - 'options' => [ - [ + 'options' => array( + array( 'label' => __( 'Allow purchases', 'woocommerce' ), 'value' => 'yes', - ], - [ + ), + array( 'label' => __( 'Allow purchases, but notify customers', 'woocommerce' ), 'value' => 'notify', - ], - [ + ), + array( 'label' => __( "Don't allow purchases", 'woocommerce' ), 'value' => 'no', - ], - ], - ], - ] + ), + ), + ), + ) ); $product_out_of_stock_conditional->add_block( - [ + array( 'id' => 'product-inventory-email', 'blockName' => 'woocommerce/product-inventory-email-field', 'order' => 20, - ] + ) ); $product_inventory_advanced_wrapper->add_block( - [ + array( 'id' => 'product-limit-purchase', 'blockName' => 'woocommerce/product-checkbox-field', 'order' => 20, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Restrictions', 'woocommerce' @@ -742,8 +743,8 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ 'When checked, customers will be able to purchase only 1 item in a single order. This is particularly useful for items that have limited quantity, like art or handmade goods.', 'woocommerce' ), - ], - ] + ), + ) ); } @@ -753,42 +754,42 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ private function add_shipping_group_blocks() { $shipping_group = $this->get_group_by_id( $this::GROUP_IDS['SHIPPING'] ); $shipping_group->add_block( - [ + array( 'id' => 'product_variation_notice_shipping_tab', 'blockName' => 'woocommerce/product-has-variations-notice', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'content' => __( 'This product has options, such as size or color. You can now manage each variation\'s price and other details individually.', 'woocommerce' ), 'buttonText' => __( 'Go to Variations', 'woocommerce' ), 'type' => 'info', - ], - ] + ), + ) ); // Virtual section. $shipping_group->add_section( - [ + array( 'id' => 'product-virtual-section', 'order' => 10, - ] + ) )->add_block( - [ + array( 'id' => 'product-virtual', 'blockName' => 'woocommerce/product-toggle-field', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'property' => 'virtual', 'checkedValue' => false, 'uncheckedValue' => true, 'label' => __( 'This product requires shipping or pickup', 'woocommerce' ), - ], - ] + ), + ) ); // Product Shipping Section. $product_fee_and_dimensions_section = $shipping_group->add_section( - [ + array( 'id' => 'product-fee-and-dimensions-section', 'order' => 20, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Fees & dimensions', 'woocommerce' ), 'description' => sprintf( /* translators: %1$s: How to get started? link opening tag. %2$s: How to get started? link closing tag.*/ @@ -796,22 +797,22 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ '', '' ), - ], - ] + ), + ) ); $product_fee_and_dimensions_section->add_block( - [ + array( 'id' => 'product-shipping-class', 'blockName' => 'woocommerce/product-shipping-class-field', 'order' => 10, - ] + ) ); $product_fee_and_dimensions_section->add_block( - [ + array( 'id' => 'product-shipping-dimensions', 'blockName' => 'woocommerce/product-shipping-dimensions-fields', 'order' => 20, - ] + ) ); } @@ -824,55 +825,55 @@ class SimpleProductTemplate extends AbstractProductFormTemplate implements Produ return; } $variation_fields = $variation_group->add_block( - [ + array( 'id' => 'product_variation-field-group', 'blockName' => 'woocommerce/product-variations-fields', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'description' => sprintf( /* translators: %1$s: Sell your product in multiple variations like size or color. strong opening tag. %2$s: Sell your product in multiple variations like size or color. strong closing tag.*/ __( '%1$sSell your product in multiple variations like size or color.%2$s Get started by adding options for the buyers to choose on the product page.', 'woocommerce' ), '', '' ), - ], - ] + ), + ) ); $variation_options_section = $variation_fields->add_block( - [ + array( 'id' => 'product-variation-options-section', 'blockName' => 'woocommerce/product-section', 'order' => 10, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Variation options', 'woocommerce' ), 'description' => __( 'Add and manage attributes used for product options, such as size and color.', 'woocommerce' ), - ], - ] + ), + ) ); $variation_options_section->add_block( - [ + array( 'id' => 'product-variation-options', 'blockName' => 'woocommerce/product-variations-options-field', - ] + ) ); $variation_section = $variation_fields->add_block( - [ + array( 'id' => 'product-variation-section', 'blockName' => 'woocommerce/product-section', 'order' => 20, - 'attributes' => [ + 'attributes' => array( 'title' => __( 'Variations', 'woocommerce' ), 'description' => __( 'Manage individual product combinations created from options.', 'woocommerce' ), - ], - ] + ), + ) ); $variation_section->add_block( - [ + array( 'id' => 'product-variation-items', 'blockName' => 'woocommerce/product-variation-items-field', 'order' => 10, - ] + ) ); } } diff --git a/plugins/woocommerce/tests/php/src/Admin/ProductBlockEditor/ProductTemplates/CustomProductFormTemplate.php b/plugins/woocommerce/tests/php/src/Admin/ProductBlockEditor/ProductTemplates/CustomProductFormTemplate.php index 58a805e6351..f1a056ec689 100644 --- a/plugins/woocommerce/tests/php/src/Admin/ProductBlockEditor/ProductTemplates/CustomProductFormTemplate.php +++ b/plugins/woocommerce/tests/php/src/Admin/ProductBlockEditor/ProductTemplates/CustomProductFormTemplate.php @@ -2,7 +2,7 @@ namespace Automattic\WooCommerce\Tests\Admin\ProductBlockEditor\ProductTemplates; -use Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates\AbstractProductFormTemplate; +use Automattic\WooCommerce\Internal\Admin\Features\ProductBlockEditor\ProductTemplates\AbstractProductFormTemplate; use Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates\ProductFormTemplateInterface; class CustomProductFormTemplate extends AbstractProductFormTemplate implements ProductFormTemplateInterface {