PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.18
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.18
1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 All 163 releases
woocommerce-pos / includes / Services / Tax_Id_Settings.php

Tax_Id_Settings.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.18, at includes/Services/Tax_Id_Settings.php

75 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Tax ID Settings.
4 *
5 * Centralises the Tax-ID-related settings: per-type write-map overrides plus
6 * the capture/display toggles surfaced in the admin SPA. Values come from
7 * WCPOS settings (the top-level `tax_ids` section, allowing the existing
8 * settings service to handle persistence) and fall back to sensible defaults.
9 *
10 * @package WCPOS\WooCommercePOS
11 */
12
13 namespace WCPOS\WooCommercePOS\Services;
14
15 use WCPOS\WooCommercePOS\Services\Settings;
16
17 /**
18 * Tax_Id_Settings class.
19 */
20 class Tax_Id_Settings {
21 /**
22 * Default per-type → meta-key write map.
23 *
24 * `_billing_vat_number` is the WC EU VAT Number current key and is read
25 * out-of-the-box by most VAT-aware plugins, so we use it as the catch-all
26 * for VAT-shaped types when no plugin and no override are present.
27 *
28 * @return array<string,string>
29 */
30 public static function default_write_map(): array {
31 return array(
32 Tax_Id_Types::TYPE_EU_VAT => '_billing_vat_number',
33 Tax_Id_Types::TYPE_GB_VAT => '_billing_vat_number',
34 Tax_Id_Types::TYPE_SA_VAT => '_billing_vat_number',
35 Tax_Id_Types::TYPE_AU_ABN => '_billing_vat_number',
36 Tax_Id_Types::TYPE_CA_GST_HST => '_billing_vat_number',
37 Tax_Id_Types::TYPE_US_EIN => '_billing_vat_number',
38 Tax_Id_Types::TYPE_OTHER => '_billing_vat_number',
39 Tax_Id_Types::TYPE_BR_CPF => '_billing_cpf',
40 Tax_Id_Types::TYPE_BR_CNPJ => '_billing_cnpj',
41 Tax_Id_Types::TYPE_IN_GST => '_billing_gstin',
42 Tax_Id_Types::TYPE_IT_CF => '_billing_cf',
43 Tax_Id_Types::TYPE_IT_PIVA => '_billing_piva',
44 Tax_Id_Types::TYPE_ES_NIF => '_billing_nif',
45 Tax_Id_Types::TYPE_AR_CUIT => '_billing_cuit',
46 );
47 }
48
49 /**
50 * User-configured per-type overrides for the write map.
51 *
52 * Reads from the `tax_ids.write_map` settings tree, including the legacy
53 * `general.tax_ids.write_map` fallback provided by Settings. Invalid types
54 * or empty keys are silently dropped.
55 *
56 * @return array<string,string>
57 */
58 public static function get_overrides(): array {
59 $raw = Settings::instance()->tax_id_write_map();
60
61 $out = array();
62 foreach ( $raw as $type => $meta_key ) {
63 if ( ! \is_string( $type ) || ! Tax_Id_Types::is_valid_type( $type ) ) {
64 continue;
65 }
66 if ( ! \is_string( $meta_key ) || '' === $meta_key ) {
67 continue;
68 }
69 $out[ $type ] = $meta_key;
70 }
71
72 return $out;
73 }
74 }
75