How to check if is a custom product type option in woocommerce?

by darrion.kuhn , in category: PHP CMS , a year ago

How to check if is a custom product type option in woocommerce?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by rollin , a year ago

@darrion.kuhn 

You can use the following code snippet to check if a product is a custom product type option in WooCommerce:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
global $product;

if ( $product->is_type( 'custom' ) ) {
    // Product is a custom product type option
    // Add your custom logic here
    echo 'This is a custom product type option';
} else {
    // Product is not a custom product type option
    // Add your custom logic here
    echo 'This is not a custom product type option';
}


This code snippet checks if the current product is of type 'custom'. If it is, it will execute the code within the if block. If it is not, it will execute the code within the else block. You can customize the logic inside the if and else blocks to suit your specific needs.

Related Threads:

How to check type of order notes in woocommerce?
How to add custom post type / post to woocommerce?
How to check for an array of product ids in woocommerce?
How to check if variable product id is in the woocommerce cart?
How to create a working custom product query in woocommerce?
How display a product custom field value in woocommerce?