• Hi,

    I am trying to create a clothing size dropdown that will provide conversion sizes for UK, EU and US and upon a selection will add a value set for each option.

    So for example,

    Value —– UK — EU — US
    4 ——- 4 — 34 — 37
    5 ——- 5 — 36 — 39
    6 ——- 6 — 38 — 41

    So if say a user is from the UK and is a UK size 5, the dropdown list shows the equivalent to the same in EU(36) and US(39), the value stored in the database is 5.

    This is handy to provide the conversion for users in the EU and US without a separate conversion table.

    Can anyone show me how this may be achieved.

    Thanks,

    Denis

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Aswin Giri

    (@aswingiri)

    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 2 years, 5 months ago by den1sa.
    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    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 years, 5 months ago by den1sa.
    Thread Starter den1sa

    (@den1sa)

    Bump. Can anyone offer any suggestions?

    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    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 2 years, 5 months ago by den1sa.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Dropdown value plus two references’ is closed to new replies.