-
-
Save kurtschlatzer/717cdfabb2a2d17ef3fda031757c37f6 to your computer and use it in GitHub Desktop.
Woocommerce get product type
This file contains 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