Automattic\WooCommerce\Blocks\BlockTypes
FeaturedProduct::render_attributes()
Renders the featured product attributes.
Метод класса: FeaturedProduct{}
Хуков нет.
Возвращает
Строку
.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->render_attributes( $product, $attributes );
- $product(\WC_Product) (обязательный)
- Product object.
- $attributes(массив) (обязательный)
- Block attributes.
По умолчанию: empty array
Код FeaturedProduct::render_attributes() FeaturedProduct::render attributes WC 9.8.1
protected function render_attributes( $product, $attributes ) { $title = sprintf( '<h2 class="wc-block-featured-product__title">%s</h2>', wp_kses_post( $product->get_title() ) ); if ( $product->is_type( ProductType::VARIATION ) ) { $title .= sprintf( '<h3 class="wc-block-featured-product__variation">%s</h3>', wp_kses_post( wc_get_formatted_variation( $product, true, true, false ) ) ); } $desc_str = sprintf( '<div class="wc-block-featured-product__description">%s</div>', wc_format_content( wp_kses_post( $product->get_short_description() ? $product->get_short_description() : wc_trim_string( $product->get_description(), 400 ) ) ) ); $price_str = sprintf( '<div class="wc-block-featured-product__price">%s</div>', wp_kses_post( $product->get_price_html() ) ); $output = $title; if ( $attributes['showDesc'] ) { $output .= $desc_str; } if ( $attributes['showPrice'] ) { $output .= $price_str; } return $output; }