WC_Product_Variation::get_variation_attributes
Get variation attribute values. Keys are prefixed with attribute_, as stored, unless $with_prefix is false.
Method of the class: WC_Product_Variation{}
No Hooks.
Returns
Array. of attributes and their values for this variation.
Usage
$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.
Default: true
WC_Product_Variation::get_variation_attributes() WC Product Variation::get variation attributes code WC 10.4.3
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;
}