WC_Product_Variation::get_attribute() public WC 1.0
Returns a single product attribute as a string.
{} Это метод класса: WC_Product_Variation{}
Хуков нет.
Возвращает
Строку
. Ничего.
Использование
$WC_Product_Variation = new WC_Product_Variation(); $WC_Product_Variation->get_attribute( $attribute );
- $attribute(строка) (обязательный)
- to get.
Код WC_Product_Variation::get_attribute() WC Product Variation::get attribute WC 5.2.2
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 '';
}