WC_Embed::get_ratings()
Prints the markup for the rating stars.
Method of the class: WC_Embed{}
No Hooks.
Return
null
. Nothing (null).
Usage
$result = WC_Embed::get_ratings();
Changelog
Since 2.4.11 | Introduced. |
WC_Embed::get_ratings() WC Embed::get ratings code WC 9.3.1
<?php public static function get_ratings() { // Make sure we're only affecting embedded products. if ( ! self::is_embedded_product() ) { return; } $_product = wc_get_product( get_the_ID() ); if ( $_product && $_product->get_average_rating() > 0 ) { ?> <div class="wc-embed-rating"> <?php printf( /* translators: %s: average rating */ esc_html__( 'Rated %s out of 5', 'woocommerce' ), esc_html( $_product->get_average_rating() ) ); ?> </div> <?php } }