• Resolved frunky

    (@frunky)


    Hello!

    Firsly, thanks for the perfect plugin.

    How I can get current color’s value and display it on category page of each product and in single page of each product.

    I made this

    add_action( 'woocommerce_shop_loop_item_title', 'product_colors' );
    add_action( 'woocommerce_single_product_summary', 'product_colors' );
    
    function product_colors() {
        global $post;
        $terms = get_terms( 'product_color', apply_filters( 'elm_cf_color_style_attribute', $color));
        print_r($terms);
    }

    But I get everything except colors hex code.

    I know it’s custom field, but how I can get this value?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter frunky

    (@frunky)

    Hi, can I have an update on this ticket, please?

    Thanks so much

    Hi there.

    This code should work:

    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 />';
    				}
    			}
    Thread Starter frunky

    (@frunky)

    @dominykasgel, thanks a lot!!!
    Have a nice day!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How I can get color value?’ is closed to new replies.