You've already forked wc-bootstrap
Add 15 Twig template overrides for the product archive and shop loop: - archive-product: 3+9 grid layout with optional filter sidebar - content-product: card component with hook-based content injection - content-product-cat: category card with thumbnail - product-searchform: input-group with search icon button - loop/loop-start, loop-end: responsive row-cols grid - loop/header: archive title with description hook - loop/result-count: showing X-Y of Z with aria-relevant - loop/orderby: form-select-sm sort dropdown - loop/pagination: delegates to components/pagination.html.twig - loop/no-products-found: alert-info empty state - loop/add-to-cart: btn-primary-sm with AJAX data attributes - loop/price: fw-semibold with sale/regular markup - loop/rating: Bootstrap Icon stars (full, half, empty) - loop/sale-flash: badge bg-danger positioned overlay CSS additions: product card hover, sale badge z-index, star rating sizing, price del/ins styling, WooCommerce grid reset. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
41 lines
1.4 KiB
Twig
41 lines
1.4 KiB
Twig
{#
|
|
# Loop Product Rating (Bootstrap 5 Override)
|
|
#
|
|
# Renders star ratings for products in the shop loop.
|
|
#
|
|
# Expected context:
|
|
# product - WC_Product object with:
|
|
# .get_average_rating() - Average rating (0-5)
|
|
# .get_review_count() - Number of reviews
|
|
# reviews_enabled - Whether reviews/ratings are enabled (boolean)
|
|
#
|
|
# WooCommerce PHP equivalent: loop/rating.php
|
|
#
|
|
# @package WcBootstrap
|
|
# @since 0.1.0
|
|
#}
|
|
|
|
{% if reviews_enabled is not defined or reviews_enabled %}
|
|
{% if product is defined and product.get_average_rating() > 0 %}
|
|
{% set rating = product.get_average_rating() %}
|
|
{% set count = product.get_review_count() %}
|
|
|
|
<div class="wc-star-rating d-flex align-items-center gap-1 mb-1"
|
|
role="img"
|
|
aria-label="{{ __('%s out of 5 stars')|format(rating) }}">
|
|
{% for i in 1..5 %}
|
|
{% if i <= rating|round(0, 'floor') %}
|
|
<i class="bi bi-star-fill text-warning" aria-hidden="true"></i>
|
|
{% elseif i - rating < 1 %}
|
|
<i class="bi bi-star-half text-warning" aria-hidden="true"></i>
|
|
{% else %}
|
|
<i class="bi bi-star text-warning" aria-hidden="true"></i>
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% if count > 0 %}
|
|
<small class="text-body-secondary">({{ count }})</small>
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
{% endif %}
|