Skip Navigation

[Résolu] Extract and compare City from entire Toolset Address field value

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
How can I compare the Toolset Address Field value (the entire address) to a single City value or ZIP code?

Solution:
It's not possible to extract a city from a Google Maps address using Toolset.

What you can do is compare the exact address, or, use some custom code to manipulate/read the address field differently.

Another - and the suggested one - approach is to use a custom field where you can add the city.
Both in the product and the user.

Then, you can compare those 2 fields.

This support ticket is created Il y a 6 années et 2 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Marqué : ,

This topic contains 3 réponses, has 3 voix.

Last updated by stephaneL-3 Il y a 6 années et 2 mois.

Assisted by: Beda.

Auteur
Publications
#617635

Hi there

I have added an Address field in the woocommerce PRODUCT content type.
I have also added an Address field to the USER profile.

I want to be able to compare the two address fields to see if the User is from the same City the product is from. If it is the same the user can buy the product, if not they cannot. I am happy to simply just hide the add to cart button using CSS if the city does not match.

Im trying to set this up but cant figure it out. Would you be able to kindly assist me in the right direction?

Much appreciated

Regards,

Pouya

#617864

It's not possible to extract a city from a Google Maps address using Toolset.
What you can do is compare the exact address, or, use some custom code to manipulate/read the address field differently.

Another - and the suggested one - approach is to use a custom field where you can add the city.
Both in the product and the user.

Then, you can compare those 2 fields.

#618109

thanks a lot man
i fixed it your way, brilliant idea
i then used the following code to check the two fields and it works 🙂

[wpv-conditional if="( $(wpcf-product-state) eq '[types usermeta="user-state" user_current="true" output="raw"][/types]' )"]both values match[/wpv-conditional]
[wpv-conditional if="( $(wpcf-product-state) ne '[types usermeta="user-state" user_current="true" output="raw"][/types]' )"]values do not match[/wpv-conditional]

#1621449

Hi there,

Just checking if this is still not possible to extract the city from an address field.
I have read most thread on this which are dating 2yrs + so I am hoping it is now possible to do this?
I read it was difficult if the coordinates (Lon/Lat) used are not in a city, but I don't mind if it return a null value, I am confident the address that will entered will be in a city in 99.9% of the time, and happy to risk the empty field.

However it seems conter intuitive to ask for an address and then have the user entered the town in a separate field, let alone the problem with mis spelling etc.

I have used other service whee you can indeed extract part of the address and I hope this can be done, it would be useful in so many ways to be able to extract the Country / Town fromt he address. The need of a manual sep field seems a little backward.

Thank you for you rtime
s

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.