PluginProbe
Tiered Pricing Table for WooCommerce / 8.1.0
Tiered Pricing Table for WooCommerce v8.1.0
8.1.0 8.0.2 7.1.7 7.1.5 7.1.4 7.1.1 6.5.0 6.4.0 6.1.0 trunk 1.0 1.1 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 All 92 releases
← All changes | views/frontend/tiered-pricing-blocks.php +14 -17 7.1.7 → 8.1.0 View file →
@@ -1,6 +1,7 @@
1 1 <?php use TierPricingTable\CalculationLogic;
2 2 use TierPricingTable\PriceManager;
3 + use TierPricingTable\PricingTable;
3 4 use TierPricingTable\PricingRule;
4 5
5 6 if ( ! defined( 'WPINC' ) ) {
6 7 die;
@@ -45,8 +46,10 @@
45 46 <h3 style="clear:both; margin: 20px 0;"><?php echo esc_attr( $settings['title'] ); ?></h3>
46 47 <?php endif; ?>
47 48
48 49 <div class="tiered-pricing-blocks <?php echo ( isset( $settings['compact_layout'] ) && $settings['compact_layout'] === 'yes' ) ? 'tiered-pricing-blocks--slim' : ''; ?>"
50 +
51 + <?php echo PricingTable::layoutStyleAttribute( $settings ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped in the helper ?>
49 52 id="<?php echo esc_attr( $id ); ?>"
50 53 data-product-id="<?php echo esc_attr( $product_id ); ?>"
51 54 data-price-rules="<?php echo esc_attr( htmlspecialchars( json_encode( $price_rules ), ENT_QUOTES ) ); ?>"
52 55 data-minimum="<?php echo esc_attr( $minimum ); ?>"
@@ -56,8 +59,9 @@
56 59 data-price="<?php echo esc_attr( $price ); ?>"
57 60 data-product-price-suffix="<?php echo esc_attr( $product->get_price_suffix() ); ?>"
58 61 >
59 62
63 + <?php $tptTierRows = array(); ob_start(); ?>
60 64 <div class="tiered-pricing-block tiered-pricing--active"
61 65 data-tiered-quantity="<?php echo esc_attr( $minimum ); ?>"
62 66 data-tiered-price="
63 67 <?php
@@ -105,11 +109,9 @@
105 109 ?>
106 110 <?php if ( $discountAmount > 0 ) : ?>
107 111 <span class="tiered-pricing-block__price-discount">
108 112 <?php
109 - // translators: %d: discount amount
110 - echo esc_html( sprintf( __( '(%d%% off)', 'tier-pricing-table' ),
111 - round( $discountAmount, 2 ) ) );
113 + echo wp_kses_post( '(' . PricingTable::formatDiscount( $discountAmount, $pricing_rule, $product, null, $settings, 'off' ) . ')' );
112 114 ?>
113 115 </span>
114 116 <?php endif; ?>
115 117 <?php endif; ?>
@@ -128,12 +130,13 @@
128 130 <?php echo esc_html( $settings['quantity_measurement_plural'] ); ?>
129 131 <?php endif; ?>
130 132 </span>
131 133 </div>
134 + <?php $tptTierRows[] = ob_get_clean(); ?>
132 135
133 136 <?php $iterator = new ArrayIterator( $price_rules ); ?>
134 137
135 - <?php while ( $iterator->valid() ) : ?>
138 + <?php while ( $iterator->valid() ) : ob_start(); ?>
136 139 <?php
137 140 $currentPrice = $iterator->current();
138 141 $currentQuantity = $iterator->key();
139 142
@@ -146,17 +149,12 @@
146 149
147 150 $iterator->next();
148 151
149 152 if ( $iterator->valid() ) {
150 - $quantity = $currentQuantity;
153 + $quantity = number_format_i18n( $currentQuantity );
151 154
152 - if ( intval( $iterator->key() - 1 != $currentQuantity ) ) {
153 -
154 - $quantity = number_format_i18n( $quantity );
155 -
156 - if ( 'range' === $settings['quantity_type'] ) {
157 - $quantity .= ' - ' . number_format_i18n( intval( $iterator->key() - 1 ) );
158 - }
155 + if ( (int) $iterator->key() - 1 !== (int) $currentQuantity && 'range' === $settings['quantity_type'] ) {
156 + $quantity .= ' - ' . number_format_i18n( intval( $iterator->key() - 1 ) );
159 157 }
160 158 } else {
161 159 $quantity = number_format_i18n( $currentQuantity );
162 160
@@ -198,14 +196,12 @@
198 196 $product_id ) ) );
199 197 ?>
200 198 </span>
201 199
202 - <?php if ( $settings['show_discount_column'] ) : ?>
200 + <?php if ( $settings['show_discount_column'] && $discountAmount > 0 ) : ?>
203 201 <span class="tiered-pricing-block__price-discount">
204 202 <?php
205 - // translators: %d: discount amount
206 - echo esc_html( sprintf( __( '(%d%% off)', 'tier-pricing-table' ),
207 - round( $discountAmount, 2 ) ) );
203 + echo wp_kses_post( '(' . PricingTable::formatDiscount( $discountAmount, $pricing_rule, $product, $currentQuantity, $settings, 'off' ) . ')' );
208 204 ?>
209 205 </span>
210 206 <?php endif; ?>
211 207 </div>
@@ -210,9 +206,10 @@
210 206 <?php endif; ?>
211 207 </div>
212 208 <span class="tiered-pricing-block__quantity"><?php echo esc_html( $quantity ); ?></span>
213 209 </div>
214 - <?php endwhile; ?>
210 + <?php $tptTierRows[] = ob_get_clean(); endwhile; ?>
211 + <?php echo PricingTable::orderTiers( $tptTierRows, $settings ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- rows escaped when rendered above ?>
215 212
216 213 <?php do_action( 'tiered_pricing_table/blocks/blocks', $pricing_rule, $settings ); ?>
217 214 </div>
218 215