Improved get attribute function.

This commit is contained in:
Mike Jolley 2012-01-10 17:14:40 +00:00
parent 371984b381
commit aa8f4596ba
1 changed files with 20 additions and 1 deletions

View File

@ -744,7 +744,26 @@ class woocommerce_product {
function get_attribute( $attr ) { function get_attribute( $attr ) {
$attributes = $this->get_attributes(); $attributes = $this->get_attributes();
if ( isset($attributes[$attr]) ) return $attributes[$attr]['value']; else return false; $attr = sanitize_title( $attr );
if (isset($attributes[$attr]) || isset($attributes['pa_' . $attr])) :
$attribute = isset($attributes[$attr]) ? $attributes[$attr] : $attributes['pa_' . $attr];
if ($attribute['is_taxonomy']) :
// Get string with terms
return get_the_term_list( $this->id, $attribute['name'], ''. '', ', ' );
else :
return $attribute['value'];
endif;
endif;
return false;
} }
/** Returns product attributes */ /** Returns product attributes */