Automattic\WooCommerce\Internal\Features\ProductBlockEditor\ProductTemplates

ProductVariationTemplate::add_general_group_blocks()protectedWC 1.0

Adds the general group blocks to the template.

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

Хуков нет.

Возвращает

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

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

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

Код ProductVariationTemplate::add_general_group_blocks() WC 9.4.2

protected function add_general_group_blocks() {
	$is_calc_taxes_enabled = wc_tax_enabled();

	$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' => array(
				'content'       => __( '<strong>You’re editing details specific to this variation.</strong> Some information, like description and images, will be inherited from the main product, <noticeLink><parentProductName/></noticeLink>.', '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' => array(
				'title'       => __( 'Variation details', 'woocommerce' ),
				'description' => __( 'This info will be displayed on the product page, category pages, social media, and search results.', 'woocommerce' ),
			),
		)
	);

	// Product Pricing columns.
	$pricing_columns  = $basic_details->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' => array(
				'templateLock' => 'all',
			),
		)
	);
	$pricing_column_1->add_block(
		array(
			'id'         => 'product-pricing-regular-price',
			'blockName'  => 'woocommerce/product-regular-price-field',
			'order'      => 10,
			'attributes' => array(
				'name'       => 'regular_price',
				'label'      => __( 'Regular price', 'woocommerce' ),
				'isRequired' => true,
				'help'       => $is_calc_taxes_enabled ? null : sprintf(
				/* translators: %1$s: store settings link opening tag. %2$s: store settings link closing tag.*/
					__( 'Per your %1$sstore settings%2$s, taxes are not enabled.', 'woocommerce' ),
					'<a href="' . admin_url( 'admin.php?page=wc-settings&tab=general' ) . '" target="_blank" rel="noreferrer">',
					'</a>'
				),
			),
		)
	);
	$pricing_column_2 = $pricing_columns->add_block(
		array(
			'id'         => 'product-pricing-group-pricing-column-2',
			'blockName'  => 'core/column',
			'order'      => 20,
			'attributes' => array(
				'templateLock' => 'all',
			),
		)
	);
	$pricing_column_2->add_block(
		array(
			'id'         => 'product-pricing-sale-price',
			'blockName'  => 'woocommerce/product-sale-price-field',
			'order'      => 10,
			'attributes' => array(
				'label' => __( 'Sale price', 'woocommerce' ),
			),
		)
	);
	$basic_details->add_block(
		array(
			'id'        => 'product-pricing-schedule-sale-fields',
			'blockName' => 'woocommerce/product-schedule-sale-fields',
			'order'     => 20,
		)
	);

	if ( $is_calc_taxes_enabled ) {
		$basic_details->add_block(
			array(
				'id'         => 'product-tax-class',
				'blockName'  => 'woocommerce/product-select-field',
				'order'      => 40,
				'attributes' => array(
					'label'    => __( 'Tax class', 'woocommerce' ),
					'help'     => sprintf(
					/* translators: %1$s: Learn more link opening tag. %2$s: Learn more link closing tag.*/
						__( 'Apply a tax rate if this product qualifies for tax reduction or exemption. %1$sLearn more%2$s', 'woocommerce' ),
						'<a href="https://woocommerce.com/document/setting-up-taxes-in-woocommerce/#shipping-tax-class" target="_blank" rel="noreferrer">',
						'</a>'
					),
					'property' => 'tax_class',
					'options'  => SimpleProductTemplate::get_tax_classes( 'product_variation' ),
				),
			)
		);
	}

	$basic_details->add_block(
		array(
			'id'         => 'product-variation-note',
			'blockName'  => 'woocommerce/product-text-area-field',
			'order'      => 20,
			'attributes' => array(
				'property' => 'description',
				'label'    => __( 'Note', 'woocommerce' ),
				'help'     => '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' => 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' => array(
				'title'       => __( 'Image', 'woocommerce' ),
				'description' => sprintf(
				/* translators: %1$s: Images guide link opening tag. %2$s: Images guide link closing tag. */
					__( 'Drag images, upload new ones or select files from your library. For best results, use JPEG files that are 1000 by 1000 pixels or larger. %1$sHow to prepare images?%2$s', 'woocommerce' ),
					'<a href="https://woocommerce.com/posts/how-to-take-professional-product-photos-top-tips" target="_blank" rel="noreferrer">',
					'</a>'
				),
			),
		)
	);
	$images_section->add_block(
		array(
			'id'         => 'product-variation-image',
			'blockName'  => 'woocommerce/product-images-field',
			'order'      => 10,
			'attributes' => array(
				'property' => 'image',
				'multiple' => false,
			),
		)
	);

	// Downloads section.
	$this->add_downloadable_product_blocks( $general_group );
}