Hello @den1sa
To achieve your requirement you will need an “IP to Location” service or You will need a field where users will select their country.
Secondly, you will need to make modifications to choices within the “Choice Callback” function based on the user’s country. Please check this documentation about UM dropdown Choices Callback.
Thread Starter
den1sa
(@den1sa)
Hi Aswin,
I think i didn’t explain myself very well, sorry about that.
If i provide another example thats doesn´t relate to country, i think it will be better to understand what I am asking for.
If a user clicks on the dropdown list they are presented with the following;
A value which is stored in the database and a description which is for reference only.
Value = 8
Reference = Small
so i need it to look like this …
8 – Small
10 – Small
12 – Medium
14 – Medium
16 – Large
… and so on.
So when I search for clothing size, I can filter clothing size that is between 8 and 10 only for example which is why i only need the value stored.
I hope this helps to understand my requirement.
Thanks,
Denis
-
This reply was modified 3 weeks ago by
den1sa.
Hi @den1sa
Have you tried using the Choices Callback function so you can separate the Labels and Values? Here’s an example code snippet:
function my_cloething_size_list_dropdown() {
$arr_sizes = array(
"8"=>"Small",
"10"=>"Small",
"12"=>"Medium",
"14"=>"Medium",
"16"=>"Large",
);
return $arr_sizes;
}
Regards,
Thread Starter
den1sa
(@den1sa)
Hi.
Thank you for your suggestion. I am not sure I understand this. I am trying to avoid having to use a table and list the corresponding description per line. So the user sees a dropdown that looks like this.
8 – Small
10 – Small
12 – Medium
14 – Medium
16 – Large
and so on…
So i need both values to show up in the dropdown, but only the numerical value stored.
Does what you suggested achieve this? If not, is this doable?
Thanks in advance.
Denis
-
This reply was modified 2 weeks, 4 days ago by
den1sa.
Thread Starter
den1sa
(@den1sa)
Bump. Can anyone offer any suggestions?
Hi @den1sa
Sorry for the late response.
You can try the following Choices callback function. It will display the size and text as option labels but stores only the size number to the database:
function my_cloething_size_list_dropdown() {
$arr_sizes = array(
"8"=> "8 - Small",
"10"=>"10 - Small",
"12"=>"12 - Medium",
"14"=>"14 - Medium",
"16"=>"16 - Large",
);
return $arr_sizes;
}
Please see the steps here to add the choices callback function:
https://docs.ultimatemember.com/article/1486-how-to-use-choices-callback
Thread Starter
den1sa
(@den1sa)
Thank you, i have now entered this in my code.
Can you please confirm that the value stored is stored as a number, so I can for example filter clothing size to only show between 12 – 16 only?
-
This reply was modified 1 week, 5 days ago by
den1sa.