Hi..!
I'm looking for at way to copy the billing country from my WooCommerce shop into a field in my form.
The billing country in WooCommerce is automatically updated through Geolocation, and I need to copy the country into a field in order to make correct calculations for product price and VAT.
I am presuming that a PHP code is the best option, and I'm hoping that one of you can help me out :-)
BR
Karsten
Please login or Register to submit your answer
To properly understand and address your need, please refer to these diagnostic questions. The information you provided is not detailed enough to help you.
---
🔍 Diagnostic Questions for Clarification
1. About the Form and Timing
* Where in the user journey should the billing country be copied into the form?
(e.g., upon page load, after WooCommerce checkout, when user adds product to cart, etc.)
* Is the Formidable Form embedded within the WooCommerce checkout process or on a separate page/post?
* Is the form being filled out before or after the WooCommerce purchase is completed?
* Does the form need to reflect live geolocation updates, or only the last known WooCommerce billing country?
2. About the WooCommerce Setup
* Is WooCommerce's built-in MaxMind geolocation feature enabled and configured?
(Geolocation with or without page caching affects reliability.)
* Are you relying solely on geolocation, or can users manually override the billing country during checkout?
* Is the billing country already stored in the user’s WooCommerce account/profile or only determined per session?
3. About the Field and Data Use
* Which field in the Formidable Form should receive the billing country?
* What field type is it?
(e.g., dropdown with country list, text field, hidden field)
* Is the value used for pricing logic within the form or submitted data only?
4. About the Technical Requirements
* Is the user logged in when submitting the form, or is this for guest users too?
* Do you have access to custom coding (e.g., adding hooks or shortcodes in PHP or JS)?
* Is this a multi-site or multi-language WooCommerce setup (e.g., using WPML)?
5. Alternative Data Sources
* Is it acceptable to use the geolocated IP country instead of the actual billing country saved in WooCommerce?
* Would using a JavaScript-based geolocation plugin be an option, or must it use WooCommerce's geolocation system?
Hi Victor.
Thank you for getting back to me. I have tried to answer your questions below.
1. About the Form and Timing
* Where in the user journey should the billing country be copied into the form?(e.g., upon page load, after WooCommerce checkout, when user adds product to cart, etc.)
ANSWER: Upon page load when user enters the website.
* Is the Formidable Form embedded within the WooCommerce checkout process or on a separate page/post?
ANSWER: Yes, FF is embedded within the WooCommerce checkout process (it's being used to calculate the total price).
* Is the form being filled out before or after the WooCommerce purchase is completed?
ANSWER: It's being filled out before the purchase is completed.
* Does the form need to reflect live geolocation updates, or only the last known WooCommerce billing country?
ANSWER: It should reflect the live geolocation.
2. About the WooCommerce Setup
* Is WooCommerce's built-in MaxMind geolocation feature enabled and configured? (Geolocation with or without page caching affects reliability.)
ANSWER: Yes, the MaxMind geolocation feature is enabled and configured - it's with page caching.
* Are you relying solely on geolocation, or can users manually override the billing country during checkout?
ANSWER: It's possible for the user to change the billing country during checkout.
* Is the billing country already stored in the user’s WooCommerce account/profile or only determined per session?
ANSWER: Only if the user has created an account prior to checkout, but it's possible to complete a purchase as guest.
3. About the Field and Data Use
* Which field in the Formidable Form should receive the billing country?
ANSWER: It can be either a text field or hidden field.
* What field type is it? (e.g., dropdown with country list, text field, hidden field)
ANSWER: It can be either a text field or hidden field.
* Is the value used for pricing logic within the form or submitted data only?
ANSWER: The value is being used for pricing logic (e.g. shipping price, duties and VAT).
4. About the Technical Requirements
* Is the user logged in when submitting the form, or is this for guest users too?
ANSWER: It's is possible to complete a purchase as guest user.
* Do you have access to custom coding (e.g., adding hooks or shortcodes in PHP or JS)?
ANSWER: Yes, we can implement custom coding throught Snippet.
* Is this a multi-site or multi-language WooCommerce setup (e.g., using WPML)?
ANSWER: It is a multi-language and multi-currency site and we are using WPML to translate the page.
5. Alternative Data Sources
* Is it acceptable to use the geolocated IP country instead of the actual billing country saved in WooCommerce?
ANSWER: Yes, it would be acceptable to use the geolocated IP country instead of the actual billing country.
* Would using a JavaScript-based geolocation plugin be an option, or must it use WooCommerce's geolocation system?