| 1 |
<?php namespace TierPricingTable\Addons\GlobalTieredPricing\CPT\Columns; |
| 2 |
|
| 3 |
use TierPricingTable\Addons\GlobalTieredPricing\GlobalPricingRule; |
| 4 |
|
| 5 |
/** |
| 6 |
* Settings that differ from the defaults: how the rule meets product-level pricing, and whatever |
| 7 |
* add-ons append (tax settings, for instance) through the after_tab_render action. |
| 8 |
*/ |
| 9 |
class Settings { |
| 10 |
|
| 11 |
public function getName(): string { |
| 12 |
return __( 'Settings', 'tier-pricing-table' ); |
| 13 |
} |
| 14 |
|
| 15 |
public function render( GlobalPricingRule $rule ) { |
| 16 |
$settings = $rule->getSettings(); |
| 17 |
$labels = array( |
| 18 |
'prefer-product' => __( 'prefer product', 'tier-pricing-table' ), |
| 19 |
'prefer-role-based-product' => __( 'prefer product role prices', 'tier-pricing-table' ), |
| 20 |
'override' => __( 'override product', 'tier-pricing-table' ), |
| 21 |
); |
| 22 |
|
| 23 |
switch ( $settings->getPriorityType() ) { |
| 24 |
case 'prefer-product': |
| 25 |
$this->renderTag( __( 'Prefers product pricing', 'tier-pricing-table' ) ); |
| 26 |
break; |
| 27 |
case 'override': |
| 28 |
$this->renderTag( __( 'Overrides product pricing', 'tier-pricing-table' ) ); |
| 29 |
break; |
| 30 |
case 'flexible': |
| 31 |
$this->renderTag( __( 'Custom priorities', 'tier-pricing-table' ), sprintf( |
| 32 |
/* translators: 1, 2, 3: the three priority choices */ |
| 33 |
__( 'Base prices: %1$s. Tiers: %2$s. Quantity limits: %3$s.', 'tier-pricing-table' ), |
| 34 |
$labels[ $settings->getRegularPricingPriority() ] ?? $settings->getRegularPricingPriority(), |
| 35 |
$labels[ $settings->getTieredPricingPriority() ] ?? $settings->getTieredPricingPriority(), |
| 36 |
$labels[ $settings->getQuantityLimitsPriority() ] ?? $settings->getQuantityLimitsPriority() |
| 37 |
) ); |
| 38 |
break; |
| 39 |
default: |
| 40 |
echo '<span class="tpt-rules-list__muted">' . esc_html__( 'Default', 'tier-pricing-table' ) . '</span>'; |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
public static function renderTag( string $text, string $title = '' ) { |
| 45 |
?> |
| 46 |
<span class="tpt-rules-list__tag" <?php echo $title ? 'title="' . esc_attr( $title ) . '"' : ''; ?>><?php echo esc_html( $text ); ?></span> |
| 47 |
<?php |
| 48 |
} |
| 49 |
} |
| 50 |
|