Forked from patrickgilmour/woocommerce-simple-or-variable.php
Last active
January 22, 2017 17:09
-
-
Save conschneider/977545250b3783acd632ab3d39bff8df 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 | |
*/ | |
//get product right first to access methods of WC_Product() | |
$product = wc_get_product( get_the_ID() ); | |
//Conditional check | |
if( $$product->is_type( 'simpe' ) ){ | |
// a simple product | |
} elseif( $product->is_type( 'variable' ) && $product->has_child() ){ | |
// a variable product | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment