ThomasLarge
12/18/2017 - 3:12 PM

WooCommerce conditional to test if a Product is Simple or Variable.

WooCommerce conditional to test if a Product is Simple or Variable.

<?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() );