Skip Navigation

[Resolved] Question about possibility to implement woocommerce product locations

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to know if it's possible to show locations on a map where a specific product can be found. If the Google Maps address isn't quite right, I would like to be able to set it using a specific latitude and longitude.

Solution: You could use a repeatable field group that contains an address field. Store all the locations for each product in RFGs, then loop over the RFGs on the front-end to display the markers. Or, you could create another custom post type for locations and use an M2M relationship between locations and products.

Types and Forms will allow you to set a lat/long location for any address field, but you will lose the text-based address if you make those adjustments.

This support ticket is created 5 years, 8 months ago. 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by pedro.S 5 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#1214897

Tell us what you are trying to do?
When the user enters the product page url, he doesn't have the option to buy it.
Instead, it must provide a map with all the stores where he can purchase that product.

1 - This is possible by extending Woocommerce post type and using a repeatable field (for every store that sells that product) group with a google map field, correct?
2 - Sometimes the google maps is not 100% acurate on the location, would it be possible to have option to insert the address using gps coordinates?

Actually the planned workflow really doesn't need Woocommerce since it won't need any payments, but i was wondering about this approach.

thanks

#1215162

1 - This is possible by extending Woocommerce post type and using a repeatable field (for every store that sells that product) group with a google map field, correct?
Hi, yes this is one way to do it. You can create a repeatable field group (RFG) that contains an address field, and loop over those RFGs to place markers on a map.

Or, you can create a custom post type called "Locations" or "Stores" or something similar, and place an address custom field on that post type. Then you can create a many-to-many relationship between Locations and Products. This approach is more convenient because there is less duplication of data when multiple Products are sold in the same Location.

2 - Sometimes the google maps is not 100% acurate on the location, would it be possible to have option to insert the address using gps coordinates?
Yes, it's possible to use numeric latitude and longitude coordinates like "40.673113, -73.983124". When you use your own custom latitude and longitude coordinates, however, you lose the text-based address. For example, let's say I enter New York, NY USA as the address. I don't like the placement of the marker so I adjust it slightly in wp-admin to use a specific latitude and longitude. Once I do that, the address field now shows the latitude and longitude coordinates, not "New York, NY USA". In theory you could use two fields. One address field with coordinates for the accurate map placement, and another simple text field for the text-based address.

#1215370

Hi Christian,

First of all, thank you for your time.

I don't like the placement of the marker so I adjust it slightly in wp-admin to use a specific latitude and longitude.
Is this possible also on the frontend using Toolset Forms?

Just 1 additional question:

When the user presses the button "Find stores that sell this products near me", it appears the popup to allow location tracking along with the map.
How is this tracking made by toolset (and Google Maps)? In desktop i know it's based on IP Address location, but when on mobile it's based on GPS correct?

it will allow also for search stores near adress X too, besides the IP/GPS tracking.

This will be possible out-of-the-box with Toolset?

Thanks

#1216023

Is this possible also on the frontend using Toolset Forms?
Yes, you can see an example in the Form here:
https://christiancox-22119-td-1.discover-wp.com/add-new-tour/
The Address field can accept an address, or you can use the "Show/Hide Coordinates" link to input a specific lat/long.

How is this tracking made by toolset (and Google Maps)? In desktop i know it's based on IP Address location, but when on mobile it's based on GPS correct?
It uses the HTML 5 Geolocation API, which is supported by modern browsers, including mobile device browsers. It relies on different criteria to determine location, including GPS and WiFi, and requires the HTTPS protocol for security: https://en.wikipedia.org/wiki/W3C_Geolocation_API

it will allow also for search stores near adress X too, besides the IP/GPS tracking.
Yes, your site visitors can search for stores near a specific address. Example here: https://christiancox-22119-rel-1.discover-wp.com/map-search/

#1216481

Thank you Christian.

Althought your first link is protected under login, i believe in your word.
Thank you for your out-of-the-box support and clear answers. You are definitly our favorite supporter for all the detailed explanations.