I need to create a conditional to hide a specific part of my product page template if the product is a Gift Card type.
I tried something like this but it returning FALSE
$temp_product = wc_get_product( $product->get_id() );
var_dump( is_a( $temp_product, 'WC_Product_PW_Gift_Card' ) );
How it is possible to do get the type of product (Gift card or not)?
EDIT: I am using woocommerce gift Card plugin.
2
Answers
I got the solution for my problem so I am posting it here, hope this will help others.
You can try to check the product type with the
WC_Product
get_type()
method.Try to use (where "product_type" need to be replaced with your Gift card product type slug):
It could work.
Now to get the product object from cart items you will use
$cart_item['data']
, and on orders items you will use$item->get_product()
.