| 1 |
<?php namespace TierPricingTable\Addons\TaxSettings\GlobalRulesIntegration; |
| 2 |
|
| 3 |
use TierPricingTable\Addons\GlobalTieredPricing\CPT\Form\FormTab; |
| 4 |
use TierPricingTable\Addons\GlobalTieredPricing\GlobalPricingRule; |
| 5 |
|
| 6 |
class TaxSettingsTab extends FormTab { |
| 7 |
|
| 8 |
public function getId() { |
| 9 |
return 'tax-settings'; |
| 10 |
} |
| 11 |
|
| 12 |
public function getTitle(): string { |
| 13 |
return __( 'Tax', 'tier-pricing-table' ); |
| 14 |
} |
| 15 |
|
| 16 |
public function getDescription(): string { |
| 17 |
return __( 'Set tax status and class', 'tier-pricing-table' ); |
| 18 |
} |
| 19 |
|
| 20 |
public function render( GlobalPricingRule $pricingRule ) { |
| 21 |
?> |
| 22 |
<div class="tiered-pricing-form-row"> |
| 23 |
<div> |
| 24 |
<?php |
| 25 |
$this->renderSectionTitle( __( 'Tax settings', 'tier-pricing-table' ), array( |
| 26 |
'description' => __( 'Override the default tax status and class for products matching this rule.', 'tier-pricing-table' ), |
| 27 |
'only_for_premium' => true, |
| 28 |
) ); |
| 29 |
|
| 30 |
$this->renderSelect( array( |
| 31 |
'id' => 'tpt_tax_status', |
| 32 |
'title' => __( 'Tax status', 'tier-pricing-table' ), |
| 33 |
'options' => array( |
| 34 |
'' => __( 'Default', 'tier-pricing-table' ), |
| 35 |
'taxable' => __( 'Taxable', 'tier-pricing-table' ), |
| 36 |
'shipping' => __( 'Shipping only', 'tier-pricing-table' ), |
| 37 |
'none' => __( 'None', 'tier-pricing-table' ), |
| 38 |
), |
| 39 |
'value' => $pricingRule->getTaxStatus(), |
| 40 |
'disabled' => ! tpt_fs()->can_use_premium_code__premium_only(), |
| 41 |
), false ); |
| 42 |
|
| 43 |
$tax_classes = \WC_Tax::get_tax_classes(); |
| 44 |
$classes_options = array( |
| 45 |
'' => __( 'Default', 'tier-pricing-table' ), |
| 46 |
'standard' => __( 'Standard', 'tier-pricing-table' ), |
| 47 |
); |
| 48 |
if ( ! empty( $tax_classes ) ) { |
| 49 |
foreach ( $tax_classes as $class ) { |
| 50 |
$classes_options[ \WC_Tax::format_tax_rate_class( $class ) ] = $class; |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
$this->renderSelect( array( |
| 55 |
'id' => 'tpt_tax_class', |
| 56 |
'title' => __( 'Tax class', 'tier-pricing-table' ), |
| 57 |
'options' => $classes_options, |
| 58 |
'value' => $pricingRule->getTaxClass(), |
| 59 |
'disabled' => ! tpt_fs()->can_use_premium_code__premium_only(), |
| 60 |
), false ); |
| 61 |
?> |
| 62 |
</div> |
| 63 |
</div> |
| 64 |
<?php |
| 65 |
} |
| 66 |
|
| 67 |
public function getIcon(): string { |
| 68 |
return '%'; |
| 69 |
} |
| 70 |
} |
| 71 |
|