admin管理员组文章数量:1122832
I custom a tab in panel (post.php page) like this:
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.
I custom a tab in panel (post.php page) like this:
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.
Share Improve this question asked Jan 5, 2018 at 7:39 Yan JunYan Jun 131 silver badge4 bronze badges1 Answer
Reset to default 0call 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;
本文标签: Can I get some product is virtual in Woocommerce by hook
版权声明:本文标题:Can I get some product is virtual in Woocommerce by hook? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736297668a1930060.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论