CB Field - Select Country

8 years 9 months ago #268316 by tmoran
Replied by tmoran on topic CB Field - Select Country
I'm trying to marry my cb user fields with mijoshop/opencart customer fields. I have the mijoshop developer insisting that the state/province field cannot simply be a single select drop down as I currently have.

He advises my cb_country field is now compatible (thank you), however I need to be able to have a similar Query Drop Down for state/province (province_iso_code), as is used, I presume, for the CB Subs Geographical Country and State / Province entries forming a Geographic Zone.

Can I achieve this for a cb user field?



<select aria-invalid="false" name="province_iso_code" id="province_iso_code" class="form-control" title="province_iso_code|The State / Province is optional.">
<option value="" id="province_iso_code__cbf0" selected="selected">All</option>
<option value="AU-ACT" id="province_iso_code__cbf1">Australian Capital Territory</option>
<option value="AU-NSW" id="province_iso_code__cbf2">New South Wales</option>
<option value="AU-NT" id="province_iso_code__cbf3">Northern Territory</option>
<option value="AU-QLD" id="province_iso_code__cbf4">Queensland</option>
<option value="AU-SA" id="province_iso_code__cbf5">South Australia</option>
<option value="AU-TAS" id="province_iso_code__cbf6">Tasmania</option>
<option value="AU-VIC" id="province_iso_code__cbf7">Victoria</option>
<option value="AU-WA" id="province_iso_code__cbf8">Western Australia</option>
</select>
Attachments:

Please Log in to join the conversation.

8 years 9 months ago #268337 by krileon
Replied by krileon on topic CB Field - Select Country
CBSubs Tax provides a province database table as well. The below should probably work fine.

Field Type: Query Drop Down (Single Select)
Query:
SELECT p.`province_iso_code`, p.`province_name`, c.`country_name`
FROM `#__comprofiler_provinces` AS p
LEFT JOIN `#__comprofiler_countries` AS c
ON c.`country_iso_code2` = p.`country_iso_code2`
ORDER BY c.`country_name`, p.`province_name`
Value Column: province_iso_code
Label Column: province_name
Group Column: country_name


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

8 years 9 months ago - 8 years 9 months ago #268374 by tmoran
Replied by tmoran on topic CB Field - Select Country
I'm getting very close... the state/province drop down works, however it lists the state/province of every country. This is despite having already selected a particular country in my cb_country field.

Is it posible to make the field dependent on what country has been selected so that only that country's state/province is displayed. (as does the CB Subs Geographical Country and State / Province entries).

Perhaps I need to rename my field? cb_state

Please Log in to join the conversation.

8 years 9 months ago #268389 by krileon
Replied by krileon on topic CB Field - Select Country
It's possible, but it won't ajax update. This means the page has to be reloaded after changing the country. You'd have to add a WHERE statement to the query to filter it down to just the selected country.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

8 years 9 months ago #268493 by tmoran
Replied by tmoran on topic CB Field - Select Country
Can you please provide me with the actual WHERE statement and how I should add it?

Strange how it won't ajax update! Why can it be achieved when selecting a country in CB Subs Geographical Country and State / Province entries and not in this instance?

Please Log in to join the conversation.

8 years 9 months ago #268521 by krileon
Replied by krileon on topic CB Field - Select Country

Can you please provide me with the actual WHERE statement and how I should add it?

Please understand I am not here to provide you with custom coding. I've provided more then ample examples to fit your needs. If you should need any further custom coding needs consider consulting with a contracted developer as needed.

See the below for adding a where statement to filter the selection to currently selected country. In the previous example it stored by country name so this needs to be filtered by country name.

SELECT p.`province_iso_code`, p.`province_name`, c.`country_name`
FROM `#__comprofiler_provinces` AS p
LEFT JOIN `#__comprofiler_countries` AS c
ON c.`country_iso_code2` = p.`country_iso_code2`
WHERE c.`country_name` = '[cb_country]'
ORDER BY c.`country_name`, p.`province_name`

Adjust cb_country fieldname to whatever fieldname your country field is using.

Strange how it won't ajax update! Why can it be achieved when selecting a country in CB Subs Geographical Country and State / Province entries and not in this instance?

Because we have no fieldtype implemented to handle that very specific case. That's hardcoded into CBSubs. I already have a future project planned to create a chained fieldtype to provide this functionality, but I won't be starting any new projects until after the GJ rewrite that I am currently working on.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.261 seconds

Facebook Twitter LinkedIn