| 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 |
|
| 24 |
<?php if ( $settings['head_quantity_text'] != '' && $settings['head_price_text'] != '' ): ?> |
| 25 |
<thead> |
| 26 |
<tr> |
| 27 |
<th><span class="nobr"><?php echo sanitize_text_field( $settings['head_quantity_text'] ); ?></span> |
| 28 |
</th> |
| 29 |
<th><span class="nobr"><?php echo sanitize_text_field( $settings['head_price_text'] ); ?></span> |
| 30 |
</th> |
| 31 |
</tr> |
| 32 |
</thead> |
| 33 |
<?php endif; ?> |
| 34 |
|
| 35 |
<tbody> |
| 36 |
<tr data-price-rules-amount="1" |
| 37 |
data-price-rules-price="<?php echo wc_get_price_to_display( wc_get_product( $product_id ), [ |
| 38 |
'price' => $real_price, |
| 39 |
] ); ?>" data-price-rules-row> |
| 40 |
<td> |
| 41 |
<?php if ( 1 === array_keys( $price_rules )[0] - 1 ): ?> |
| 42 |
<span>1</span> |
| 43 |
<?php else: ?> |
| 44 |
<span>1 - <?php echo array_keys( $price_rules )[0] - 1; ?></span> |
| 45 |
<?php endif; ?> |
| 46 |
</td> |
| 47 |
<td> |
| 48 |
<span data-price-rules-formated-price><?php echo wc_price( wc_get_price_to_display( wc_get_product( $product_id ), [ |
| 49 |
'price' => $real_price, |
| 50 |
] ) ); ?></span> |
| 51 |
</td> |
| 52 |
</tr> |
| 53 |
|
| 54 |
<?php $iterator = new ArrayIterator( $price_rules ); ?> |
| 55 |
|
| 56 |
<?php while ( $iterator->valid() ): ?> |
| 57 |
<?php |
| 58 |
$current_price = $iterator->current(); |
| 59 |
$current_quantity = $iterator->key(); |
| 60 |
|
| 61 |
$iterator->next(); |
| 62 |
|
| 63 |
if ( $iterator->valid() ) { |
| 64 |
$quantity = $current_quantity; |
| 65 |
|
| 66 |
if ( intval( $iterator->key() - 1 != $current_quantity ) ) { |
| 67 |
$quantity = $quantity . ' - ' . intval( $iterator->key() - 1 ); |
| 68 |
} |
| 69 |
} else { |
| 70 |
$quantity = $current_quantity . '+'; |
| 71 |
} |
| 72 |
?> |
| 73 |
<tr data-price-rules-amount="<?php echo $current_quantity ?>" |
| 74 |
data-price-rules-price="<?php echo wc_get_price_to_display( wc_get_product( $product_id ), [ |
| 75 |
'price' => $current_price, |
| 76 |
] ); ?>" data-price-rules-row> |
| 77 |
<td> |
| 78 |
<span><?php echo $quantity ?></span> |
| 79 |
</td> |
| 80 |
<td> |
| 81 |
<span data-price-rules-formated-price><?php echo wc_price( wc_get_price_to_display( wc_get_product( $product_id ), [ |
| 82 |
'price' => $current_price, |
| 83 |
] ) ); ?></span> |
| 84 |
</td> |
| 85 |
</tr> |
| 86 |
<?php endwhile; ?> |
| 87 |
|
| 88 |
</tbody> |
| 89 |
</table> |
| 90 |
|
| 91 |
<?php do_action( 'after_fixed_tier_pricing_table' ); ?> |
| 92 |
|
| 93 |
</div> |
| 94 |
|
| 95 |
<style> |
| 96 |
.price-rule-active td { |
| 97 |
background-color: <?php echo $settings['selected_quantity_color'] ?> !important; |
| 98 |
} |
| 99 |
|
| 100 |
.price-rules-table-wrapper { |
| 101 |
<?php echo $settings['display_type'] === 'tooltip' ? 'display: none; ' : ''; ?> |
| 102 |
} |
| 103 |
</style> |
| 104 |
<?php endif; ?> |