• bkmason

    (@bkmason)


    When a user selects a color from a dropdown box on the product page I would like to retrieve that selected color attribute or term to use in a table I’m building. I can get a list of all the colors (red, black, blue, green) for the individual product on the product page using the code listed below but I only want the currently selected color. Example: if a user selects red I would like the $term-> name “red” to be used in my PHP code and not all the colors associated with that product. I’ve tried get_term, get_term_by, has_term, etc.
    `$terms = get_the_terms($product->id,’pa_color’ );
    foreach( $terms as $term ) {
    echo “<option>” . $term->name . “</option>”;}`

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter bkmason

    (@bkmason)

    Does anybody have an answer to this question? I’ve posted three question on this form over the past three years and have never gotten an answer or even a response. Is this an active form?

    Did you got the solution ? I am looking for the similar solution.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Getting current product attribute pa_color’ is closed to new replies.