Plugin Directory

Changeset 3157194


Ignore:
Timestamp:
09/25/2024 01:54:54 AM (19 months ago)
Author:
bulletproofcheckout
Message:

Added support for countries with missed states at WooCommerce

Location:
bulletproof-checkout-lite/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • bulletproof-checkout-lite/trunk/README.txt

    r3132917 r3157194  
    44Requires at least: 4.0
    55Tested up to: 6.5.4
    6 Stable tag: 1.0.0
     6Stable tag: 1.0.7
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    9898- Sale, authorization, subscription, and order processing.
    9999- Collect payments inside and outside of WooCommerce.
     100- Refund via Dashboard: Process full or partial refunds, directly from your WordPress dashboard.
    100101
    101102
  • bulletproof-checkout-lite/trunk/bulletproof-checkout-lite.php

    r3146685 r3157194  
    55 * Plugin URI: https://www.bulletproof-checkout.com/
    66 * Description: Receive Credit Card payments using the Lite version of the BulletProof Gateway.
    7  * Version: 1.0.6
     7 * Version: 1.0.8
    88 * Author: BulletProof Checkout <support@bulletproof-checkout.com>
    99 * Author URI: https://www.bulletproof-checkout.com/
     
    1111 * Text Domain: bulletproof-checkout-lite
    1212 * WC requires at least: 5.0
    13  * WC tested up to: 9.2.1
     13 * WC tested up to: 9.3.2
    1414 * Requires PHP: 7.4
    1515 * Requires Plugins: woocommerce
     
    3030if (!defined('BULLETPROOF_CHECKOUT_FORMAT')) define('BULLETPROOF_CHECKOUT_FORMAT', 'raw');
    3131if (!defined('BULLETPROOF_BPCHECKOUT_GATEWAY')) define('BULLETPROOF_BPCHECKOUT_GATEWAY', 'BPCHECKOUT');
    32 
     32// If the Official Mobile App will be used then will need to disable BULLETPROOF_CHECKOUT_ADDORDERLISTCOLUMNS
     33// In the Official Mobile App BulletProof does not support Authorize and Capture later
     34if (!defined('BULLETPROOF_CHECKOUT_ADDORDERLISTCOLUMNS')) define('BULLETPROOF_CHECKOUT_ADDORDERLISTCOLUMNS', true);
     35// Some hosting providers auto-enabled JetPack SSO whih is buggy with the Official Mobile App
     36if (!defined('BULLETPROOF_CHECKOUT_DISABLEJETPACKSSO')) define('BULLETPROOF_CHECKOUT_DISABLEJETPACKSSO', false);
    3337
    3438
  • bulletproof-checkout-lite/trunk/includes/class-wc-bulletproof-payment-gateway-lite.php

    r3146685 r3157194  
    2121    public $supports = array(
    2222        'products',
     23        'refunds'
    2324    );
    2425    /**
     
    4748        $this->title = $this->get_option('title');
    4849        $this->description = $this->get_option('description');
    49         //$this->supports = array(
    50         //      'products',
    51         //  );
    5250        $this->enabled = $this->get_option('enabled');
    5351        $this->testmode = 'yes' === $this->get_option('testmode');
     
    5553        $this->enable_vault = $this->get_option('save_payment_info');
    5654        $this->processor = $this->get_option('processor');
    57         $this->supports           = array('products', 'refunds');
     55        $this->supports = array('products', 'refunds');
     56
    5857        // Process admin options when saving payment gateway settings
    5958        add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
     
    890889    }
    891890
     891    // String operations functions
     892    public static function left($str, $length)
     893    {
     894        return substr($str, 0, $length);
     895    }
     896
     897    public static function right($str, $length)
     898    {
     899        if ($str != "") {
     900            return substr($str, -$length);
     901        } else {
     902            return "";
     903        }
     904    }
    892905
    893906    /**
     
    10031016
    10041017        $the_amount = $order->get_total();
     1018        $the_country = $order->get_billing_country();
     1019        $the_country_shipping = $order->get_shipping_country();
     1020        try {
     1021            $the_state = $order->get_billing_state();
     1022        } catch (Exception $e) {
     1023            $the_state = "";
     1024        }
     1025
     1026        try {
     1027            $the_state_shipping = $order->get_shipping_state();
     1028        } catch (Exception $e) {
     1029            $the_state_shipping = "";
     1030        }
     1031
     1032
     1033        // patch for remove value format XX-AA in some countries
     1034        if (($the_state != '') && ($the_country != '')) {
     1035            if (strpos($the_state, $the_country . "-")>=0) {
     1036                $the_state = str_replace($the_country . "-", "", $the_state);
     1037            }
     1038        }
     1039        if (($the_state_shipping != '') && ($the_country_shipping != '')) {
     1040            if (strpos($the_state_shipping, $the_country_shipping . "-") >=0) {
     1041                $the_state_shipping = str_replace($the_country_shipping . "-", "", $the_state_shipping);
     1042            }
     1043        }
     1044        // check if state is longer than 3 characters
     1045        if (strlen($the_state) > 3) {
     1046            $the_state = $this->left($the_state, 3);
     1047        }
     1048        if (strlen($the_state_shipping) > 3) {
     1049            $the_state_shipping = $this->left($the_state_shipping, 3);
     1050        }
    10051051
    10061052        // Build an array of sale authorization parameters.
     1053        // The parameter fix_iso_codes will ignore any country or state which is not on ISO format
    10071054        $sale_auth_params = array(
    10081055            'sale_auth_only' => $sale_method,
     
    10301077            'billing_address_address2' => $order->get_billing_address_2(),
    10311078            'billing_address_city' => $order->get_billing_city(),
    1032             'billing_address_state' => $order->get_billing_state(),
     1079            'billing_address_state' => $the_state,
    10331080            'billing_address_zip' => $order->get_billing_postcode(),
    1034             'billing_address_country' => $order->get_billing_country(),
     1081            'billing_address_country' => $the_country,
    10351082            'billing_address_phone' => $order->get_billing_phone(),
    10361083            'billing_address_email' => $order->get_billing_email(),
     
    10401087            'shipping_address_address2' => $order->get_shipping_address_2(),
    10411088            'shipping_address_city' => $order->get_shipping_city(),
    1042             'shipping_address_state' => $order->get_shipping_state(),
     1089            'shipping_address_state' => $the_state_shipping,
    10431090            'shipping_address_zip' => $order->get_shipping_postcode(),
    1044             'shipping_address_country' => $order->get_shipping_country(),
     1091            'shipping_address_country' => $the_country_shipping,
    10451092            'source_override' => 'WOOCOMMERCELITE',
     1093            'fix_iso_codes'=> 'true'
    10461094        );
    10471095
     1096
     1097       
     1098       
    10481099        // Adds line item information
    10491100        $sale_auth_params = array_merge($sale_auth_params, $item_array);
  • bulletproof-checkout-lite/trunk/includes/class-wc-bulletproof-shop-orders.php

    r3143215 r3157194  
    1616        add_action('wp_enqueue_scripts', array($this, 'bulletproof_frontend_enqueue_scripts'));
    1717
    18         add_filter('manage_woocommerce_page_wc-orders_columns', array($this, 'bulletproof_checkout_capture_column_header'), 10, 1);
    19         add_filter('manage_edit-shop_order_columns', array($this, 'bulletproof_checkout_capture_column_header'), 10, 1);
    20 
    21         add_action('manage_shop_order_posts_custom_column', array($this, 'bulletproof_checkout_capture_column_content_old'), 10, 2);
    22 
    23         add_action('manage_woocommerce_page_wc-orders_custom_column', array($this, 'bulletproof_checkout_capture_column_content'), 10, 2);
    24 
    25         add_action('wp_ajax_capture_order_payment', array($this, 'bulletproof_capture_order_payment_callback'));
    26     }
     18        if (BULLETPROOF_CHECKOUT_ADDORDERLISTCOLUMNS) {
     19            add_filter('manage_woocommerce_page_wc-orders_columns', array($this, 'bulletproof_checkout_capture_column_header'), 10, 1);
     20            add_filter('manage_edit-shop_order_columns', array($this, 'bulletproof_checkout_capture_column_header'), 10, 1);
     21            add_action('manage_shop_order_posts_custom_column', array($this, 'bulletproof_checkout_capture_column_content_old'), 10, 2);
     22            add_action('manage_woocommerce_page_wc-orders_custom_column', array($this, 'bulletproof_checkout_capture_column_content'), 10, 2);
     23            add_action('wp_ajax_capture_order_payment', array($this, 'bulletproof_capture_order_payment_callback'));
     24        }
     25
     26        // State is not a required field
     27        add_filter('woocommerce_shipping_fields', array($this, 'bp_unrequire_wc_shipping_state_field'));
     28        add_filter('woocommerce_billing_fields', array($this, 'bp_unrequire_wc_billing_state_field'));
     29        //  add_filter('default_checkout_billing_state', array($this, 'bp_remove_default_billing_state'));
     30        //  add_filter('default_checkout_shipping_state', array($this, 'bp_remove_default_billing_state'));
     31        add_filter('woocommerce_states', array($this, 'bp_filter_woocommerce_states'), 10, 1);
     32
     33        if (BULLETPROOF_CHECKOUT_DISABLEJETPACKSSO) {
     34            // JetPack SSO is a module auto-enabled in some hosting providers like Bluehost which
     35            // is in conflict with the Official Woo Mobile App (Mobile App requires JetPack enabled)
     36            // more info here: https://jetpack.com/support/getting-started-with-jetpack/known-issues/
     37            function jetpackcom_support_disable_jetpack_sso($modules)
     38            {
     39                $found = array_search('sso', $modules, true);
     40                if (false !== $found) {
     41                    unset($modules[$found]);
     42                }
     43                return $modules;
     44            }
     45            add_filter('option_jetpack_active_modules', 'jetpackcom_support_disable_jetpack_sso');
     46        }
     47    }
     48
     49   
     50
     51    public function bp_filter_woocommerce_states($states)
     52    {
     53        foreach ($states as $state_key => $state_value) {
     54            $states[$state_key]['hidden'] = false;
     55        }
     56
     57        // Add all the states missed by Woo , for example: Kuwait
     58        // AF
     59        $states['AF'] = array(
     60            'BDS' => 'Badakhshan',
     61            'BDG' => 'Badghis',
     62            'BGL' => 'Baghlan',
     63            'BAL' => 'Balkh',
     64            'BAM' => 'Bamyan',
     65            'DAY' => 'Daykundi',
     66            'FRA' => 'Farah',
     67            'FYB' => 'Faryab',
     68            'GHA' => 'Ghazni'     // There are some other missed states here
     69        );
     70        // Austria
     71        $states['AT'] = array(
     72            '1' => 'Burgenland',
     73            '2' => 'Carinthia',
     74            '3' => 'Lower Austria',
     75            '5' => 'Salzburg',
     76            '6' => 'Styria',
     77            '7' => 'Tyrol',
     78            '4' => 'Upper Austria',
     79            '9' => 'Vienna',
     80            '8' => 'Vorarlberg'
     81        );
     82        $states['ET'] = array(
     83            'SO' => 'Somali Region',
     84            'AM' => 'Amhara Region',
     85            'TI' => 'Tigray Region',
     86            'OR' => 'Oromia Region',
     87            'AF' => 'Afar Region',
     88            'HA' => 'Harari Region',
     89            'DD' => 'Dire Dawa',
     90            'BE' => 'Benishangul-Gumuz Region',
     91            'GA' => 'Gambela Region',
     92            'AA' => 'Addis Ababa'
     93        );
     94        $states['MT'] = array(
     95            '33' => 'Mqabba',
     96            '49' => 'San Gwann',
     97            '68' => 'Zurrieq',
     98            '25' => 'Luqa',
     99            '28' => 'Marsaxlokk',
     100            '42' => 'Qala',
     101            '66' => 'Zebbug Malta',
     102            '63' => 'Xghajra',
     103            '23' => 'Kirkop',
     104            '46' => 'Rabat',
     105            '9' => 'Floriana',
     106            '65' => 'Zebbug Gozo',
     107            '57' => 'Swieqi',
     108            '50' => 'Saint Lawrence',
     109            '5' => 'Birzebbuga',
     110            '29' => 'Mdina',
     111            '54' => 'Santa Venera',
     112            '22' => 'Kercem',
     113            '14' => 'Gharb',
     114            '19' => 'Iklin',
     115            '53' => 'Santa Lucija',
     116            '60' => 'Valletta',
     117            '34' => 'Msida',
     118            '4' => 'Birkirkara',
     119            '55' => 'Siggiewi',
     120            '21' => 'Kalkara',
     121            '48' => 'St. Julians',
     122            '45' => 'Victoria',
     123            '30' => 'Mellieha',
     124            '59' => 'Tarxien',
     125            '56' => 'Sliema',
     126            '18' => 'Hamrun',
     127            '16' => 'Ghasri',
     128            '3' => 'Birgu',
     129            '2' => 'Balzan',
     130            '31' => 'Mgarr',
     131            '1' => 'Attard',
     132            '44' => 'Qrendi',
     133            '38' => 'Naxxar',
     134            '12' => 'Gzira',
     135            '61' => 'Xaghra',
     136            '39' => 'Paola',
     137            '52' => 'Sannat',
     138            '7' => 'Dingli',
     139            '11' => 'Gudja',
     140            '43' => 'Qormi',
     141            '15' => 'Gharghur',
     142            '62' => 'Xewkija',
     143            '58' => 'Ta Xbiex',
     144            '64' => 'Zabbar',
     145            '17' => 'Ghaxaq',
     146            '40' => 'Pembroke',
     147            '24' => 'Lija',
     148            '41' => 'Pieta',
     149            '26' => 'Marsa',
     150            '8' => 'Fgura',
     151            '13' => 'Ghajnsielem',
     152            '35' => 'Mtarfa',
     153            '36' => 'Munxar',
     154            '37' => 'Nadur',
     155            '10' => 'Fontana',
     156            '67' => 'Zejtun',
     157            '20' => 'Senglea',
     158            '27' => 'Marsaskala',
     159            '6' => 'Cospicua',
     160            '51' => 'St. Pauls Bay',
     161            '32' => 'Mosta'
     162        );
     163        $states['RW'] = array(
     164            '5' => 'Southern Province',
     165            '4' => 'Western Province',
     166            '2' => 'Eastern Province',
     167            '1' => 'Kigali district',
     168            '3' => 'Northern Province'
     169        );
     170        $states['LI'] = array(
     171            '8' => 'Schellenberg',
     172            '7' => 'Schaan',
     173            '2' => 'Eschen',
     174            '11' => 'Vaduz',
     175            '6' => 'Ruggell',
     176            '5' => 'Planken',
     177            '4' => 'Mauren',
     178            '10' => 'Triesenberg',
     179            '3' => 'Gamprin',
     180            '1' => 'Balzers',
     181            '9' => 'Triesen'
     182        );
     183        $states['NO'] = array(
     184            '50' => 'Trøndelag',
     185            '3' => 'Oslo',
     186            '34' => 'Innlandet',
     187            '30' => 'Viken',
     188            '21' => 'Svalbard',
     189            '42' => 'Agder',
     190            '54' => 'Troms og Finnmark',
     191            '46' => 'Vestland',
     192            '15' => 'Møre og Romsdal',
     193            '11' => 'Rogaland',
     194            '38' => 'Vestfold og Telemark',
     195            '18' => 'Nordland',
     196            '22' => 'Jan Mayen'
     197        );
     198
     199        $states['IL'] = array(
     200            'Z' => 'Northern District',
     201            'M' => 'Central District',
     202            'D' => 'Southern District',
     203            'HA' => 'Haifa District',
     204            'JM' => 'Jerusalem District',
     205            'TA' => 'Tel Aviv District'
     206        );
     207        $states['BE'] = array(
     208            'VLI' => 'Limburg',
     209            'VLG' => 'Flanders',
     210            'VBR' => 'Flemish Brabant',
     211            'WHT' => 'Hainaut',
     212            'BRU' => 'Brussels-Capital Region',
     213            'VOV' => 'East Flanders',
     214            'WNA' => 'Namur',
     215            'WLX' => 'Luxembourg',
     216            'WAL' => 'Wallonia',
     217            'VAN' => 'Antwerp',
     218            'WBR' => 'Walloon Brabant',
     219            'VWV' => 'West Flanders',
     220            'WLG' => 'Liège'
     221        );
     222        $states['FI'] = array(
     223            '6' => 'Tavastia Proper',
     224            '7' => 'Central Ostrobothnia',
     225            '4' => 'Southern Savonia',
     226            '5' => 'Kainuu',
     227            '2' => 'South Karelia',
     228            '3' => 'Southern Ostrobothnia',
     229            '10' => 'Lapland',
     230            '17' => 'Satakunta',
     231            '16' => 'Päijänne Tavastia',
     232            '15' => 'Northern Savonia',
     233            '13' => 'North Karelia',
     234            '14' => 'Northern Ostrobothnia',
     235            '11' => 'Pirkanmaa',
     236            '19' => 'Finland Proper',
     237            '12' => 'Ostrobothnia',
     238            '1' => 'Åland Islands',
     239            '18' => 'Uusimaa',
     240            '8' => 'Central Finland',
     241            '9' => 'Kymenlaakso'
     242        );
     243        $states['LU'] = array(
     244            'DI' => 'Canton of Diekirch',
     245            'L' => 'Luxembourg District',
     246            'EC' => 'Canton of Echternach',
     247            'RD' => 'Canton of Redange',
     248            'ES' => 'Canton of Esch-sur-Alzette',
     249            'CA' => 'Canton of Capellen',
     250            'RM' => 'Canton of Remich',
     251            'G' => 'Grevenmacher District',
     252            'CL' => 'Canton of Clervaux',
     253            'ME' => 'Canton of Mersch',
     254            'VD' => 'Canton of Vianden',
     255            'D' => 'Diekirch District',
     256            'GR' => 'Canton of Grevenmacher',
     257            'WI' => 'Canton of Wiltz',
     258            'LU' => 'Canton of Luxembourg'
     259        );
     260        $states['SE'] = array(
     261            'X' => 'Gävleborg County',
     262            'W' => 'Dalarna County',
     263            'S' => 'Värmland County',
     264            'E' => 'Östergötland County',
     265            'K' => 'Blekinge County',
     266            'BD' => 'Norrbotten County',
     267            'T' => 'Örebro County',
     268            'D' => 'Södermanland County',
     269            'M' => 'Skåne County',
     270            'G' => 'Kronoberg County',
     271            'AC' => 'Västerbotten County',
     272            'H' => 'Kalmar County',
     273            'C' => 'Uppsala County',
     274            'I' => 'Gotland County',
     275            'O' => 'Västra Götaland County',
     276            'N' => 'Halland County',
     277            'U' => 'Västmanland County',
     278            'F' => 'Jönköping County',
     279            'AB' => 'Stockholm County',
     280            'Y' => 'Västernorrland County'
     281        );
     282        $states['PL'] = array(
     283            'OP' => 'Opole Voivodeship',
     284            'SL' => 'Silesian Voivodeship',
     285            'PM' => 'Pomeranian Voivodeship',
     286            'KP' => 'Kuyavian-Pomeranian Voivodeship',
     287            'PK' => 'Podkarpackie Voivodeship',
     288            'WN' => 'Warmian-Masurian Voivodeship',
     289            'DS' => 'Lower Silesian Voivodeship',
     290            'SK' => 'Swietokrzyskie Voivodeship',
     291            'LB' => 'Lubusz Voivodeship',
     292            'PD' => 'Podlaskie Voivodeship',
     293            'ZP' => 'West Pomeranian Voivodeship',
     294            'WP' => 'Greater Poland Voivodeship',
     295            'MA' => 'Lesser Poland Voivodeship',
     296            'LD' => 'Lód´z Voivodeship',
     297            'MZ' => 'Masovian Voivodeship',
     298            'LU' => 'Lublin Voivodeship'
     299        );
     300        $states['PT'] = array(
     301            '11' => 'Lisbon',
     302            '4' => 'Bragança',
     303            '2' => 'Beja',
     304            '30' => 'Madeira',
     305            '12' => 'Portalegre',
     306            '20' => 'Açores',
     307            '17' => 'Vila Real',
     308            '1' => 'Aveiro',
     309            '7' => 'Évora',
     310            '18' => 'Viseu',
     311            '14' => 'Santarém',
     312            '8' => 'Faro',
     313            '10' => 'Leiria',
     314            '5' => 'Castelo Branco',
     315            '15' => 'Setúbal',
     316            '13' => 'Porto',
     317            '3' => 'Braga',
     318            '16' => 'Viana do Castelo',
     319            '6' => 'Coimbra'
     320        );
     321
     322        $states['NL'] = array(
     323            'UT' => 'Utrecht',
     324            'GE' => 'Gelderland',
     325            'NH' => 'North Holland',
     326            'DR' => 'Drenthe',
     327            'ZH' => 'South Holland',
     328            'LI' => 'Limburg',
     329            'BQ3' => 'Sint Eustatius',
     330            'GR' => 'Groningen',
     331            'OV' => 'Overijssel',
     332            'FL' => 'Flevoland',
     333            'ZE' => 'Zeeland',
     334            'BQ2' => 'Saba',
     335            'FR' => 'Friesland',
     336            'NB' => 'North Brabant',
     337            'BQ1' => 'Bonaire'
     338        );
     339        $states['NL'] = array(
     340            '39' => 'Hiiu County',
     341            '84' => 'Viljandi County',
     342            '78' => 'Tartu County',
     343            '82' => 'Valga County',
     344            '70' => 'Rapla County',
     345            '86' => 'Võru County',
     346            '74' => 'Saare County',
     347            '67' => 'Pärnu County',
     348            '65' => 'Põlva County',
     349            '59' => 'Lääne-Viru County',
     350            '49' => 'Jõgeva County',
     351            '51' => 'Järva County',
     352            '37' => 'Harju County',
     353            '57' => 'Lääne County',
     354            '44' => 'Ida-Viru County'
     355        );
     356
     357        $states['NL'] = array(
     358            '41' => 'Jaffna District',
     359            '21' => 'Kandy District',
     360            '13' => 'Kalutara District',
     361            '81' => 'Badulla District',
     362            '33' => 'Hambantota District',
     363            '31' => 'Galle District',
     364            '42' => 'Kilinochchi District',
     365            '23' => 'Nuwara Eliya District',
     366            '53' => 'Trincomalee District',
     367            '62' => 'Puttalam District',
     368            '92' => 'Kegalle District',
     369            '2' => 'Central Province',
     370            '52' => 'Ampara District',
     371            '7' => 'North Central Province',
     372            '3' => 'Southern Province',
     373            '1' => 'Western Province',
     374            '9' => 'Sabaragamuwa Province',
     375            '12' => 'Gampaha District',
     376            '43' => 'Mannar District',
     377            '32' => 'Matara District',
     378            '91' => 'Ratnapura district',
     379            '5' => 'Eastern Province',
     380            '44' => 'Vavuniya District',
     381            '22' => 'Matale District',
     382            '8' => 'Uva Province',
     383            '72' => 'Polonnaruwa District',
     384            '4' => 'Northern Province',
     385            '45' => 'Mullaitivu District',
     386            '11' => 'Colombo District',
     387            '71' => 'Anuradhapura District',
     388            '6' => 'North Western Province',
     389            '51' => 'Batticaloa District',
     390            '82' => 'Monaragala District'
     391        );
     392        $states['DK'] = array(
     393            '85' => 'Region Zealand',
     394            '83' => 'Region of Southern Denmark',
     395            '84' => 'Capital Region of Denmark',
     396            '82' => 'Central Denmark Region',
     397            '81' => 'North Denmark Region',
     398        );
     399        $states['BH'] = array(
     400            '13' => 'Capital',
     401            '14' => 'Southern',
     402            '17' => 'Northern',
     403            '15' => 'Muharraq',
     404            '16' => 'Central'
     405        );
     406
     407        $states['BI'] = array(
     408            'RM' => 'Rumonge Province',
     409            'MY' => 'Muyinga Province',
     410            'MW' => 'Mwaro Province',
     411            'MA' => 'Makamba Province',
     412            'RT' => 'Rutana Province',
     413            'CI' => 'Cibitoke Province',
     414            'RY' => 'Ruyigi Province',
     415            'KY' => 'Kayanza Province',
     416            'MU' => 'Muramvya Province',
     417            'KR' => 'Karuzi Province',
     418            'KI' => 'Kirundo Province',
     419            'BB' => 'Bubanza Province',
     420            'GI' => 'Gitega Province',
     421            'BM' => 'Bujumbura Mairie Province',
     422            'NG' => 'Ngozi Province',
     423            'BL' => 'Bujumbura Rural Province',
     424            'CA' => 'Cankuzo Province',
     425            'BR' => 'Bururi Province'
     426        );
     427
     428        $states['LB'] = array(
     429            'JA' => 'South',
     430            'JL' => 'Mount Lebanon',
     431            'BH' => 'Baalbek-Hermel',
     432            'AS' => 'North',
     433            'AK' => 'Akkar',
     434            'BA' => 'Beirut',
     435            'BI' => 'Beqaa',
     436            'NA' => 'Nabatieh'
     437        );
     438        $states['IS'] = array(
     439            '2' => 'Southern Peninsula Region',
     440            '1' => 'Capital Region',
     441            '4' => 'Westfjords',
     442            '7' => 'Eastern Region',
     443            '8' => 'Southern Region',
     444            '5' => 'Northwestern Region',
     445            '3' => 'Western Region',
     446            '6' => 'Northeastern Region'
     447        );
     448        $states['FR'] = array(
     449            'BL' => 'Saint-Barthélemy',
     450            'NAQ' => 'Nouvelle-Aquitaine',
     451            'IDF' => 'Île-de-France',
     452            '976' => 'Mayotte',
     453            'ARA' => 'Auvergne-Rhône-Alpes',
     454            'OCC' => 'Occitanie',
     455            'PDL' => 'Pays-de-la-Loire',
     456            'NOR' => 'Normandie',
     457            '20R' => 'Corse',
     458            'BRE' => 'Bretagne',
     459            'MF' => 'Saint-Martin',
     460            'WF' => 'Wallis and Futuna',
     461            '6AE' => 'Alsace',
     462            'PAC' => 'Provence-Alpes-Côte-d Azur',
     463            '75C' => 'Paris',
     464            'CVL' => 'Centre-Val de Loire',
     465            'GES' => 'Grand-Est',
     466            'PM' => 'Saint Pierre and Miquelon',
     467            '973' => 'French Guiana',
     468            '974' => 'La Réunion',
     469            'PF' => 'French Polynesia',
     470            'BFC' => 'Bourgogne-Franche-Comté',
     471            '972' => 'Martinique',
     472            'HDF' => 'Hauts-de-France',
     473            '971' => 'Guadeloupe',
     474            '01' => 'Ain',
     475            '02' => 'Aisne',
     476            '03' => 'Allier',
     477            '04' => 'Alpes-de-Haute-Provence',
     478            '05' => 'Hautes-Alpes',
     479            '06' => 'Alpes-Maritimes',
     480            '07' => 'Ardèche',
     481            '08' => 'Ardennes',
     482            '09' => 'Ariège',
     483            '10' => 'Aube',
     484            '11' => 'Aude',
     485            '12' => 'Aveyron',
     486            '13' => 'Bouches-du-Rhône',
     487            '14' => 'Calvados',
     488            '15' => 'Cantal',
     489            '16' => 'Charente',
     490            '17' => 'Charente-Maritime',
     491            '18' => 'Cher',
     492            '19' => 'Corrèze',
     493            '21' => 'Côte-dOr',
     494            '22' => 'Côtes-dArmor',
     495            '23' => 'Creuse',
     496            '24' => 'Dordogne',
     497            '25' => 'Doubs',
     498            '26' => 'Drôme',
     499            '27' => 'Eure',
     500            '28' => 'Eure-et-Loir',
     501            '29' => 'Finistère',
     502            '2A' => 'Corse-du-Sud',
     503            '2B' => 'Haute-Corse',
     504            '30' => 'Gard',
     505            '31' => 'Haute-Garonne',
     506            '32' => 'Gers',
     507            '33' => 'Gironde',
     508            '34' => 'Hérault',
     509            '35' => 'Ille-et-Vilaine',
     510            '36' => 'Indre',
     511            '37' => 'Indre-et-Loire',
     512            '38' => 'Isère',
     513            '39' => 'Jura',
     514            '40' => 'Landes',
     515            '41' => 'Loir-et-Cher',
     516            '42' => 'Loire',
     517            '43' => 'Haute-Loire',
     518            '44' => 'Loire-Atlantique',
     519            '45' => 'Loiret',
     520            '46' => 'Lot',
     521            '47' => 'Lot-et-Garonne',
     522            '48' => 'Lozère',
     523            '49' => 'Maine-et-Loire',
     524            '50' => 'Manche',
     525            '51' => 'Marne',
     526            '52' => 'Haute-Marne',
     527            '53' => 'Mayenne',
     528            '54' => 'Meurthe-et-Moselle',
     529            '55' => 'Meuse',
     530            '56' => 'Morbihan',
     531            '57' => 'Moselle',
     532            '58' => 'Nièvre',
     533            '59' => 'Nord',
     534            '60' => 'Oise',
     535            '61' => 'Orne',
     536            '62' => 'Pas-de-Calais',
     537            '63' => 'Puy-de-Dôme',
     538            '64' => 'Pyrénées-Atlantiques',
     539            '65' => 'Hautes-Pyrénées',
     540            '66' => 'Pyrénées-Orientales',
     541            '67' => 'Bas-Rhin',
     542            '68' => 'Haut-Rhin',
     543            '69' => 'Rhône',
     544            '69M' => 'Métropole de Lyon',
     545            '70' => 'Haute-Saône',
     546            '71' => 'Saône-et-Loire',
     547            '72' => 'Sarthe',
     548            '73' => 'Savoie',
     549            '74' => 'Haute-Savoie',
     550            '76' => 'Seine-Maritime',
     551            '77' => 'Seine-et-Marne',
     552            '78' => 'Yvelines',
     553            '79' => 'Deux-Sèvres',
     554            '80' => 'Somme',
     555            '81' => 'Tarn',
     556            '82' => 'Tarn-et-Garonne',
     557            '83' => 'Var',
     558            '84' => 'Vaucluse',
     559            '85' => 'Vendée',
     560            '86' => 'Vienne',
     561            '87' => 'Haute-Vienne',
     562            '88' => 'Vosges',
     563            '89' => 'Yonne',
     564            '90' => 'Territoire de Belfort',
     565            '91' => 'Essonne',
     566            '92' => 'Hauts-de-Seine',
     567            '93' => 'Seine-Saint-Denis',
     568            '94' => 'Val-de-Marne',
     569            '95' => 'Val-dOise',
     570            'CP' => 'Clipperton',
     571            'TF' => 'French Southern and Antarctic Lands'
     572        );
     573        $states['PR'] = array(
     574            'SJ' => 'San Juan',
     575            'BY' => 'Bayamon',
     576            'CL' => 'Carolina',
     577            'PO' => 'Ponce',
     578            'CG' => 'Caguas',
     579            'GN' => 'Guaynabo',
     580            'AR' => 'Arecibo',
     581            'TB' => 'Toa Baja',
     582            'MG' => 'Mayagüez',
     583            'TA' => 'Trujillo Alto',
     584            '1' => 'Adjuntas',
     585            '3' => 'Aguada',
     586            '5' => 'Aguadilla',
     587            '7' => 'Aguas Buenas',
     588            '9' => 'Aibonito',
     589            '11' => 'Añasco',
     590            '13' => 'Arecibo',
     591            '15' => 'Arroyo',
     592            '17' => 'Barceloneta',
     593            '19' => 'Barranquitas',
     594            '21' => 'Bayamón',
     595            '23' => 'Cabo Rojo',
     596            '25' => 'Caguas',
     597            '27' => 'Camuy',
     598            '29' => 'Canóvanas',
     599            '31' => 'Carolina',
     600            '33' => 'Cataño',
     601            '35' => 'Cayey',
     602            '37' => 'Ceiba',
     603            '39' => 'Ciales',
     604            '41' => 'Cidra',
     605            '43' => 'Coamo',
     606            '45' => 'Comerío',
     607            '47' => 'Corozal',
     608            '49' => 'Culebra',
     609            '51' => 'Dorado',
     610            '53' => 'Fajardo',
     611            '54' => 'Florida',
     612            '55' => 'Guánica',
     613            '57' => 'Guayama',
     614            '59' => 'Guayanilla',
     615            '61' => 'Guaynabo',
     616            '63' => 'Gurabo',
     617            '65' => 'Hatillo',
     618            '67' => 'Hormigueros',
     619            '69' => 'Humacao',
     620            '71' => 'Isabela',
     621            '73' => 'Jayuya',
     622            '75' => 'Juana Díaz',
     623            '77' => 'Juncos',
     624            '79' => 'Lajas',
     625            '81' => 'Lares',
     626            '83' => 'Las Marías',
     627            '85' => 'Las Piedras',
     628            '87' => 'Loíza',
     629            '89' => 'Luquillo',
     630            '91' => 'Manatí',
     631            '93' => 'Maricao',
     632            '95' => 'Maunabo',
     633            '97' => 'Mayagüez',
     634            '99' => 'Moca',
     635            '101' => 'Morovis',
     636            '103' => 'Naguabo',
     637            '105' => 'Naranjito',
     638            '107' => 'Orocovis',
     639            '109' => 'Patillas',
     640            '111' => 'Peñuelas',
     641            '113' => 'Ponce',
     642            '115' => 'Quebradillas',
     643            '117' => 'Rincón',
     644            '119' => 'Río Grande',
     645            '121' => 'Sabana Grande',
     646            '123' => 'Salinas',
     647            '125' => 'San Germán',
     648            '127' => 'San Juan',
     649            '129' => 'San Lorenzo',
     650            '131' => 'San Sebastián',
     651            '133' => 'Santa Isabel',
     652            '135' => 'Toa Alta',
     653            '137' => 'Toa Baja',
     654            '139' => 'Trujillo Alto',
     655            '141' => 'Utuado',
     656            '143' => 'Vega Alta',
     657            '145' => 'Vega Baja',
     658            '147' => 'Vieques',
     659            '149' => 'Villalba',
     660            '151' => 'Yabucoa',
     661            '153' => 'Yauco'
     662        );
     663        $states['CZ'] = array(
     664            '644' => 'Breclav',
     665            '312' => 'Ceský Krumlov',
     666            '323' => 'Plzen-mesto',
     667            '643' => 'Brno-venkov',
     668            '20B' => 'Príbram',
     669            '532' => 'Pardubice',
     670            '804' => 'Nový Jicín',
     671            '523' => 'Náchod',
     672            '713' => 'Prostejov',
     673            '72' => 'Zlínský kraj',
     674            '422' => 'Chomutov',
     675            '20' => 'Stredoceský kraj',
     676            '311' => 'Ceské Budejovice',
     677            '20C' => 'Rakovník',
     678            '802' => 'Frýdek-Místek',
     679            '314' => 'Písek',
     680            '645' => 'Hodonín',
     681            '724' => 'Zlín',
     682            '325' => 'Plzen-sever',
     683            '317' => 'Tábor',
     684            '642' => 'Brno-mesto',
     685            '533' => 'Svitavy',
     686            '723' => 'Vsetín',
     687            '411' => 'Cheb',
     688            '712' => 'Olomouc',
     689            '63' => 'Kraj Vysocina',
     690            '42' => 'Ústecký kraj',
     691            '315' => 'Prachatice',
     692            '525' => 'Trutnov',
     693            '521' => 'Hradec Králové',
     694            '41' => 'Karlovarský kraj',
     695            '208' => 'Nymburk',
     696            '326' => 'Rokycany',
     697            '806' => 'Ostrava-mesto',
     698            '803' => 'Karviná',
     699            '53' => 'Pardubický kraj',
     700            '71' => 'Olomoucký kraj',
     701            '513' => 'Liberec',
     702            '322' => 'Klatovy',
     703            '722' => 'Uherské Hradište',
     704            '721' => 'Kromeríž',
     705            '413' => 'Sokolov',
     706            '514' => 'Semily',
     707            '634' => 'Trebíc',
     708            '10' => 'Praha',
     709            '427' => 'Ústí nad Labem',
     710            '80' => 'Moravskoslezský kraj',
     711            '51' => 'Liberecký kraj',
     712            '64' => 'Jihomoravský kraj',
     713            '412' => 'Karlovy Vary',
     714            '423' => 'Litomerice',
     715            '209' => 'Praha-východ',
     716            '32' => 'Plzenský kraj',
     717            '324' => 'Plzen-jih',
     718            '421' => 'Decín',
     719            '631' => 'Havlíckuv Brod',
     720            '512' => 'Jablonec nad Nisou',
     721            '632' => 'Jihlava',
     722            '52' => 'Královéhradecký kraj',
     723            '641' => 'Blansko',
     724            '424' => 'Louny',
     725            '204' => 'Kolín',
     726            '20A' => 'Praha-západ',
     727            '202' => 'Beroun',
     728            '426' => 'Teplice',
     729            '646' => 'Vyškov',
     730            '805' => 'Opava',
     731            '313' => 'Jindrichuv Hradec',
     732            '711' => 'Jeseník',
     733            '714' => 'Prerov',
     734            '201' => 'Benešov',
     735            '316' => 'Strakonice',
     736            '425' => 'Most',
     737            '647' => 'Znojmo',
     738            '203' => 'Kladno',
     739            '511' => 'Ceská Lípa',
     740            '531' => 'Chrudim',
     741            '524' => 'Rychnov nad Knežnou',
     742            '206' => 'Melník',
     743            '31' => 'Jihoceský kraj',
     744            '522' => 'Jicín',
     745            '321' => 'Domažlice',
     746            '715' => 'Šumperk',
     747            '207' => 'Mladá Boleslav',
     748            '801' => 'Bruntál',
     749            '633' => 'Pelhrimov',
     750            '327' => 'Tachov',
     751            '534' => 'Ústí nad Orlicí',
     752            '635' => 'Ždár nad Sázavou',
     753            '205' => 'Kutná Hora'
     754        );
     755        $states['KW'] = array(
     756            'JA' => 'Al Jahra',
     757            'HA' => 'Hawalli',
     758            'MU' => 'Mubarak Al-Kabeer',
     759            'FA' => 'Al Farwaniyah',
     760            'AH' => 'Al Ahmadi',
     761            'KU' => 'Capital'
     762        );
     763
     764        // The next countries are not supported:
     765        //AX
     766        //GF
     767        //GP
     768        //IM
     769        //KR
     770        //MF
     771        //MQ
     772        //RE
     773        //SG
     774        //SK
     775        //SI
     776        //VN
     777        //YT
     778
     779
     780
     781        return $states;
     782    }
     783
     784    public function bp_remove_default_billing_state()
     785    {
     786        return '';
     787    }
     788
     789    public function bp_unrequire_wc_billing_state_field($fields)
     790    {
     791        $fields['billing_state']['required'] = true;
     792        $fields['billing_state']['hidden'] = false;
     793        return $fields;
     794    }
     795
     796    public function bp_unrequire_wc_shipping_state_field($fields)
     797    {
     798        $fields['shipping_state']['required'] = true;
     799        $fields['shipping_state']['hidden'] = false;
     800        return $fields;
     801    }
     802
    27803
    28804    public function bulletproof_frontend_enqueue_scripts()
     
    34810    {
    35811        wp_enqueue_script('admin-custom-script', plugins_url('../assets/js/admin-custom-script.js', __FILE__), array('jquery'), '1.0', true);
     812
    36813        wp_localize_script('admin-custom-script', 'custom_script_vars', array(
    37814            'ajax_url' => admin_url('admin-ajax.php'),
     
    52829        if ('payment_capture_column' === $column) {
    53830            if ($order && $order->get_status() === 'on-hold') {
    54                 $transaction_id = $order->get_meta('_payment_gateway_tx_received',true);
     831                $transaction_id = $order->get_meta('_payment_gateway_tx_received', true);
    55832                if ($transaction_id != "") {
    56                     $sale_method_received = $order->get_meta('_bulletproof_gateway_action_type',true);
     833                    $sale_method_received = $order->get_meta('_bulletproof_gateway_action_type', true);
    57834                    if ($sale_method_received == "auth") {
    58835                        echo '<button class="button payment_capture_btn" data-order-id="' . esc_attr($order->get_id()) . '">Capture</button>';
     
    69846            $order = wc_get_order($order_id);
    70847            if ($order && $order->get_status() === 'on-hold') {
    71                 $transaction_id = $order->get_meta('_payment_gateway_tx_received',true);
     848                $transaction_id = $order->get_meta('_payment_gateway_tx_received', true);
    72849                if ($transaction_id != "") {
    73                     $sale_method_received = $order->get_meta('_bulletproof_gateway_action_type',true);
     850                    $sale_method_received = $order->get_meta('_bulletproof_gateway_action_type', true);
    74851                    if ($sale_method_received == "auth") {
    75852                        echo '<button class="button payment_capture_btn" data-order-id="' . esc_attr($order_id) . '">Capture</button>';
     
    116893            }
    117894
    118             $transaction_id = $order->get_meta('_payment_gateway_tx_received',true);
     895            $transaction_id = $order->get_meta('_payment_gateway_tx_received', true);
    119896            $api_url = $base_api_url . 'capture_payment.php?user=' . urlencode($username) .
    120897                '&pass=' . urlencode($password) .
Note: See TracChangeset for help on using the changeset viewer.