Woocommerce – how to tell if product post has variations or not

Use $product->is_type() function to check the product type. To check if the product is a variable product use:

global $product;

// $product->is_type( $type ) checks the product type, string/array $type ( 'simple', 'grouped', 'variable', 'external' ), returns boolean

if ( $product->is_type( 'variable' ) ) {}

There is also $product->get_type() function that returns the internal type of a product as a string.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)