Php 如何在WooCommerce循环中获得产品可见性?
如何获得产品可见性的价值 我想根据产品可见性(如果隐藏)在循环中设置条件显示 比如:Php 如何在WooCommerce循环中获得产品可见性?,php,wordpress,methods,woocommerce,product,Php,Wordpress,Methods,Woocommerce,Product,如何获得产品可见性的价值 我想根据产品可见性(如果隐藏)在循环中设置条件显示 比如: if($my_product is hidden) { } 您只需在WC\u产品上使用以下对象: global $product; // Be sure to get the WC_Product instance object if( ! is_a( $product, 'WC_Product' ) ) { $product = wc_get_product( get_the_id() ); }
if($my_product is hidden) {
}
您只需在WC\u产品上使用以下对象:
global $product;
// Be sure to get the WC_Product instance object
if( ! is_a( $product, 'WC_Product' ) ) {
$product = wc_get_product( get_the_id() );
}
// Check product visibility
if( ! $product->is_visible() ) {
// Not visible
} else {
// Visible
}
应该能用。谢谢,我要测试一下!