Home Forums WoodMart support forum Making rating visible on shop page

Making rating visible on shop page

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #110636

    dk1
    Participant

    Hi,

    I am using “summar on hover” product layout for my shop pages.
    I am satisfied with it, but I want the rating to be shown by default, without hover. I’ve been able to achieve that with a zero rating through an additional code, however, it doesn’t work for rated products.

    Code is:

    // Woocommerce rating stars always
    add_filter(‘woocommerce_product_get_rating_html’, ‘your_get_rating_html’, 10, 2);

    function your_get_rating_html($rating_html, $rating) {
    if ( $rating > 0 ) {
    $title = sprintf( __( ‘Rated %s out of 5’, ‘woocommerce’ ), $rating );
    } else {
    $title = ‘No rating’;
    $rating = 0;
    }

    $rating_html = ‘<div class=”star-rating” title=”‘ . $title . ‘”>’;
    $rating_html .= ‘<span style=”width:’ . ( ( $rating / 5 ) * 100 ) . ‘%”><strong class=”rating”>’ . $rating . ‘ ‘ . __( ‘out of 5’, ‘woocommerce’ ) . ‘</span>’;
    $rating_html .= ‘</div>’;
    return $rating_html;
    }

    #110661

    Hello,

    Please add this code to the Theme Settings > Custom CSS > Global:

    body .woodmart-hover-base.has-stars.product-type-external .product-rating-price, body .woodmart-hover-base.has-stars.purchasable .product-rating-price {
        height: auto;
        line-height: auto;
    }
    body .woodmart-hover-base.has-stars.product-type-external .star-rating, body .woodmart-hover-base.has-stars.product-type-external .wrapp-product-price .price, body .woodmart-hover-base.has-stars.purchasable .star-rating, body .woodmart-hover-base.has-stars.purchasable .wrapp-product-price .price {
            height: 20px;
            line-height: 20px;
    }
    body .woodmart-hover-base.has-stars.product-type-external .wrapp-product-price, body .woodmart-hover-base.has-stars.purchasable .wrapp-product-price {
        height: auto;
        transform: none!important;
        -webkit-transform: none!important;
    }

    Best Regards

Viewing 2 posts - 1 through 2 (of 2 total)