-
-
Save hslaszlo/cb13f147fc304c05b9de99c29da1bc8c to your computer and use it in GitHub Desktop.
Woocommerce get product type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* is_type can be simple, variable, grouped, external | |
* woocommerce_single_product_summary is hook! | |
* Put this into your functions.php (child-theme) | |
**/ | |
add_action( 'woocommerce_single_product_summary', 'get_product_type', 5 ); | |
function get_product_type() { | |
global $post; | |
if( function_exists('get_product') ){ | |
$product = get_product( $post->ID ); | |
if( $product->is_type( 'variable' ) ){ | |
echo // do something with external products | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment