0

I custom a tab in panel (post.php page) like this:

enter image description here

But I want to hide it if it isn't virtual product. And if it is virtual product, show it.

I don't know how can I get the value of product which is virtual or not.

1 Answer 1

0

call this on product-page template where you want to handle icon or tab:

<?php
    if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
    global $post, $woocommerce, $product;

    if ($product-> is_virtual('yes')) {
        // your logic to display tab or image etc 
    }else{
        // your logic not to display tab or image etc 
    }
    ?>

follow this link for details

For more related details see this link and this one

Hope this will give you idea and help!

According to comment to get product type with ID : For details

$product = get_product(619);
echo $product->product_type; 
3
  • Uncaught Error: Call to a member function is_virtual() on null
    – Yan Jun
    Jan 5, 2018 at 8:04
  • 1
    Thanks.I has already fixed this problem with your solution. And reference this:stackoverflow.com/questions/23576584/…
    – Yan Jun
    Jan 5, 2018 at 8:16
  • Thanks I have edited answer as per your comment and reference link !
    – jas
    Jan 5, 2018 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.