• Resolved viking36

    (@viking36)


    WooCommerce: 3.5.1
    WordPress: 4.9.8
    GeoIP Detection plugin 2.9.1 https://ru.wordpress.org/plugins/geoip-detect/

    I need to set the postal code value from GeoIP into billing or shipping fields in woocommerce checkout. By default (GeoIP Detection plugin) I can only set the following values:

    `$record->city->name [geoip_detect2 property=”city”]
    $record->mostSpecificSubdivision->isoCode [geoip_detect2 property=”mostSpecificSubdivision.isoCode”]
    $record->mostSpecificSubdivision->name [geoip_detect2 property=”mostSpecificSubdivision”]
    $record->country->isoCode [geoip_detect2 property=”country.isoCode”]
    $record->country->name [geoip_detect2 property=”country”]
    $record->location->latitude [geoip_detect2 property=”location.latitude”]
    $record->location->longitude [geoip_detect2 property=”location.longitude”]
    $record->continent->code [geoip_detect2 property=”continent.code”]
    $record->location->timeZone [geoip_detect2 property=”location.timeZone”]`

    I set values by following code in child-theme functions.php

    `add_filter( ‘woocommerce_checkout_fields’, ‘set_checkout_field_input_value_default’ );

    function set_checkout_field_input_value_default($fields) {
    $fields[‘billing’][‘billing_city’][‘default’] = do_shortcode( ‘[geoip_detect2 property=”city”]’ );
    $fields[‘billing’][‘billing_state’][‘default’] = do_shortcode( ‘[geoip_detect2 property=”mostSpecificSubdivision”]’ );
    $fields[‘billing’][‘billing_postcode’][‘default’] = do_shortcode( ‘???’ );
    return $fields;
    }`

    How can I set GeoIP postcode as a default value? Any solution, pls!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How can I get postal code using GeoIP?’ is closed to new replies.