wc_get_attribute( int $id )
Get attribute data by ID.
Description Description
Parameters Parameters
- $id
-
(Required) Attribute ID.
Return Return
(stdClass|null)
Source Source
File: includes/wc-attribute-functions.php
function wc_get_attribute( $id ) {
$attributes = wc_get_attribute_taxonomies();
if ( ! isset( $attributes[ 'id:' . $id ] ) ) {
return null;
}
$data = $attributes[ 'id:' . $id ];
$attribute = new stdClass();
$attribute->id = (int) $data->attribute_id;
$attribute->name = $data->attribute_label;
$attribute->slug = wc_attribute_taxonomy_name( $data->attribute_name );
$attribute->type = $data->attribute_type;
$attribute->order_by = $data->attribute_orderby;
$attribute->has_archives = (bool) $data->attribute_public;
return $attribute;
}
Changelog Changelog
| Version | Description |
|---|---|
| 3.2.0 | Introduced. |