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