Skip to content

Instantly share code, notes, and snippets.

@kurtschlatzer
Forked from dleone81/functions.php
Created October 20, 2016 18:37
Show Gist options
  • Save kurtschlatzer/717cdfabb2a2d17ef3fda031757c37f6 to your computer and use it in GitHub Desktop.
Save kurtschlatzer/717cdfabb2a2d17ef3fda031757c37f6 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