Automattic\WooCommerce\Internal\Features\ProductBlockEditor\ProductTemplates

ProductVariationTemplate::add_shipping_group_blocks()protectedWC 1.0

Adds the shipping group blocks to the template.

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

Хуков нет.

Возвращает

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

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

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

Код ProductVariationTemplate::add_shipping_group_blocks() WC 9.4.2

protected 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' => 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,
			),
		)
	);
	// 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' => array(
				'property'       => 'virtual',
				'checkedValue'   => false,
				'uncheckedValue' => true,
				'label'          => __( 'This variation requires shipping or pickup', 'woocommerce' ),
				'uncheckedHelp'  => __( 'This variation will not trigger your customer\'s shipping calculator in cart or at checkout. This product also won\'t require your customers to enter their shipping details at checkout. <a href="https://woocommerce.com/document/managing-products/#adding-a-virtual-product" target="_blank" rel="noreferrer">Read more about virtual products</a>.', 'woocommerce' ),
			),
		)
	);
	// Product Shipping Section.
	$product_fee_and_dimensions_section = $shipping_group->add_section(
		array(
			'id'         => 'product-variation-fee-and-dimensions-section',
			'order'      => 30,
			'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.*/
					__( 'Set up shipping costs and enter dimensions used for accurate rate calculations. %1$sHow to get started?%2$s', 'woocommerce' ),
					'<a href="https://woocommerce.com/posts/how-to-calculate-shipping-costs-for-your-woocommerce-store/" target="_blank" rel="noreferrer">',
					'</a>'
				),
			),
		)
	);
	$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,
		)
	);
}