WC_Product_Variation::get_variation_attributes()publicWC 1.0

Get variation attribute values. Keys are prefixed with attribute_, as stored, unless $with_prefix is false.

Метод класса: WC_Product_Variation{}

Хуков нет.

Возвращает

Массив. of attributes and their values for this variation.

Использование

$WC_Product_Variation = new WC_Product_Variation();
$WC_Product_Variation->get_variation_attributes( $with_prefix );
$with_prefix(true|false)
Whether keys should be prepended with attribute_ or not.
По умолчанию: true

Код WC_Product_Variation::get_variation_attributes() WC 8.7.0

public function get_variation_attributes( $with_prefix = true ) {
	$attributes           = $this->get_attributes();
	$variation_attributes = array();
	$prefix               = $with_prefix ? 'attribute_' : '';

	foreach ( $attributes as $key => $value ) {
		$variation_attributes[ $prefix . $key ] = $value;
	}
	return $variation_attributes;
}