Automattic\WooCommerce\Internal\Features\ProductBlockEditor\ProductTemplates

SimpleProductTemplate::add_organization_group_blocksprivateWC 1.0

Adds the organization group blocks to the template.

Метод класса: SimpleProductTemplate{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

// private - только в коде основоного (родительского) класса
$result = $this->add_organization_group_blocks();

Код SimpleProductTemplate::add_organization_group_blocks() WC 10.4.3

private function add_organization_group_blocks() {
	$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' => array(
				'title'       => __( 'Product catalog', 'woocommerce' ),
				'description' => __( 'Help customers find this product by assigning it to categories, adding extra details, and managing its visibility in your store and other channels.', 'woocommerce' ),
			),
		)
	);
	$product_catalog_section->add_block(
		array(
			'id'         => 'product-categories',
			'blockName'  => 'woocommerce/product-taxonomy-field',
			'order'      => 10,
			'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' ),
				'placeholder'        => __( 'Search or create categories…', 'woocommerce' ),
			),
		)
	);
	$product_catalog_section->add_block(
		array(
			'id'         => 'product-tags',
			'blockName'  => 'woocommerce/product-tag-field',
			'attributes' => array(
				'name' => 'tags',
			),
		)
	);
	$product_catalog_section->add_block(
		array(
			'id'         => 'product-catalog-search-visibility',
			'blockName'  => 'woocommerce/product-catalog-visibility-field',
			'order'      => 20,
			'attributes' => array(
				'label'      => __( 'Hide in product catalog', 'woocommerce' ),
				'visibility' => CatalogVisibility::SEARCH,
			),
		)
	);
	$product_catalog_section->add_block(
		array(
			'id'         => 'product-catalog-catalog-visibility',
			'blockName'  => 'woocommerce/product-catalog-visibility-field',
			'order'      => 30,
			'attributes' => array(
				'label'      => __( 'Hide from search results', 'woocommerce' ),
				'visibility' => CatalogVisibility::CATALOG,
			),
		)
	);
	$product_catalog_section->add_block(
		array(
			'id'         => 'product-enable-product-reviews',
			'blockName'  => 'woocommerce/product-checkbox-field',
			'order'      => 40,
			'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' => array(
				'label' => __( 'Require a password', 'woocommerce' ),
			),
		)
	);
	// Attributes section.
	$product_attributes_section = $organization_group->add_section(
		array(
			'id'         => 'product-attributes-section',
			'order'      => 20,
			'attributes' => array(
				'title'       => __( 'Attributes', 'woocommerce' ),
				'description' => __( 'Use global attributes to allow shoppers to filter and search for this product. Use custom attributes to provide detailed product information.', 'woocommerce' ),
				'blockGap'    => 'unit-40',
			),
		)
	);
	$product_attributes_section->add_block(
		array(
			'id'        => 'product-attributes',
			'blockName' => 'woocommerce/product-attributes-field',
			'order'     => 10,
		)
	);

	if ( Features::is_enabled( 'product-custom-fields' ) ) {
		$organization_group->add_section(
			array(
				'id'    => 'product-custom-fields-wrapper-section',
				'order' => 30,
			)
		)->add_block(
			array(
				'id'         => 'product-custom-fields-toggle',
				'blockName'  => 'woocommerce/product-custom-fields-toggle-field',
				'order'      => 10,
				'attributes' => array(
					'label' => __( 'Show custom fields', 'woocommerce' ),
				),
			)
		)->add_block(
			array(
				'id'         => 'product-custom-fields-section',
				'blockName'  => 'woocommerce/product-section',
				'order'      => 10,
				'attributes' => array(
					'blockGap'    => 'unit-30',
					'title'       => __( 'Custom fields', 'woocommerce' ),
					'description' => sprintf(
						/* translators: %1$s: Custom fields guide link opening tag. %2$s: Custom fields guide link closing tag. */
						__( 'Custom fields can be used in a variety of ways, such as sharing more detailed product information, showing more input fields, or for internal inventory organization. %1$sRead more about custom fields%2$s', 'woocommerce' ),
						'<a href="https://woocommerce.com/document/custom-product-fields/" target="_blank" rel="noreferrer">',
						'</a>'
					),
				),
			)
		)->add_block(
			array(
				'id'        => 'product-custom-fields',
				'blockName' => 'woocommerce/product-custom-fields',
				'order'     => 10,
			)
		);
	}
}