1

I have "Color Filters for WooCommerce" plugin and "color" taxonomy.

Each taxonomy have one custom field - color picker.

I want to display on archive page current color picker value of each product's.

I can call

get_option( 'nm_taxonomy_colors' );

And I'll get all values from this field, but I need only current.

This plugin have doc, but I don't know how I can use this filters

elm_cf_get_terms_args
elm_cf_color_style_attribute
  • Hi, I think the plugin only provides filtration and does not show individual product's colors. You should check all the meta_values for each product_id. You may find selected colors there. Try using get_meta_values(). – Faisal Alvi Mar 20 '17 at 12:06
1

The author of plugin help me with that. Thanks all.

global $post;
        $product_colors = get_the_terms( $post, 'product_color' );
        $saved_colors = get_option( 'nm_taxonomy_colors' );

        if(isset($product_colors) && is_array($product_colors)){
            foreach($product_colors as $color){
                $term_id = $color->term_id;

                $hex_code = $saved_colors[$term_id];

                echo $hex_code . '<br />';
            }
        }
0

you can use it like this.

$saved_colors = get_option( 'nm_taxonomy_colors' );
//just use current term_id here.
$color = @$saved_colors[$current_term_id];
echo $color //anywhere you want on single product page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.