WordPress at Your Fingertips
function is not described

WC_Product_Variation::get_attribute() public WC 1.0

Returns a single product attribute as a string.

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

No Hooks.

Return

String.

Usage

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

Code of WC_Product_Variation::get_attribute() WC 5.7.1

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

	if ( isset( $attributes[ $attribute ] ) ) {
		$value = $attributes[ $attribute ];
		$term  = taxonomy_exists( $attribute ) ? get_term_by( 'slug', $value, $attribute ) : false;
		return ! is_wp_error( $term ) && $term ? $term->name : $value;
	}

	$att_str = 'pa_' . $attribute;
	if ( isset( $attributes[ $att_str ] ) ) {
		$value = $attributes[ $att_str ];
		$term  = taxonomy_exists( $att_str ) ? get_term_by( 'slug', $value, $att_str ) : false;
		return ! is_wp_error( $term ) && $term ? $term->name : $value;
	}

	return '';
}