Automattic\WooCommerce\Blocks\BlockTypes\AddToCartWithOptions

VariationSelectorAttribute::render │ protected │ WC 1.0

Render the block.

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

Хуков нет.

Возвращает

string. Rendered block output.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->render( $attributes, $content, $block );
$attributes(массив) (обязательный)
Block attributes.
$content(строка) (обязательный)
Block content.
$block(WP_Block) (обязательный)
Block instance.

Код VariationSelectorAttribute::render() WC 11.3.0

protected function render( $attributes, $content, $block ) {
	global $product;

	if ( ! $product instanceof \WC_Product_Variable ) {
		return '';
	}

	$content = '';

	$product_attributes            = $product->get_variation_attributes();
	$available_values_by_attribute = $this->get_available_variation_values_by_attribute_slug();

	foreach ( $product_attributes as $product_attribute_name => $product_attribute_terms ) {
		$content .= $this->render_attribute_row( $product_attribute_name, $product_attribute_terms, $block, $attributes, $available_values_by_attribute );
	}

	return $content;
}