wc_is_attribute_in_product_name()WC 3.0.2

Check if an attribute is included in the attributes area of a variation name.

Return

true|false.

Usage

wc_is_attribute_in_product_name( $attribute, $name );
$attribute(string) (required)
Attribute value to check for.
$name(string) (required)
Product name to check in.

Changelog

Since 3.0.2 Introduced.

wc_is_attribute_in_product_name() code WC 8.7.0

function wc_is_attribute_in_product_name( $attribute, $name ) {
	$is_in_name = stristr( $name, ' ' . $attribute . ',' ) || 0 === stripos( strrev( $name ), strrev( ' ' . $attribute ) );
	return apply_filters( 'woocommerce_is_attribute_in_product_name', $is_in_name, $attribute, $name );
}