Automattic\WooCommerce\Blocks\BlockTypes\AddToCartWithOptions
VariationSelector::render
Render the block.
Метод класса: VariationSelector{}
Хуков нет.
Возвращает
string. Rendered block output.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->render( $attributes, $content, $block ): string;
- $attributes(массив) (обязательный)
- Block attributes.
- $content(строка) (обязательный)
- Block content.
- $block(WP_Block) (обязательный)
- Block instance.
Код VariationSelector::render() VariationSelector::render WC 11.1.0
protected function render( $attributes, $content, $block ): string {
global $product;
if ( $product instanceof \WC_Product && $product->is_type( ProductType::VARIABLE ) && ! Utils::is_not_purchasable_product( $product ) ) {
$p = new \WP_HTML_Tag_Processor( $content );
if ( $p->next_tag( array( 'class_name' => 'wp-block-woocommerce-add-to-cart-with-options-variation-selector' ) ) ) {
$p->set_attribute( 'data-wp-watch', 'callbacks.setSelectedVariationId' );
$p->set_attribute( 'data-wp-watch--validate', 'callbacks.validateVariation' );
}
return $p->get_updated_html();
}
return '';
}