Automattic\WooCommerce\Internal\Features\ProductBlockEditor\ProductTemplates

SimpleProductTemplate::add_shipping_group_blocks()privateWC 1.0

Adds the shipping group blocks to the template.

Method of the class: SimpleProductTemplate{}

No Hooks.

Return

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->add_shipping_group_blocks();

SimpleProductTemplate::add_shipping_group_blocks() code WC 9.3.3

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' => array(
				'content'    => __( 'This product has options, such as size or color. You can now manage each variation\'s shipping settings 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,
			'hideConditions' => array(
				array(
					'expression' => 'editedProduct.type !== "simple"',
				),
			),
		)
	)->add_block(
		array(
			'id'         => 'product-virtual',
			'blockName'  => 'woocommerce/product-toggle-field',
			'order'      => 10,
			'attributes' => array(
				'property'       => 'virtual',
				'checkedValue'   => false,
				'uncheckedValue' => true,
				'label'          => __( 'This product requires shipping or pickup', 'woocommerce' ),
				'uncheckedHelp'  => __( 'This product 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-fee-and-dimensions-section',
			'order'      => 20,
			'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-shipping-class',
			'blockName'         => 'woocommerce/product-shipping-class-field',
			'order'             => 10,
			'disableConditions' => array(
				array(
					'expression' => 'editedProduct.type === "variable"',
				),
			),
		)
	);
	$product_fee_and_dimensions_section->add_block(
		array(
			'id'                => 'product-shipping-dimensions',
			'blockName'         => 'woocommerce/product-shipping-dimensions-fields',
			'order'             => 20,
			'disableConditions' => array(
				array(
					'expression' => 'editedProduct.type === "variable"',
				),
			),
		)
	);
}