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

by darrion.kuhn , in category: PHP CMS , 5 months ago

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

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by rollin , 5 months 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.