| 1 |
<?php namespace TierPricingTable\Addons\GlobalTieredPricing\CPT\Columns; |
| 2 |
|
| 3 |
use TierPricingTable\Addons\GlobalTieredPricing\GlobalPricingRule; |
| 4 |
use TierPricingTable\CalculationLogic; |
| 5 |
|
| 6 |
class Settings { |
| 7 |
|
| 8 |
public function getName(): string { |
| 9 |
return __( 'Priority Settings', 'tier-pricing-table' ); |
| 10 |
} |
| 11 |
|
| 12 |
public function render( GlobalPricingRule $rule ) { |
| 13 |
|
| 14 |
$prioritySlug = $rule->getSettings()->getPriorityType(); |
| 15 |
|
| 16 |
if ( $prioritySlug === 'default' ) { |
| 17 |
$realPriority = CalculationLogic::globalRulesOverrideProductLevelRules() ? 'override' : 'prefer-product'; |
| 18 |
} else { |
| 19 |
$realPriority = $prioritySlug; |
| 20 |
} |
| 21 |
|
| 22 |
$priorities = array( |
| 23 |
'default' => __( 'Global', 'tier-pricing-table' ), |
| 24 |
'prefer-product' => __( 'Prefer Product', 'tier-pricing-table' ), |
| 25 |
'prefer-role-based-product' => __( 'Prefer Product', 'tier-pricing-table' ), |
| 26 |
'override' => __( 'Override', 'tier-pricing-table' ), |
| 27 |
'flexible' => __( 'Flexible', 'tier-pricing-table' ), |
| 28 |
); |
| 29 |
|
| 30 |
|
| 31 |
if ( ! array_key_exists( $prioritySlug, $priorities ) ) { |
| 32 |
return; |
| 33 |
} |
| 34 |
|
| 35 |
?> |
| 36 |
<div style="margin-bottom: 12px;"> |
| 37 |
<div style="display: flex; flex-wrap: wrap; gap: 4px;"> |
| 38 |
<span style="display: inline-block; background: #e0f0fa; color: #0070bc; border: 1px solid #bae0ff; padding: 4px 10px; border-radius: 4px; font-size: 13px; font-weight: 500; line-height: 1.4;"> |
| 39 |
<?php echo esc_html( $priorities[ $realPriority ] ); ?> |
| 40 |
</span> |
| 41 |
</div> |
| 42 |
|
| 43 |
<?php if ( $prioritySlug === 'flexible' ) : ?> |
| 44 |
<div style="margin-top: 8px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start;"> |
| 45 |
<span style="display: inline-block; padding: 2px 8px; background: #f0f0f1; border-radius: 3px; font-size: 12px; color: #3c434a; border: 1px solid #dcdcdc; line-height: 1.4;"> |
| 46 |
<?php esc_html_e( 'Regular prices:', 'tier-pricing-table' ); ?> <b><?php echo esc_html( $priorities[ $rule->getSettings()->getRegularPricingPriority() ] ); ?></b> |
| 47 |
</span> |
| 48 |
<span style="display: inline-block; padding: 2px 8px; background: #f0f0f1; border-radius: 3px; font-size: 12px; color: #3c434a; border: 1px solid #dcdcdc; line-height: 1.4;"> |
| 49 |
<?php esc_html_e( 'Tiered pricing:', 'tier-pricing-table' ); ?> <b><?php echo esc_html( $priorities[ $rule->getSettings()->getTieredPricingPriority() ] ); ?></b> |
| 50 |
</span> |
| 51 |
<span style="display: inline-block; padding: 2px 8px; background: #f0f0f1; border-radius: 3px; font-size: 12px; color: #3c434a; border: 1px solid #dcdcdc; line-height: 1.4;"> |
| 52 |
<?php esc_html_e( 'Quantity limits:', 'tier-pricing-table' ); ?> <b><?php echo esc_html( $priorities[ $rule->getSettings()->getQuantityLimitsPriority() ] ); ?></b> |
| 53 |
</span> |
| 54 |
</div> |
| 55 |
<?php endif; ?> |
| 56 |
</div> |
| 57 |
|
| 58 |
<?php |
| 59 |
} |
| 60 |
} |
| 61 |
|