wc_is_attribute_in_product_name

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

Description

wc_is_attribute_in_product_name( (string) $attribute, (string) $name ); 

Parameters (2)

0. $attribute (string)
Attribute value to check for
1. $name (string)
Product name to check in

Usage

  1. if ( !function_exists( 'wc_is_attribute_in_product_name' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-attribute-functions.php'; 
  3.  
  4. // Attribute value to check for 
  5. $attribute = ''; 
  6.  
  7. // Product name to check in 
  8. $name = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wc_is_attribute_in_product_name($attribute, $name); 
  12.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-attribute-functions.php  
  1. function wc_is_attribute_in_product_name( $attribute, $name ) { 
  2. $is_in_name = stristr( $name, ' ' . $attribute . ', ' ) || 0 === stripos( strrev( $name ), strrev( ' ' . $attribute ) ); 
  3. return apply_filters( 'woocommerce_is_attribute_in_product_name', $is_in_name, $attribute, $name );