Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

CB Field - Select Country

  • tmoran
  • tmoran
  • OFFLINE
  • Posts: 166
  • Thanks: 12
  • Karma: 1
9 years 3 months ago #267895 by tmoran
CB Field - Select Country was created by tmoran
I'm trying to integrate CB fields with a shopping cart so that existing users can purchase product without having to re-enter their address details etc. in the checkout fields. The cart requires a user's Country and State/Province to apply tax rules. I have created a State/Province single select drop down as there are only 7 states, however I was wondering if there is a plugin or another way to create a Country select dropdown that lists every country, or do I have to add every individual country as a value?

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48473
  • Thanks: 8281
  • Karma: 1443
9 years 3 months ago - 9 years 3 months ago #267929 by krileon
Replied by krileon on topic CB Field - Select Country
Best way to have a CBSubs compatible country dropdown field is to use CBSubs own countries database table and build a select field from it using CB Query Field. The below should work.

Field Type: Query Drop Down (Single Select)
Query:
Code:
SELECT `country_iso_code2`, `country_name`, `country_region` FROM `#__comprofiler_countries` WHERE `country_region` != '' ORDER BY `country_region`, `country_name`
Value Column: country_iso_code2
Label Column: country_name
Group Column: country_region


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.
Last edit: 9 years 3 months ago by krileon.

Please Log in or Create an account to join the conversation.

  • tmoran
  • tmoran
  • OFFLINE
  • Posts: 166
  • Thanks: 12
  • Karma: 1
9 years 3 months ago #268179 by tmoran
Replied by tmoran on topic CB Field - Select Country
I have tried adding this field, but I get an error message when I publish the field and try to edit a user in user manager:

An error has occurred.

1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT `country_iso_code2`, `country_name`, country_region FROM `j17_comprofile' at line 1 SQL=SELECT `country_iso_code2`, `country_name`, country_region FROM `j17_comprofiler_countries` WHERE `country_region` != '' ORDER BY `country_region`, `country_name`


Can you please advise if I have the config correct in the following screenshots..








Attachments:

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48473
  • Thanks: 8281
  • Karma: 1443
9 years 3 months ago #268206 by krileon
Replied by krileon on topic CB Field - Select Country
That doesn't make any sense. There's nothing wrong with the syntax. Directly copy and paste from the textarea above to the Query input and it should work fine as long as CBSubs Tax has been installed, which provides the geolocation tables.

In another topic it was discovered the below usage is needed if you want it to synchronize with CBSubs invoice address though.

Field Type: Query Drop Down (Single Select)
Query:
Code:
SELECT `country_name`, `country_region` FROM `#__comprofiler_countries` WHERE `country_region` != '' ORDER BY `country_region`, `country_name`
Value Column: country_name
Label Column: country_name
Group Column: country_region


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 or Create an account to join the conversation.

  • tmoran
  • tmoran
  • OFFLINE
  • Posts: 166
  • Thanks: 12
  • Karma: 1
9 years 3 months ago - 9 years 3 months ago #268255 by tmoran
Replied by tmoran on topic CB Field - Select Country
Thanks krileon

Not sure what happened. CBSubs Tax was already installed. I re-pasted the syntax (and double checked to make sure it was identical to what I had originally pasted) re-saved and it now magically displays the Country field in user edit without any error message!!! Perhaps I'd left a space/linebreak in the syntax...

Is there another field/syntax I have to use for selecting a State/Province? The Country field is displayed, but once a country is selected there are no region groups showing:
Group Column = country_region

Is this what is meant to happen?
Last edit: 9 years 3 months ago by tmoran.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48473
  • Thanks: 8281
  • Karma: 1443
9 years 3 months ago #268289 by krileon
Replied by krileon on topic CB Field - Select Country
The region is just used as the optgroup. You don't get to select a region in it. The optgroup will display as bold text in the dropdown with its countries below it.


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 or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum