WordPress at Your Fingertips
function is not described

WC_Product::get_attribute() public WC 1.0

Returns a single product attribute as a string.

{} It's a method of the class: WC_Product{}

No Hooks.

Return

String.

Usage

$WC_Product = new WC_Product();
$WC_Product->get_attribute( $attribute );
$attribute(string) (required)
to get.

Code of WC_Product::get_attribute() WC 5.5.2

<?php
public function get_attribute( $attribute ) {
	$attributes = $this->get_attributes();
	$attribute  = sanitize_title( $attribute );

	if ( isset( $attributes[ $attribute ] ) ) {
		$attribute_object = $attributes[ $attribute ];
	} elseif ( isset( $attributes[ 'pa_' . $attribute ] ) ) {
		$attribute_object = $attributes[ 'pa_' . $attribute ];
	} else {
		return '';
	}
	return $attribute_object->is_taxonomy() ? implode( ', ', wc_get_product_terms( $this->get_id(), $attribute_object->get_name(), array( 'fields' => 'names' ) ) ) : wc_implode_text_attributes( $attribute_object->get_options() );
}