Files
wc-tier-and-package-prices/templates/frontend/tier-pricing-table.twig

42 lines
1.5 KiB
Twig
Raw Normal View History

{#
# Frontend Tier Pricing Table Template
#
# @package WC_Tier_Package_Prices
# @var object product
# @var array tiers
#}
<div class="wc-tpp-tier-pricing-table">
<h3>{{ 'Volume Discounts'|__('wc-tier-package-prices') }}</h3>
<table class="wc-tpp-table">
<thead>
<tr>
<th>{{ 'Quantity'|__('wc-tier-package-prices') }}</th>
<th>{{ 'Price per Unit'|__('wc-tier-package-prices') }}</th>
<th>{{ 'You Save'|__('wc-tier-package-prices') }}</th>
</tr>
</thead>
<tbody>
{% set regular_price = product.get_regular_price() %}
{% for tier in tiers %}
{% set savings = 0 %}
{% set savings_percent = 0 %}
{% if regular_price > 0 %}
{% set savings = regular_price - tier.price %}
{% set savings_percent = (savings / regular_price) * 100 %}
{% endif %}
<tr data-min-qty="{{ tier.min_qty|esc_attr }}" data-price="{{ tier.price|esc_attr }}">
<td>{{ tier.min_qty|esc_html }}+</td>
<td>{{ wc_price(tier.price)|raw }}</td>
<td>
{% if savings > 0 %}
{{ wc_price(savings)|raw }} ({{ savings_percent|round(2) }}%)
{% else %}
-
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>