Support » Plugins » Hacks » Custom field (get_post_meta) issue

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator bcworkz

    (@bcworkz)

    There’s not really anything wrong, you’re just a bit confused about what’s going on. I’m not familiar with the woo select function, but based on your described results, I’m certain it outputs <option> lines which, for the ‘two’ option, would look like this:
    <option value="two">Option 2</option>

    Thus when this option is selected, the value in $_POST['myfieldname'] would naturally be “two”, so your script 2 will store it as such and your script 3 displays it.

    You have several options on how to end up displaying ‘Option 2’. Write your own select/option HTML output where the values are set correctly. Change the array key names passed to the woo select function. In either script 2 or 3 use an array like the woo options argument to translate ‘two’ back to ‘Option 2’. Instead of a translation array, you could hard code a PHP switch/case structure to do the same thing.

    One choice is probably more efficient than the others, I’m not sure which. I would suggest the write your own option unless there’s a reason I’m unaware of to use one of the others.

    Guido

    (@guido07111975)

    Hi,

    Thanks for your response!
    I did not thought about the possibility this is a woocommerce issue > so it might handle the select box different from default WP select box in frontend.

    I will work on this.

    Guido

    Guido

    (@guido07111975)

    @bcworkz: I decided to open a topic in Woocommerce forum because I have no idea how to solve this…

    https://wordpress.org/support/topic/get_post_meta-get-value-of-selectbox?

    Guido

    Guido

    (@guido07111975)

    Moderator bcworkz

    (@bcworkz)

    Nice work! Thanks for reporting back.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom field (get_post_meta) issue’ is closed to new replies.