Automattic\WooCommerce\Blocks\BlockTypes
FeaturedProduct::render_attributes
Renders the featured product attributes.
Method of the class: FeaturedProduct{}
No Hooks.
Returns
String
.
Usage
// protected - for code of main (parent) or child class $result = $this->render_attributes( $product, $attributes );
- $product(WC_Product) (required)
- Product object.
- $attributes(array) (required)
- Block attributes.
Default: empty array
FeaturedProduct::render_attributes() FeaturedProduct::render attributes code WC 9.9.4
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; }