WC_API_Products::get_attribute_taxonomy_by_slug()privateWC 2.2

Get attribute taxonomy by slug.

Method of the class: WC_API_Products{}

No Hooks.

Return

String|null.

Usage

// private - for code of main (parent) class only
$result = $this->get_attribute_taxonomy_by_slug( $slug );
$slug(string) (required)
-

Changelog

Since 2.2 Introduced.

WC_API_Products::get_attribute_taxonomy_by_slug() code WC 8.9.0

private function get_attribute_taxonomy_by_slug( $slug ) {
	$taxonomy = null;
	$attribute_taxonomies = wc_get_attribute_taxonomies();

	foreach ( $attribute_taxonomies as $key => $tax ) {
		if ( $slug == $tax->attribute_name ) {
			$taxonomy = 'pa_' . $tax->attribute_name;

			break;
		}
	}

	return $taxonomy;
}