BlockEditing
4 days ago
Convert
4 days ago
Duplicate
4 days ago
Management
4 days ago
Timestamps
4 days ago
Tracker
4 days ago
views
4 days ago
CommonMethodSettings.php
4 days ago
FreeShippingCalculator.php
4 days ago
FreeShippingThresholdRuleValidator.php
4 days ago
MethodDescription.php
4 days ago
MethodLogo.php
4 days ago
MethodLogoCheckoutBlocksAssets.php
4 days ago
MethodLogoSettingsField.php
4 days ago
MethodSettings.php
4 days ago
MethodTitle.php
4 days ago
RateCalculator.php
4 days ago
RateCalculatorFactory.php
4 days ago
SettingsDisplayPreparer.php
4 days ago
SettingsProcessor.php
4 days ago
SingleMethodSettings.php
4 days ago
SingleMethodSettings.php
81 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class TaxableMethodSettings |
| 4 | * |
| 5 | * @package WPDesk\FS\TableRate\ShippingMethod |
| 6 | */ |
| 7 | |
| 8 | namespace WPDesk\FS\TableRate\ShippingMethod; |
| 9 | |
| 10 | /** |
| 11 | * Settings fields with taxable option. |
| 12 | */ |
| 13 | class SingleMethodSettings implements MethodSettings { |
| 14 | |
| 15 | /** |
| 16 | * @param array $method_settings . |
| 17 | * @param bool $with_integration_settings Append integration settings. |
| 18 | * |
| 19 | * @return array |
| 20 | */ |
| 21 | public function get_settings_fields( array $method_settings, $with_integration_settings ) { |
| 22 | $settings_fields = $this->append_tax_settings( |
| 23 | ( new CommonMethodSettings() )->get_settings_fields( $method_settings, $with_integration_settings ) |
| 24 | ); |
| 25 | unset( $settings_fields['method_enabled'], $settings_fields[ CommonMethodSettings::METHOD_DEFAULT ] ); |
| 26 | |
| 27 | return $settings_fields; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * @param array $settings_fields . |
| 32 | * |
| 33 | * @return array |
| 34 | */ |
| 35 | private function append_tax_settings( array $settings_fields ) { |
| 36 | $tax_docs_link = 'pl_PL' !== get_locale() |
| 37 | ? 'https://octol.io/fs-tax' |
| 38 | : 'https://octol.io/fs-tax-pl'; |
| 39 | $new_settings_fields = []; |
| 40 | foreach ( $settings_fields as $key => $settings_field ) { |
| 41 | $new_settings_fields[ $key ] = $settings_field; |
| 42 | if ( CommonMethodSettings::METHOD_LOGO_ID === $key ) { |
| 43 | $new_settings_fields['tax_heading'] = [ |
| 44 | 'title' => __( 'Tax', 'flexible-shipping' ), |
| 45 | 'type' => 'title', |
| 46 | 'description' => sprintf( |
| 47 | // Translators: new line and link. |
| 48 | __( 'Adjust shipping taxes for this shipping method. Determine its tax status and whether you want to enter shipping costs with or without taxes.%1$sNeed more information? Read our %2$scomprehensive guide about WooCommerce shipping taxes →%3$s', 'flexible-shipping' ), |
| 49 | '<br/>', |
| 50 | '<a target="_blank" href="' . $tax_docs_link . '">', |
| 51 | '</a>' |
| 52 | ), |
| 53 | 'default' => '', |
| 54 | ]; |
| 55 | $new_settings_fields['tax_status'] = [ |
| 56 | 'title' => __( 'Tax Status', 'flexible-shipping' ), |
| 57 | 'type' => 'select', |
| 58 | 'default' => 'taxable', |
| 59 | 'options' => [ |
| 60 | 'taxable' => __( 'Taxable', 'flexible-shipping' ), |
| 61 | 'none' => _x( 'None', 'Tax status', 'flexible-shipping' ), |
| 62 | ], |
| 63 | 'desc_tip' => __( 'If you select to apply the tax, the plugin will use the tax rates defined in the WooCommerce settings at <strong>WooCommerce → Settings → Tax</strong>.', 'flexible-shipping' ), |
| 64 | ]; |
| 65 | $new_settings_fields['prices_include_tax'] = [ |
| 66 | 'title' => __( 'Tax included in shipping cost', 'flexible-shipping' ), |
| 67 | 'type' => 'select', |
| 68 | 'default' => 'no', |
| 69 | 'options' => [ |
| 70 | 'yes' => __( 'Yes, I will enter the shipping cost inclusive of tax', 'flexible-shipping' ), |
| 71 | 'no' => __( 'No, I will enter the shipping cost exclusive of tax', 'flexible-shipping' ), |
| 72 | ], |
| 73 | 'desc_tip' => __( 'Choose whether the shipping cost defined in the rules table should be inclusive or exclusive of tax.', 'flexible-shipping' ), |
| 74 | ]; |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | return $new_settings_fields; |
| 79 | } |
| 80 | } |
| 81 |