is_type()
14th January 2021
0 Comments
Framework / CMS
WooCommerce [Version: Since 3.0.0]
Syntax
Typical Usage
returns the WooCommerce product type. eg, simple, variable, etc.
Accepted Parameters
- type (string or array) (Required): A string or an array of types to check. Use a string to check for a single type or an array to check for multiple types.
Return Value(s)
Returns a boolean value.Notes
Backwards compatibility is available to check for types of downloadable and virtual although newer methods have been added for those. See is_virtual() and is_downloadable().
Examples of is_type()
Example 1
<?php
$product = wc_get_product(1234);
if ( $product->is_type('variable') ) {
// Do Something
}
Used In Projects
Was This Helpful?
If this post has helped you, please let me know. Your feedback will be highly appreciated and will help me build better content.