Automattic\WooCommerce\Blocks\BlockTypes\AddToCartWithOptions
VariationSelectorAttribute::render
Render the block.
Method of the class: VariationSelectorAttribute{}
No Hooks.
Returns
String. Rendered block output.
Usage
// protected - for code of main (parent) or child class $result = $this->render( $attributes, $content, $block );
- $attributes(array) (required)
- Block attributes.
- $content(string) (required)
- Block content.
- $block(WP_Block) (required)
- Block instance.
VariationSelectorAttribute::render() VariationSelectorAttribute::render code WC 10.9.1
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;
}