WC_Product_Variation::get_variation_attributes( bool $with_prefix = true )

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


Description Description


Parameters Parameters

$with_prefix

(Optional) Whether keys should be prepended with attribute_ or not,

Default value: true


Top ↑

Return Return

(array) of attributes and their values for this variation.


Top ↑

Source Source

File: includes/class-wc-product-variation.php

	public function get_variation_attributes() {
		$attributes           = $this->get_attributes();
		$variation_attributes = array();
		foreach ( $attributes as $key => $value ) {
			$variation_attributes[ 'attribute_' . $key ] = $value;
		}
		return $variation_attributes;
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.