PluginProbe
Tiered Pricing Table for WooCommerce / 6.1.0
Tiered Pricing Table for WooCommerce v6.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 2.3.3 All 91 releases
tier-pricing-table / views / frontend / price-table-percentage.php

price-table-percentage.php in Tiered Pricing Table for WooCommerce 6.1.0, at views/frontend/price-table-percentage.php

187 lines 6.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Percentage pricing table
4 *
5 * @var array $price_rules
6 * @var string $real_price
7 * @var string $product_name
8 * @var int $product_id
9 * @var int $minimum
10 * @var array $settings
11 */
12
13 use TierPricingTable\PriceManager;
14
15 if ( ! defined( 'WPINC' ) ) {
16 die;
17 }
18 /**
19 * @var array $price_rules
20 * @var string $real_price
21 * @var int $product_id ;
22 */
23 ?>
24
25 <?php if ( ! empty( $price_rules ) ) : ?>
26 <div class="clear"></div>
27 <div class="price-rules-table-wrapper">
28 <?php if ( ! empty( $settings['table_title'] ) ) : ?>
29
30 <h3 style="clear:both; margin: 20px 0;"><?php echo esc_attr( $settings['table_title'] ); ?></h3>
31 <?php endif; ?>
32
33 <?php do_action( 'before_percentage_tier_pricing_table' ); ?>
34
35 <table class="shop_table price-rules-table <?php echo esc_attr( $settings['table_css_class'] ); ?>"
36 data-price-rules-table
37 data-product-id="<?php echo esc_attr( $product_id ); ?>"
38 data-price-rules="<?php echo esc_attr( json_encode( $price_rules ) ); ?>"
39 data-minimum="<?php echo esc_attr( $minimum ); ?>"
40 data-product-name="<?php echo esc_attr( $product_name ); ?>">
41
42 <?php if ( '' != $settings['head_quantity_text'] && '' != $settings['head_price_text'] ) : ?>
43 <thead>
44 <tr>
45 <th>
46 <span class="nobr"><?php echo esc_attr( sanitize_text_field( $settings['head_quantity_text'] ) ); ?></span>
47 </th>
48 <?php if ( 'yes' === $settings['show_discount_column'] ) : ?>
49 <th>
50 <span class="nobr"><?php echo esc_attr( sanitize_text_field( $settings['head_discount_text'] ) ); ?></span>
51 </th>
52 <?php endif; ?>
53 <th>
54 <span class="nobr"><?php echo esc_attr( sanitize_text_field( $settings['head_price_text'] ) ); ?></span>
55 </th>
56 <?php
57 do_action( 'tier_pricing_table_percentage_header_columns', $price_rules, $real_price,
58 $product_id );
59 ?>
60 </tr>
61 </thead>
62 <?php endif; ?>
63
64 <tbody>
65 <tr data-price-rules-amount="<?php echo esc_attr( $minimum ); ?>"
66 data-price-rules-price="
67 <?php
68 echo esc_attr( wc_get_price_to_display( wc_get_product( $product_id ),
69 array( 'price' => $real_price, ) ) );
70 ?>
71 "
72 data-price-rules-price-exclude-taxes="
73 <?php
74 echo esc_attr( wc_get_price_excluding_tax( wc_get_product( $product_id ),
75 array( 'price' => $real_price, ) ) );
76 ?>
77 "
78 data-price-rules-row>
79 <td>
80 <?php if ( 1 >= array_keys( $price_rules )[0] - $minimum || $settings['quantity_type'] === "static" ) : ?>
81 <span><?php echo esc_attr( number_format_i18n( $minimum ) ); ?></span>
82 <?php else : ?>
83 <span><?php echo esc_attr( number_format_i18n( $minimum ) ); ?> - <?php echo esc_attr( number_format_i18n( array_keys( $price_rules )[0] - 1 ) ); ?></span>
84 <?php endif; ?>
85 </td>
86 <?php if ( 'yes' === $settings['show_discount_column'] ) : ?>
87 <td>
88 —
89 </td>
90 <?php endif; ?>
91 <td>
92 <span data-price-rules-formated-price>
93 <?php
94 echo wp_kses_post( wc_price( wc_get_price_to_display( wc_get_product( $product_id ),
95 array( 'price' => $real_price, ) ) ) );
96 ?>
97 </span>
98 </td>
99 </tr>
100
101 <?php $iterator = new ArrayIterator( $price_rules ); ?>
102
103 <?php while ( $iterator->valid() ) : ?>
104 <?php
105 $percentageDiscount = $iterator->current();
106 $current_quantity = $iterator->key();
107
108 $iterator->next();
109
110 $quantity = number_format_i18n( $current_quantity );
111
112 if ( $iterator->valid() ) {
113
114 if ( intval( $iterator->key() - 1 != $current_quantity ) && $settings['quantity_type'] === 'range' ) {
115 $quantity .= ' - ' . number_format_i18n( intval( $iterator->key() - 1 ) );
116 }
117
118 } else {
119 $quantity .= '+';
120 }
121 ?>
122 <tr data-price-rules-amount="<?php echo esc_attr( $current_quantity ); ?>"
123 data-price-rules-price="
124 <?php
125 echo esc_attr( PriceManager::getPriceByRules( $current_quantity,
126 $product_id ) );
127 ?>
128 "
129 data-price-rules-price-exclude-taxes="
130 <?php
131 echo esc_attr(
132 wc_get_price_excluding_tax( wc_get_product( $product_id ),
133 array(
134 'price' => PriceManager::getPriceByRules( $current_quantity,
135 $product_id )
136 ) ) )
137 ?>
138 "
139 data-price-rules-row>
140 <td>
141 <span><?php echo esc_attr( $quantity ); ?></span>
142 </td>
143 <?php if ( 'yes' === $settings['show_discount_column'] ) : ?>
144 <td>
145 <span><?php echo esc_attr( round( $percentageDiscount, 2 ) ); ?> %</span>
146 </td>
147 <?php endif; ?>
148 <td>
149 <span data-price-rules-formated-price>
150 <?php
151 echo wp_kses_post( wc_price( PriceManager::getPriceByRules( $current_quantity,
152 $product_id ) ) );
153 ?>
154 </span>
155 </td>
156 </tr>
157
158 <?php
159 do_action( 'tier_pricing_table_percentage_body_columns', $iterator, $price_rules, $real_price,
160 $product_id );
161 ?>
162
163 <?php endwhile; ?>
164
165 </tbody>
166 </table>
167
168 <?php do_action( 'after_percentage_tier_pricing_table' ); ?>
169
170 </div>
171
172 <style>
173 <?php
174 if ( 'yes' === $settings['clickable_table_rows'] && tpt_fs()->is_premium()) {
175 echo '.price-rules-table-wrapper table tr {cursor: pointer; }';
176 }
177 ?>
178
179 .price-rule-active td {
180 background-color: <?php echo esc_attr($settings['selected_quantity_color']); ?> !important;
181 }
182
183 .price-rules-table-wrapper {
184 <?php echo ( 'tooltip' === $settings['display_type'] || 'yes' !== $settings['display'] ) ? 'display: none; ' : ''; ?>
185 }
186 </style>
187 <?php endif; ?>