Skip to content

Instantly share code, notes, and snippets.

@wplaunchify
Forked from dleone81/functions.php
Created January 30, 2020 06:10
Show Gist options
  • Save wplaunchify/22fcc03c3b726ada9fbd69b6e610807f to your computer and use it in GitHub Desktop.
Save wplaunchify/22fcc03c3b726ada9fbd69b6e610807f to your computer and use it in GitHub Desktop.
Woocommerce get product type
/**
* 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