• Resolved summerset21

    (@summerset21)


    Hello,

    Is it possible to change the formatting of the address fields returned from user selection? I tried implementing custom address fields according to the FAQ #5, but the data is currently presented in a way that doesn’t really work in the site language.

    For example, I want the (street)address line to display “<street name> <street number>”, instead of “<street number>, <street name>,”.

    I also want to remove the commas after City- and Street-fields.

    Thank you for this great plugin!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    I tried implementing custom address fields according to the FAQ #5, but the data is currently presented in a way that doesn’t really work in the site language.

    I understand. As pointed out in FAQ #5, the address change event fired exposes a formatted address with the following items,

    the event has 5 address fields, e.address.line, e.address.city, e.address.pin, e.address.state, e.address.country.

    For example, I want the (street)address line to display “<street name> <street number>”, instead of “<street number>, <street name>,”.

    I also want to remove the commas after City- and Street-fields.

    so the Google maps emits a very granular address component (see the js function parseGeolocationAddress starting at line 256 in the file cf7-google-map/public/js/cf7-googlemap.js

    these granular address components are parsed into an array, one for each item passed in the event above. Each of these arrays are then simply flattened with a ‘, ‘ delimiter on line 340 onwards.

    So you can always retrieve the original granular address components by doing the following,

    
    lineArr = e.address.line.split(', ');
    

    and then recombine the array as per your requirement.

    Thread Starter summerset21

    (@summerset21)

    Thank you, I will try that!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to change address format?’ is closed to new replies.