Plugin Directory

Changeset 3468430


Ignore:
Timestamp:
02/24/2026 09:15:45 AM (5 weeks ago)
Author:
wootro
Message:

Version 2.2.4: Add state/county field and zipcode for international shipping quotations

Location:
woot-ro/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • woot-ro/trunk/README.txt

    r3467627 r3468430  
    44Requires at least: 4.0
    55Tested up to: 6.9
    6 Stable tag: 2.2.3
     6Stable tag: 2.2.4
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    7878
    7979== Changelog ==
     80
     81= 2.2.4 =
     82* New: State/county field now visible for all international countries without nomenclature (free text input)
     83* New: Zipcode (postal code) included in all shipping quotation requests
     84* New: County name sent in quotation requests for countries without nomenclature
     85* Fix: State field was hidden for countries without predefined states in classic checkout
    8086
    8187= 2.2.3 =
     
    188194== Upgrade Notice ==
    189195
     196= 2.2.4 =
     197* International shipping quotations now include zipcode, county name, and state field for all countries. Improved accuracy for cross-border shipping rates.
     198
    190199= 2.2.3 =
    191200* Shipping options with fixed prices now appear immediately at checkout. Parcel weight minimum enforced at 1kg.
  • woot-ro/trunk/includes/admin/class-woot-admin-order.php

    r3467627 r3468430  
    560560        $city = !empty($address_data['city']) ? $address_data['city'] : ($order->get_shipping_city() ?: $order->get_billing_city());
    561561        $address = !empty($address_data['address']) ? $address_data['address'] : ($order->get_shipping_address_1() ?: $order->get_billing_address_1());
    562 
    563         if ($debug) error_log("Woot Admin Quotation: Address - country: $country, state: $state, city: $city, address: $address");
     562        $postcode = !empty($address_data['postcode']) ? $address_data['postcode'] : ($order->get_shipping_postcode() ?: $order->get_billing_postcode());
     563
     564        if ($debug) error_log("Woot Admin Quotation: Address - country: $country, state: $state, city: $city, address: $address, postcode: $postcode");
    564565
    565566        if (empty($country) || empty($city)) {
     
    597598        } else {
    598599            $receiver['city'] = $city;
     600            if (!empty($state)) {
     601                $states = WC()->countries->get_states($country);
     602                $receiver['county_name'] = isset($states[$state]) ? $states[$state] : $state;
     603            }
     604        }
     605
     606        // Always send zipcode if available
     607        if (!empty($postcode)) {
     608            $receiver['zipcode'] = $postcode;
    599609        }
    600610
     
    763773        $debug['city'] = !empty($address_data['city']) ? $address_data['city'] : ($order->get_shipping_city() ?: $order->get_billing_city());
    764774        $debug['address'] = !empty($address_data['address']) ? $address_data['address'] : ($order->get_shipping_address_1() ?: $order->get_billing_address_1());
     775        $debug['postcode'] = !empty($address_data['postcode']) ? $address_data['postcode'] : ($order->get_shipping_postcode() ?: $order->get_billing_postcode());
    765776
    766777        $country_info = Woot_API::get_country_by_code($debug['country']);
     
    791802            if (!empty($city_id)) {
    792803                $receiver['city_id'] = $city_id;
     804            } else {
     805                $receiver['city'] = $debug['city'];
     806                if (!empty($debug['state'])) {
     807                    $states = WC()->countries->get_states($debug['country']);
     808                    $receiver['county_name'] = isset($states[$debug['state']]) ? $states[$debug['state']] : $debug['state'];
     809                }
     810            }
     811
     812            // Always send zipcode if available
     813            if (!empty($debug['postcode'])) {
     814                $receiver['zipcode'] = $debug['postcode'];
    793815            }
    794816
  • woot-ro/trunk/includes/checkout/class-woot-checkout-fields.php

    r3438930 r3468430  
    6565        }
    6666
     67        // For Woot countries WITHOUT counties, ensure state field is visible as free text
     68        $wc_countries = WC()->countries->get_allowed_countries();
     69        $woot_countries = Woot_API::get_countries();
     70
     71        foreach ($woot_countries as $country) {
     72            $code = !empty($country['code']) ? strtoupper($country['code']) : '';
     73            if (empty($code) || !isset($wc_countries[$code])) {
     74                continue;
     75            }
     76            // Skip countries that already have counties (handled above)
     77            if (isset($woot_states[$code])) {
     78                continue;
     79            }
     80            if (!isset($locale[$code])) {
     81                $locale[$code] = array();
     82            }
     83            $locale[$code]['state'] = array(
     84                'required' => true,
     85                'hidden' => false,
     86            );
     87        }
     88
    6789        return $locale;
    6890    }
     
    143165        foreach ($woot_states as $country_code => $states) {
    144166            $countries[$country_code] = $states;
     167        }
     168
     169        // For Woot countries WITHOUT counties, remove from states list
     170        // so WooCommerce JS shows a text input instead of hiding the field
     171        $woot_countries = Woot_API::get_countries();
     172        foreach ($woot_countries as $country) {
     173            $code = !empty($country['code']) ? strtoupper($country['code']) : '';
     174            if (empty($code) || isset($woot_states[$code])) {
     175                continue;
     176            }
     177            if (isset($countries[$code]) && empty($countries[$code])) {
     178                unset($countries[$code]);
     179            }
    145180        }
    146181
  • woot-ro/trunk/includes/shipping/class-woot-shipping-services.php

    r3467627 r3468430  
    911911        $address_1 = $get_value($destination, 'address_1');
    912912        $address = $get_value($destination, 'address');
     913        $postcode = $get_value($destination, 'postcode');
    913914
    914915        if ($debug) {
    915             error_log("Woot Quotation: Destination - country: $country, city: $city, state: $state");
     916            error_log("Woot Quotation: Destination - country: $country, city: $city, state: $state, postcode: $postcode");
    916917        }
    917918
     
    963964            $receiver['city_id'] = $city_id;
    964965        } else {
    965             // Country has no nomenclature - send city name
     966            // Country has no nomenclature - send city name and county name
    966967            $receiver['city'] = $city;
    967 
    968             if ($debug) error_log("Woot Quotation: Using city name: $city");
     968            if (!empty($state)) {
     969                $states = WC()->countries->get_states($country);
     970                $receiver['county_name'] = isset($states[$state]) ? $states[$state] : $state;
     971            }
     972
     973            if ($debug) error_log("Woot Quotation: Using city name: $city, county_name: " . ($receiver['county_name'] ?? ''));
     974        }
     975
     976        // Always send zipcode if available
     977        if (!empty($postcode)) {
     978            $receiver['zipcode'] = $postcode;
    969979        }
    970980
  • woot-ro/trunk/woot.php

    r3467627 r3468430  
    1717 * Plugin URI:        https://woot.ro
    1818 * Description:       Integrates all popular couriers in Romania, providing a one-stop solution for all your delivery needs
    19  * Version:           2.2.3
     19 * Version:           2.2.4
    2020 * Author:            Woot.ro
    2121 * Author URI:        https://woot.ro
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define('WOOT_VERSION', '2.2.3');
     38define('WOOT_VERSION', '2.2.4');
    3939
    4040/**
Note: See TracChangeset for help on using the changeset viewer.