Forked from patrickgilmour/woocommerce-simple-or-variable.php
Created
December 18, 2017 15:12
-
-
Save ThomasLarge/5f4174951a802ad4c6ffc30a8f407ae7 to your computer and use it in GitHub Desktop.
WooCommerce conditional to test if a Product is Simple or Variable.
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
<?php | |
/** | |
* Is a WooCommerce Product Simple or Variable | |
* | |
* see http://wordpress.org/support/topic/condition-to-check-if-product-is-simple-or-variable | |
*/ | |
if( $product->is_type( 'simple' ) ){ | |
// a simple product | |
} elseif( $product->is_type( 'variable' ) ){ | |
// a variable product | |
} | |
// If you need a Product object for the above: | |
$product = new WC_Product( get_the_ID() ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment