wc_gzd_product_matches_extended_type

The WooCommerce Germanized wc gzd product matches extended type function.

Description

wc_gzd_product_matches_extended_type( $type, $product ); 

Parameters (2)

0. $type
The type.
1. $product
The product.

Usage

  1. if ( !function_exists( 'wc_gzd_product_matches_extended_type' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-germanized/includes/wc-gzd-product-functions.php'; 
  3.  
  4. // The type. 
  5. $type = null; 
  6.  
  7. // The product. 
  8. $product = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wc_gzd_product_matches_extended_type($type, $product); 
  12.  

Defined (1)

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

/includes/wc-gzd-product-functions.php  
  1. function wc_gzd_product_matches_extended_type( $type, $product ) { 
  2.  
  3. $parent = null; 
  4.  
  5. // Support Variations 
  6. if ( wc_gzd_get_crud_data( $product, 'parent' ) ) { 
  7. $parent = wc_get_product( wc_gzd_get_crud_data( $product, 'parent' ) ); 
  8.  
  9. $matches_type = false; 
  10.  
  11. if ( $type === $product->get_type() ) 
  12. $matches_type = true;  
  13. elseif ( is_callable( array( $product, 'is_' . $type ) ) ) 
  14. $matches_type = ( call_user_func_array( array( $product, 'is_' . $type ), array() ) === true ? true : false ); 
  15.  
  16. // Do only check parent if product does not match the type 
  17. if ( ! $matches_type && $parent ) 
  18. return wc_gzd_product_matches_extended_type( $type, $parent ); 
  19.  
  20. return $matches_type;