| 1 |
<?php if ( ! defined( 'WPINC' ) ) { |
| 2 |
die; |
| 3 |
} |
| 4 |
/** |
| 5 |
* @var array $price_rules |
| 6 |
* @var string $real_price |
| 7 |
* @var int $product_id ; |
| 8 |
*/ |
| 9 |
?> |
| 10 |
|
| 11 |
<?php if ( ! empty( $price_rules ) ): ?> |
| 12 |
|
| 13 |
<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; ?> |
| 17 |
|
| 18 |
<?php do_action( 'before_fixed_tier_pricing_table' ); ?> |
| 19 |
|
| 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> |
| 29 |
|
| 30 |
<tbody> |
| 31 |
<tr data-price-rules-amount="1" data-price-rules-price="<?php echo $real_price ?>" data-price-rules-row> |
| 32 |
<td> |
| 33 |
<?php if ( 1 === array_keys( $price_rules )[0] - 1 ): ?> |
| 34 |
<span>1</span> |
| 35 |
<?php else: ?> |
| 36 |
<span>1 - <?php echo array_keys( $price_rules )[0] - 1; ?></span> |
| 37 |
<?php endif; ?> |
| 38 |
</td> |
| 39 |
<td> |
| 40 |
<span data-price-rules-formated-price><?php echo wc_price( $real_price ); ?></span> |
| 41 |
</td> |
| 42 |
</tr> |
| 43 |
|
| 44 |
<?php $iterator = new ArrayIterator( $price_rules ); ?> |
| 45 |
|
| 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> |
| 65 |
<td> |
| 66 |
<span><?php echo $quantity ?></span> |
| 67 |
</td> |
| 68 |
<td> |
| 69 |
<span data-price-rules-formated-price><?php echo wc_price( $current_price ) ?></span> |
| 70 |
</td> |
| 71 |
</tr> |
| 72 |
<?php endwhile; ?> |
| 73 |
|
| 74 |
</tbody> |
| 75 |
</table> |
| 76 |
|
| 77 |
<?php do_action( 'after_fixed_tier_pricing_table' ); ?> |
| 78 |
|
| 79 |
</div> |
| 80 |
|
| 81 |
<style> |
| 82 |
.price-rule-active td { |
| 83 |
background-color: <?php echo $settings['selected_quantity_color'] ?> !important; |
| 84 |
} |
| 85 |
|
| 86 |
.price-rules-table-wrapper { |
| 87 |
<?php echo $settings['display_type'] === 'tooltip' ? 'display: none; ' : ''; ?> |
| 88 |
} |
| 89 |
</style> |
| 90 |
<?php endif; ?> |